cliagents
CLAUDE.md19 starsChanged 7 months agoMITView on GitHub
A Node.js server that wraps CLI-based AI agents (Claude Code, Gemini CLI, Codex, etc.) and exposes them via HTTP REST API and WebSocket. For repo-local coding policy and stable agent guidance, start with AGENTS.md. Keep architecture notes, API details, and broader project documentation here and under docs/. Single unified database: data/cliagents.db
- Sends data out
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adding-adaptersSkill
- adding-adaptersSkill
- agent-handoffSkill
- brainstormingSkill
- broker-collaborationSkill
- code-reviewSkill
- debuggingSkill
- multi-agent-workflowSkill
- parallel-agentsSkill
- test-driven-developmentSkill
- token-efficient-contextSkill
- using-skillsSkill
The file
We split this CLAUDE.md into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 167
All errors follow a standardized format:
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
cliagents
A Node.js server that wraps CLI-based AI agents (Claude Code, Gemini CLI, Codex, etc.) and exposes them via HTTP REST API and WebSocket.
For repo-local coding policy and stable agent guidance, start with AGENTS.md. Keep architecture notes, API details, and broader project documentation here and under docs/.
Quick Start
# Start server
npm start
# Server at http://localhost:4001
# WebSocket at ws://localhost:4001/wsArchitecture
┌─────────────────────────────────────────────────────────┐
│ Application Layer │
│ (HTTP REST + WebSocket) │
├─────────────────────────────────────────────────────────┤
│ Session Management Layer │
│ (SessionManager - handles lifecycle) │
├─────────────────────────────────────────────────────────┤
│ Adapter Layer │
│ ClaudeCodeAdapter │ GeminiCliAdapter │
├─────────────────────────────────────────────────────────┤
│ CLI Processes │
│ claude --resume │ gemini -r latest │
└─────────────────────────────────────────────────────────┘Key Files
| File | Purpose |
src/index.js | Main entry point, exports |
src/server/index.js | HTTP/WebSocket server |
src/core/session-manager.js | Session lifecycle management |
src/core/adapter.js | Base adapter class |
src/adapters/claude-code.js | Claude Code CLI wrapper |
src/adapters/gemini-cli.js | Gemini CLI wrapper |
src/database/db.js | Unified database (SQLite) |
src/database/schema.sql | Database schema (8 tables) |
src/routes/memory.js | Shared memory REST endpoints |
src/orchestration/handoff.js | Agent-to-agent task delegation |
src/utils/gemini-config.js | Gemini config.yaml manager (generation params) |
src/services/transcriptionService.js | Whisper audio transcription |
Database Schema
Single unified database: data/cliagents.db
┌─────────────────────────────────────────────────────────────┐
│ cliagents.db (Unified) │
├─────────────────────────────────────────────────────────────┤
│ ORCHESTRATION │ SHARED MEMORY │ TRACING │
│ ├── terminals │ ├── artifacts │ ├── traces │
│ ├── inbox │ ├── findings │ └── spans │
│ └── annotations │ └── context │ │
└─────────────────────────────────────────────────────────────┘Tables
| Table | Purpose |
terminals | Registered CLI agent sessions |
inbox | Message queue for inter-agent communication |
traces | Orchestration traces for observability |
spans | Individual operations within a trace |
annotations | File-based annotations (workspace_id, file_path) |
artifacts | Code, files, outputs from agents (task_id, key) |
findings | Insights, bugs, issues from agents (task_id, severity) |
context | Conversation summaries for agent handoff |
API Endpoints
GET /health - Health check
GET /openapi.json - OpenAPI 3.0 specification
GET /adapters - List available adapters (includes available models)
POST /sessions - Create new session
GET /sessions - List all sessions
GET /sessions/:id - Get session info
GET /sessions/:id/status - Get session status (running/stable/error)
POST /sessions/:id/interrupt - Interrupt active process
POST /sessions/:id/messages - Send message (streaming with SSE)
POST /sessions/:id/files - Upload files to session working directory
GET /sessions/:id/files - List files in session working directory
DELETE /sessions/:id - Terminate session
POST /ask - One-shot ask (auto session)
# Shared Memory (Multi-Agent Collaboration)
POST /orchestration/memory/artifacts - Store an artifact
GET /orchestration/memory/artifacts/:taskId - Get all artifacts for a task
GET /orchestration/memory/artifacts/:taskId/:key - Get specific artifact
DELETE /orchestration/memory/artifacts/:taskId/:key - Delete artifact
POST /orchestration/memory/findings - Store a finding
GET /orchestration/memory/findings/:taskId - Get all findings for a task
GET /orchestration/memory/findings/by-id/:id - Get finding by ID
DELETE /orchestration/memory/findings/:id - Delete finding
POST /orchestration/memory/context - Store context
GET /orchestration/memory/context/:taskId - Get context for a task
GET /orchestration/memory/tasks/:taskId - Get complete memory for a task
DELETE /orchestration/memory/tasks/:taskId - Clear all memory for a task
GET /orchestration/memory/stats - Get memory statistics
POST /orchestration/memory/cleanup - Clean up old entriesSession Options (POST /sessions)
{
"adapter": "claude-code", // or "gemini-cli"
"model": "claude-sonnet-4-5-20250514", // model selection
"systemPrompt": "You are a helpful assistant",
"workDir": "/tmp/project",
"jsonSchema": {"type": "object", ...}, // Claude only - structured output
"allowedTools": ["Read", "Write"], // restrict available tools
// Generation parameters (Gemini only - writes to ~/.gemini/config.yaml)
"temperature": 0.7, // 0.0-2.0
"top_p": 0.9, // 0.0-1.0
"top_k": 40, // integer
"max_output_tokens": 8192 // integer (also works for Claude via env var)
}Generation Parameters
| Parameter | Claude | Gemini | Notes |
temperature | ❌ | ✅ | Controls randomness (0.0-2.0) |
top_p | ❌ | ✅ | Nucleus sampling threshold |
top_k | ❌ | ✅ | Top-k sampling |
max_output_tokens | ✅ | ✅ | Claude: via CLAUDE_CODE_MAX_OUTPUT_TOKENS env var; Gemini: via config.yaml |
jsonSchema | ✅ | ❌ | Structured JSON output enforcement |
Message Options (POST /sessions/:id/messages)
{
"message": "Your prompt here",
"stream": true, // Enable SSE streaming
"timeout": 120000, // Custom timeout in ms
"jsonSchema": {...}, // Per-message schema override (Claude)
"allowedTools": [...] // Per-message tools override
}File Upload (POST /sessions/:id/files)
{
"files": [
{ "name": "data.txt", "content": "Hello", "encoding": "utf8" },
{ "name": "image.png", "content": "base64...", "encoding": "base64" }
]
}Error Response Format
All errors follow a standardized format:
{
"error": {
"code": "session_not_found",
"message": "The specified session was not found",
"type": "session_not_found",
"param": null
}
}Error codes include:
invalid_request_error(400) - Malformed requestmissing_parameter(400) - Required parameter missingsession_not_found(404) - Session doesn't existadapter_not_found(404) - Unknown adapteradapter_unavailable(503) - CLI not installedtimeout_error(504) - Request timed outcli_error(500) - CLI process errorinternal_error(500) - Server error
Usage Examples
One-shot ask (simplest)
curl -X POST http://localhost:4001/ask \
-H "Content-Type: application/json" \
-d '{"message": "What is 2+2?", "adapter": "claude-code"}'Session-based (preserves context)
# Create session
curl -X POST http://localhost:4001/sessions \
-d '{"adapter": "claude-code"}'
# Returns: {"sessionId": "abc123", ...}
# Send messages (context preserved)
curl -X POST http://localhost:4001/sessions/abc123/messages \
-d '{"message": "My name is Suyash"}'
curl -X POST http://localhost:4001/sessions/abc123/messages \
-d '{"message": "What is my name?"}'
# Returns: "Your name is Suyash" ✓Integration with AI-Twin
This server is designed to work with the AI-Twin learning loop:
┌────────────────────────────────────────────────────────────┐
│ PROMPT TO AGENT │
├────────────────────────────────────────────────────────────┤
│ Task: Book a flight on google.com/flights │
│ │
│ ## PAST LEARNINGS FOR google.com: │
│ - Search box: role=combobox, aria-label contains "Search" │
│ - Cookie consent popup appears first │
│ │
│ Screenshot attached. What's next? │
└────────────────────────────────────────────────────────────┘| Component | Responsibility |
| Neo4j | Stores learnings, workflows, patterns |
| AI-Browser | Queries Neo4j, builds prompts, executes actions |
| Agent Server | Translates CLI calls, no knowledge of learnings |
| Agent (Claude/Gemini) | Receives learnings as prompt context |
Session Management
- Sessions auto-timeout after 30 minutes of inactivity
- Max 10 concurrent sessions (oldest evicted if exceeded)
- Context preserved via CLI resume flags:
- Claude:
--resume <sessionId> - Gemini:
-r latest
- Claude:
Configuration
const server = new AgentServer({
port: 3001,
sessionTimeout: 30 * 60 * 1000, // 30 min
maxSessions: 10,
claudeCode: {
timeout: 60000,
skipPermissions: true
},
geminiCli: {
timeout: 60000,
yoloMode: true,
model: 'gemini-2.5-flash'
}
});Testing
# Start server first
npm start
# Run tests (in another terminal)
npm testTest files:
tests/run-all.js- Main automated test suite (health, adapters, sessions, streaming, context)tests/test-file-context.js- File context preservation teststests/test-screenshot-context.js- Screenshot/image context testsexamples/test-basic.js- Basic usage example
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

