vastai-local-dev-loop
Sets up a fast, reproducible local development loop for Vast.ai GPU projects to minimize cloud costs.
Install
mkdir -p .claude/skills/vastai-local-dev-loop && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5336" && unzip -o skill.zip -d .claude/skills/vastai-local-dev-loop && rm skill.zipInstalls to .claude/skills/vastai-local-dev-loop
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Configure Vast.ai local development with testing and fast iteration.Key capabilities
- →Structure projects with API clients and job runners
- →Mock Vast.ai API responses for unit testing
- →Test Docker images locally in CPU mode
- →Verify CLI authentication and account balance
- →Implement dry-run workflows for training scripts
How it works
It establishes a local development loop by mocking the Vast.ai API and using Docker to simulate the containerized environment. This allows developers to validate logic and job orchestration without incurring cloud GPU costs.
Inputs & outputs
When to use vastai-local-dev-loop
- →Setting up local development environments
- →Testing GPU job provisioning
- →Mocking Vast.ai API for fast iteration
About this skill
Vast.ai Local Dev Loop
Overview
Set up a fast, reproducible local development workflow for Vast.ai GPU workloads. Test Docker images locally, mock API responses for CI, and minimize cloud GPU costs during development.
Prerequisites
- Completed
vastai-install-authsetup - Docker installed locally
- Python 3.8+ with pytest
Instructions
Step 1: Project Structure
vastai-project/
src/
vastai_client.py # API client wrapper
job_runner.py # Job orchestration logic
instance_manager.py # Instance lifecycle management
docker/
Dockerfile # GPU workload image
requirements.txt # Python dependencies for GPU job
tests/
test_client.py # Unit tests with mocked API
test_job_runner.py # Integration tests
conftest.py # Shared fixtures and mocks
scripts/
test-connection.sh # Quick API verification
benchmark-gpu.py # GPU benchmark script
.env.development # Dev API key (low spending limit)
.env.production # Prod API key (gitignored)
Step 2: Mock the Vast.ai API for Testing
# tests/conftest.py
import pytest
from unittest.mock import MagicMock
@pytest.fixture
def mock_vast_client():
client = MagicMock()
client.search_offers.return_value = {
"offers": [
{"id": 12345, "gpu_name": "RTX_4090", "gpu_ram": 24,
"dph_total": 0.22, "reliability2": 0.99,
"inet_down": 500, "ssh_host": "test.host", "ssh_port": 22},
]
}
client.create_instance.return_value = {"new_contract": 67890}
client.show_instances.return_value = [
{"id": 67890, "actual_status": "running",
"ssh_host": "test.host", "ssh_port": 22}
]
return client
Step 3: Test Docker Images Locally
# Build and test your GPU image locally (CPU mode)
docker build -t my-training:dev -f docker/Dockerfile .
docker run --rm my-training:dev python -c "import torch; print('OK')"
# Test training script in CPU mode
docker run --rm -v $(pwd)/data:/workspace/data my-training:dev \
python train.py --epochs 1 --batch-size 4 --device cpu --dry-run
Step 4: Quick Connection Test Script
#!/bin/bash
set -euo pipefail
echo "Testing Vast.ai connection..."
vastai show user 2>/dev/null && echo " CLI auth: OK" || echo " CLI auth: FAIL"
BALANCE=$(vastai show user --raw 2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin).get('balance',0))")
echo " Balance: \$$BALANCE"
echo "Connection verified."
Step 5: Development Workflow
# 1. Edit Docker image and training code locally
# 2. Test locally with CPU mode
docker build -t my-training:dev . && docker run --rm my-training:dev python train.py --dry-run
# 3. Push image to registry
docker tag my-training:dev ghcr.io/yourorg/training:dev && docker push ghcr.io/yourorg/training:dev
# 4. Rent cheapest GPU for real test
vastai create instance OFFER_ID --image ghcr.io/yourorg/training:dev --disk 20
# 5. Monitor, verify, destroy
vastai show instances && vastai destroy instance INSTANCE_ID
Output
- Project structure with client, tests, and Docker setup
- Mocked Vast.ai client for unit tests (no API calls)
- Local Docker testing workflow (CPU mode)
- Connection verification script
Error Handling
| Error | Cause | Solution |
|---|---|---|
| Docker build fails | Missing CUDA locally | Use CPU-compatible base image for local testing |
| Mock assertions fail | API interface changed | Update mock return values to match current API |
| Balance too low for testing | Dev account underfunded | Add $5 credits for dev testing |
| Image push rejected | Registry auth missing | Run docker login ghcr.io first |
Resources
Next Steps
Proceed to vastai-sdk-patterns for production-ready API patterns.
Examples
TDD workflow: Write tests that mock search_offers and create_instance, implement the job runner to pass tests, then run one real integration test against the API.
Cost-controlled dev: Set dph_total<=0.10 in search queries and auto-destroy after 30 minutes to keep testing costs under $0.05.
When not to use it
- →Testing code that requires actual GPU hardware acceleration
- →Performance benchmarking on CPU-only environments
Prerequisites
Limitations
- →Local testing uses CPU mode which may not catch GPU-specific errors
- →Mock return values must be manually updated if the API interface changes
How it compares
It shifts testing from the cloud to a local containerized environment, reducing costs and iteration time compared to deploying to a remote GPU instance for every change.
Compared to similar skills
vastai-local-dev-loop side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| vastai-local-dev-loop (this skill) | 1 | 27d | Review | Intermediate |
| documenso-local-dev-loop | 2 | 27d | Review | Beginner |
| gentleman-e2e | 1 | 7mo | Review | Intermediate |
| nx-run-tasks | 1 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by jeremylongshore
View all by jeremylongshore →You might also like
documenso-local-dev-loop
jeremylongshore
Set up local development environment and testing workflow for Documenso. Use when configuring dev environment, setting up test workflows, or establishing rapid iteration patterns with Documenso. Trigger with phrases like "documenso local dev", "documenso development", "test documenso locally", "documenso dev environment".
gentleman-e2e
Gentleman-Programming
Docker-based E2E testing patterns for Gentleman.Dots installer. Trigger: When editing files in installer/e2e/, writing E2E tests, or adding platform support.
nx-run-tasks
nrwl
Helps with running tasks in an Nx workspace. USE WHEN the user wants to execute build, test, lint, serve, or run any other tasks defined in the workspace.
firecrawl-local-dev-loop
jeremylongshore
Configure FireCrawl local development with hot reload and testing. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with FireCrawl. Trigger with phrases like "firecrawl dev setup", "firecrawl local development", "firecrawl dev environment", "develop with firecrawl".
bazel-build-optimization
wshobson
Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.
modal
davila7
Run Python code in the cloud with serverless containers, GPUs, and autoscaling. Use when deploying ML models, running batch processing jobs, scheduling compute-intensive tasks, or serving APIs that require GPU acceleration or dynamic scaling.