Your complete guide to setting up ChaozCode and building your first AI-powered project. Follow these steps to unlock the full potential of intelligent development.
⏱️ 15-20 minutes to completeBefore you begin, ensure you have the following requirements met:
| Plan | Features | Best For |
|---|---|---|
| Free | 100 API calls/day, 1 project, basic features | Exploration & learning |
| Pro | 10,000 API calls/day, unlimited projects, Memory Spine | Individual developers |
| Team | 100,000 API calls/day, team collaboration, priority support | Development teams |
| Enterprise | Unlimited, dedicated infrastructure, SLA | Organizations |
Install the ChaozCode CLI globally using npm:
# Install globally
npm install -g @chaozcode/cli
# Verify installation
chaozcode --version
# Output: ChaozCode CLI v2.4.0
# View available commands
chaozcode --help
# Using npm
npm install @chaozcode/sdk
# Using yarn
yarn add @chaozcode/sdk
# Using pnpm
pnpm add @chaozcode/sdk
# Using pip
pip install chaozcode
# Using poetry
poetry add chaozcode
# Verify installation
python -c "import chaozcode; print(chaozcode.__version__)"
Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (Mac)# Authenticate with your API key
chaozcode auth login
# Or set directly via environment variable
export CHAOZCODE_API_KEY="your-api-key-here"
# Verify authentication
chaozcode auth status
# Output: ✓ Authenticated as: your@email.com
Create a chaozcode.config.js file in your project root:
// chaozcode.config.js
module.exports = {
// Project identification
projectId: "my-awesome-project",
// Memory Spine settings
memory: {
enabled: true,
autoSync: true,
maxContextTokens: 4000
},
// AI model preferences
model: {
default: "gpt-4",
fallback: "claude-3-sonnet",
temperature: 0.7
},
// Code analysis
codebase: {
include: ["src/**/*.ts", "src/**/*.tsx"],
exclude: ["node_modules", "dist", "*.test.*"],
maxFileSize: 100000 // bytes
},
// Agent configuration
agents: {
defaultTimeout: 30000,
maxConcurrent: 3
}
};
Create a .env file (add to .gitignore):
# .env
CHAOZCODE_API_KEY=your-api-key-here
CHAOZCODE_PROJECT_ID=my-awesome-project
CHAOZCODE_ENVIRONMENT=development
CHAOZCODE_LOG_LEVEL=info
# Optional: Memory Spine custom endpoint
# CHAOZCODE_MEMORY_ENDPOINT=https://custom.endpoint.com
# Optional: Model overrides
# CHAOZCODE_DEFAULT_MODEL=gpt-4-turbo
Configure the extension in VS Code settings (Ctrl+,):
{
"chaozcode.enabled": true,
"chaozcode.autoComplete": true,
"chaozcode.inlineHints": true,
"chaozcode.memorySpine.enabled": true,
"chaozcode.codeReview.autoTrigger": true,
"chaozcode.model": "gpt-4",
"chaozcode.telemetry": false
}
# Test API connection
chaozcode ping
# Output: ✓ Connected to ChaozCode API (latency: 45ms)
# Check service status
chaozcode status
# Output:
# ✓ API: healthy
# ✓ Memory Spine: healthy (5,234 vectors)
# ✓ Zearch: healthy
# ✓ Authentication: valid
# Initialize Memory Spine for your project
chaozcode memory init
# Check memory stats
chaozcode memory stats
# Output:
# Vectors: 0
# Storage: 0 MB
# Last sync: Never
# Store your first memory
chaozcode memory store --id "project-init" --content "Project initialized with ChaozCode" --tags "setup"
# Link your GitHub account for enhanced features
chaozcode integrations connect github
# This enables:
# - PR code reviews
# - Issue analysis
# - Commit context
# - Repository insights
// test-connection.js
const { ChaozCode } = require('@chaozcode/sdk');
const client = new ChaozCode({
apiKey: process.env.CHAOZCODE_API_KEY
});
async function testConnection() {
// Test basic query
const response = await client.query({
prompt: "What is 2 + 2?",
model: "gpt-4"
});
console.log("Response:", response.text);
// Test Memory Spine
const stats = await client.memory.stats();
console.log("Memory vectors:", stats.vectorCount);
// Test code analysis
const analysis = await client.codebase.analyze({
path: "./src"
});
console.log("Files analyzed:", analysis.fileCount);
}
testConnection().catch(console.error);
# test_connection.py
import os
from chaozcode import ChaozCode
client = ChaozCode(api_key=os.environ["CHAOZCODE_API_KEY"])
# Test basic query
response = client.query(
prompt="What is 2 + 2?",
model="gpt-4"
)
print(f"Response: {response.text}")
# Test Memory Spine
stats = client.memory.stats()
print(f"Memory vectors: {stats['vector_count']}")
# Test code analysis
analysis = client.codebase.analyze(path="./src")
print(f"Files analyzed: {analysis['file_count']}")
Let's build a simple task manager that uses ChaozCode for intelligent features.
# Create project directory
mkdir chaozcode-task-manager
cd chaozcode-task-manager
# Initialize npm project
npm init -y
# Install dependencies
npm install @chaozcode/sdk express dotenv
# Create project structure
mkdir src
touch src/index.js src/tasks.js .env
# .env
CHAOZCODE_API_KEY=your-api-key-here
PORT=3000
// src/tasks.js
const { ChaozCode } = require('@chaozcode/sdk');
const client = new ChaozCode({
apiKey: process.env.CHAOZCODE_API_KEY
});
class TaskManager {
constructor() {
this.tasks = [];
}
async addTask(description) {
// Use AI to analyze and categorize the task
const analysis = await client.query({
prompt: `Analyze this task and return JSON with: category, priority (1-5), estimatedMinutes
Task: "${description}"`,
model: "gpt-4"
});
const taskData = JSON.parse(analysis.text);
const task = {
id: Date.now(),
description,
...taskData,
status: 'pending',
createdAt: new Date()
};
this.tasks.push(task);
// Store in Memory Spine for context
await client.memory.store({
id: `task-${task.id}`,
content: JSON.stringify(task),
tags: ['task', taskData.category]
});
return task;
}
async suggestNextTask() {
// Use Memory Spine to find patterns
const recentTasks = await client.memory.search({
query: 'completed tasks this week',
tags: ['task'],
limit: 10
});
const pendingTasks = this.tasks.filter(t => t.status === 'pending');
const suggestion = await client.query({
prompt: `Based on recently completed tasks and current pending tasks, suggest which task to work on next and why.
Recent completed: ${JSON.stringify(recentTasks)}
Pending: ${JSON.stringify(pendingTasks)}`,
model: "gpt-4"
});
return suggestion.text;
}
async completeTask(taskId) {
const task = this.tasks.find(t => t.id === taskId);
if (!task) throw new Error('Task not found');
task.status = 'completed';
task.completedAt = new Date();
// Update Memory Spine
await client.memory.update({
id: `task-${task.id}`,
content: JSON.stringify(task),
tags: ['task', 'completed']
});
return task;
}
}
module.exports = TaskManager;
// src/index.js
require('dotenv').config();
const express = require('express');
const TaskManager = require('./tasks');
const app = express();
const taskManager = new TaskManager();
app.use(express.json());
// Add a task
app.post('/tasks', async (req, res) => {
try {
const task = await taskManager.addTask(req.body.description);
res.json({ success: true, task });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
// Get task suggestions
app.get('/tasks/suggest', async (req, res) => {
try {
const suggestion = await taskManager.suggestNextTask();
res.json({ suggestion });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
// Complete a task
app.post('/tasks/:id/complete', async (req, res) => {
try {
const task = await taskManager.completeTask(parseInt(req.params.id));
res.json({ success: true, task });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Task Manager running on port ${PORT}`);
});
# Start the server
node src/index.js
# In another terminal, test the API:
# Add a task
curl -X POST http://localhost:3000/tasks \
-H "Content-Type: application/json" \
-d '{"description": "Write documentation for the new API endpoint"}'
# Get suggestions
curl http://localhost:3000/tasks/suggest
# Complete a task (use the ID from the add response)
curl -X POST http://localhost:3000/tasks/1234567890/complete
echo $CHAOZCODE_API_KEYcurl https://api.chaozcode.com/healthchaozcode usagenpm bin -gexport PATH="$(npm bin -g):$PATH"