This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build all packages
go build ./...
# Build example CLI
go build -o agent-example ./cmd/agent
# Run after build
./agent-example "your prompt here"
# Run tests (when they exist)
go test ./...
# Run single package test
go test ./app/...
# Lint (requires golangci-lint)
golangci-lint runInstall via:
go get github.com/dotcommander/agent-frameworkThe examples/ directory contains runnable examples for each major feature:
examples/loop/- Agent loop patternexamples/subagents/- Parallel subagent executionexamples/mcp/- MCP server/clientexamples/validation/- Rules-based validationexamples/codegen/- Code generation outputexamples/search/- Semantic searchexamples/state/- File system trackingexamples/evaluation/- Hierarchical verification
| Package | Purpose |
|---|---|
app/ |
Application composition, agent loop, subagent spawning |
client/ |
Claude SDK wrapper, provider abstraction, context compaction |
cli/ |
Cobra command scaffolding, standard flags |
config/ |
Configuration types, functional options |
input/ |
Auto-detection of URLs, files, globs, text |
output/ |
JSON/Markdown/text formatters, code generation output |
tools/ |
Type-safe tool registration, MCP server/client |
validation/ |
Composable rules (Required, Regex, Enum, Range, Length, Custom) |
verification/ |
Visual verification, hierarchical evaluation |
state/ |
File system tracking, snapshots, rollback |
search/ |
Semantic search with embeddings, hybrid search |
Functional Options: All constructors use With* option functions:
app.New("myapp", "1.0.0",
app.WithSystemPrompt("..."),
app.WithTool(tool),
)Type-Safe Tools: Generic handlers with automatic JSON marshaling:
tools.TypedTool("name", "desc", schema, func(ctx context.Context, input T) (R, error) { ... })Agent Loop: Gather → Decide → Act → Verify cycle in app/loop.go:
AgentLoopinterface defines the contractSimpleLoopprovides configurable implementationLoopRunnerexecutes with limits (iterations, tokens, timeout)
Subagent Spawning: Parallel execution via app/subagent.go:
SubagentManager.Spawn()creates isolated child agentsRunAll()executes concurrently with errgroupFilterResults(),MergeResults(),AggregateTokens()for result handling
MCP Protocol: Model Context Protocol in tools/mcp.go:
MCPServerhandles initialize, tools/list, tools/call, resources/*MCPClient+ToolDiscoveryfor connecting to external servers- Protocol version:
2024-11-05(hardcoded inhandleInitialize)
MCP Compatibility:
- Implements MCP specification dated 2024-11-05
- Compatible with Claude Desktop, MCP Inspector, and conforming clients
- Supports: tools/list, tools/call, resources/list, resources/read
- JSON-RPC 2.0 transport with size limits (1MB default)
client/provider.go supports multiple backends:
- Anthropic (via agent-sdk-go) - default
- Z.AI - placeholder
- Synthetic - for testing without API calls