| name | anth-local-dev-loop |
| description | Configure a local development workflow for Anthropic Claude API projects.
Use when setting up dev environment, configuring hot reload,
or establishing a fast iteration cycle with the Messages API.
Trigger with phrases like "anthropic local dev", "claude dev setup",
"anthropic development workflow", "test claude locally".
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Bash(pip:*), Grep |
| version | 1.6.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","ai","anthropic"] |
| compatibility | Designed for Claude Code |
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-auth setup
- Node.js 18+ or Python 3.8+
.env file with ANTHROPIC_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
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;
}
export function logUsage(messageId: string, : { input_tokens: ; output_tokens: }, : ) {
: <, { : ; : }> = {
: { : , : },
: { : , : },
: { : , : },
};
rates = pricing[model] || pricing[];
cost = (usage. * rates. + usage. * rates.) / ;
.();
}