Anth local dev loop
'Configure a local development workflow for Anthropic Claude API projects.From its SKILL.md
npx -y skills add jeremylongshore/claude-code-plugins-plus-skills --skill anth-local-dev-loopAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
4.4 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Anthropic Local Dev Loop
Overview
Set up a fast local development cycle for Claude API projects with environment management, request logging, cost tracking, and hot-reload.
Prerequisites
- Completed
anth-install-authsetup - Node.js 18+ or Python 3.8+
.envfile withANTHROPIC_API_KEY
Instructions
Step 1: Project Structure
my-claude-app/
├── .env # ANTHROPIC_API_KEY=sk-ant-...
├── .env.example # ANTHROPIC_API_KEY=your-key-here
├── .gitignore # Include .env
├── src/
│ ├── client.ts # Singleton client
│ ├── prompts/ # System prompts as files
│ └── tools/ # Tool definitions
├── tests/
│ └── mock-responses/ # Saved API responses for testing
└── scripts/
└── dev.ts # Dev runner with logging
Step 2: Singleton Client with Request Logging
// src/client.ts
import Anthropic from '@anthropic-ai/sdk';
let client: Anthropic | null = null;
export function getClient(): Anthropic {
if (!client) {
client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
maxRetries: 2,
timeout: 30_000,
});
}
return client;
}
// Development logger — tracks cost per request
export function logUsage(messageId: string, usage: { input_tokens: number; output_tokens: number }, model: string) {
const pricing: Record<string, { input: number; output: number }> = {
'claude-sonnet-4-20250514': { input: 3.0, output: 15.0 },
'claude-haiku-4-20250514': { input: 0.80, output: 4.0 },
'claude-opus-4-20250514': { input: 15.0, output: 75.0 },
};
const rates = pricing[model] || pricing['claude-sonnet-4-20250514'];
const cost = (usage.input_tokens * rates.input + usage.output_tokens * rates.output) / 1_000_000;
console.log(`[${messageId}] ${model} | ${usage.input_tokens}+${usage.output_tokens} tokens | $${cost.toFixed(4)}`);
}
Step 3: Mock Responses for Tests
// tests/mock-client.ts
import { type Message } from '@anthropic-ai/sdk/resources/messages';
export function mockMessage(text: string): Message {
return {
id: 'msg_test_123',
type: 'message',
role: 'assistant',
model: 'claude-sonnet-4-20250514',
content: [{ type: 'text', text }],
stop_reason: 'end_turn',
stop_sequence: null,
usage: { input_tokens: 10, output_tokens: 20 },
};
}
Step 4: Hot-Reload Dev Script
# package.json scripts
"scripts": {
"dev": "tsx watch src/index.ts",
"dev:debug": "ANTHROPIC_LOG=debug tsx watch src/index.ts",
"test": "vitest",
"test:live": "LIVE_API=1 vitest --run"
}
Environment Management
# .env.example (commit this)
ANTHROPIC_API_KEY=your-key-here
ANTHROPIC_MODEL=claude-sonnet-4-20250514
ANTHROPIC_MAX_TOKENS=1024
ANTHROPIC_LOG=warn # debug | info | warn | error
# Enable SDK debug logging
export ANTHROPIC_LOG=debug # Logs all requests/responses
Cost Control During Development
import os
DEV_MODEL = "claude-haiku-4-20250514" # $0.80/$4.00 per MTok
PROD_MODEL = "claude-sonnet-4-20250514" # $3.00/$15.00 per MTok
model = DEV_MODEL if os.getenv("ENV") == "development" else PROD_MODEL
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Hot reload triggers duplicate requests | File save causes restart | Add debounce or save-on-explicit-action |
.env not loading | Missing dotenv setup | Use dotenv package or tsx --env-file=.env |
| Mock tests pass but live fails | Response shape changed | Update mocks from real API responses |
Resources
Next Steps
Apply patterns in anth-sdk-patterns for production-ready code.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.