This directory contains the command-line interface (CLI) for the Claude Code project, which provides an interactive environment for working with Anthropic’s Claude AI models.
The CLI is implemented as a Docker-based environment that provides:
@anthropic-ai/sdk
pre-installedCopy the example environment file and update it with your API key:
cp .env.example .env
# Edit .env and set your ANTHROPIC_API_KEY
Make the CLI script executable:
chmod +x cli/claude-code.sh
Run the CLI using the provided script:
./cli/claude-code.sh
This will:
@anthropic-ai/sdk
globally in the containerOnce inside the container, you can use the following commands:
node
- Start a Node.js REPL with the Anthropic SDK availablenpm install -g @anthropic-ai/sdk
- Update the SDK to the latest versionexit
- Exit the container// In the Node.js REPL
const { Anthropic } = require('@anthropic-ai/sdk');
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY
});
async function main() {
const message = await anthropic.messages.create({
model: 'claude-3-opus-20240229',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }]
});
console.log(message);
}
main().catch(console.error);
claude-code.sh
- Main script to start the CLI environmentdocker-compose.claude-code.yml
- Docker Compose configurationTo add new Node.js dependencies:
Edit the entrypoint
in docker-compose.claude-code.yml
to include the new package:
entrypoint: |
/bin/sh -c '
# ... existing setup ...
su -c "npm install -g @anthropic-ai/sdk new-package-name" node && \
# ... rest of the entrypoint
'
Rebuild and restart the container:
docker-compose -f docker-compose.claude-code.yml up -d --build
If you encounter permission issues with the container:
# Check container logs
docker logs claude-code
# Fix permissions on mounted volumes
docker exec claude-code chown -R node:node /workspace
To update to the latest version of the Anthropic SDK:
docker exec -u node claude-code npm install -g @anthropic-ai/sdk@latest
This project is licensed under the terms of the MIT license.