This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
make build # Build both binaries (map CLI and mapd daemon) to bin/
make test # Run tests with -v -race flags
make generate # Regenerate protobuf files (requires protoc)
make dev # Hot reload development mode (requires Air)
make rebuild # Clean, generate, and build
make install-tools # Install protoc-gen-go pluginsRun a single test:
go test -v -race ./internal/daemon -run TestStoreNameImportant: Before submitting changes, always run the linter and fix any issues:
golangci-lint run --timeout=5mCommon lint issues to watch for:
- errcheck: Always handle or explicitly ignore error return values (use
_ = fn()for intentionally ignored errors) - staticcheck: Avoid deprecated functions; check for modern alternatives
- For deferred close operations where errors can be ignored:
defer func() { _ = x.Close() }()
MAP uses a Docker-like CLI + daemon architecture for managing AI coding agents (Claude Code and OpenAI Codex).
CLI (map) ──gRPC──► Daemon (mapd) ──► Agent processes (tmux sessions)
│
├── Store (SQLite) - tasks, events, spawned_agents
├── ProcessManager - spawns agents in tmux
├── WorktreeManager - git worktree isolation
└── TaskRouter - task distribution
Communication: gRPC over Unix socket (/tmp/mapd.sock)
Data storage: SQLite at ~/.mapd/map.db
Agent isolation: Each agent runs in its own git worktree at ~/.mapd/worktrees/{agentID}/
cmd/map/- CLI entry point, routes tointernal/clicmd/mapd/- Daemon entry point, routes tointernal/daemoninternal/cli/- Cobra command implementationsinternal/daemon/- Core daemon logic:server.go- gRPC server, event broadcastingstore.go- SQLite persistence layerprocess.go- Agent spawning via tmuxworktree.go- Git worktree operationstask.go- Task routing logic
internal/client/- gRPC client wrapperproto/map/v1/- Protobuf definitions and generated code
Task lifecycle: PENDING → OFFERED → ACCEPTED → IN_PROGRESS → COMPLETED/FAILED/CANCELLED
Agent types: "claude" (default) or "codex", managed as tmux sessions named map-agent-{agentID}
Event streaming: Real-time via WatchEvents RPC with broadcast to all connected watchers