Why CLI + Hooks?
Claude Code integration usesbd prime and hooks instead of MCP for better efficiency:
- Lower token overhead: ~1-2k tokens vs 10-50k for MCP schemas
- Reduced compute cost: Fewer tokens means less processing per inference
- Better latency: Smaller prompts process faster
- Universal compatibility: Works in any environment with shell access
For MCP-only environments like Claude Desktop, see the MCP Server documentation.
Installation
Install Claude Code hooks
Install hooks globally (for all projects):Or install for the current project only:
What gets installed?
What gets installed?
- SessionStart hook: Runs
bd primewhen Claude Code starts a session - PreCompact hook: Runs
bd primebefore context compaction to preserve workflow instructions
Verify installation
Check that hooks are properly installed:You should see confirmation that both hooks are installed.
Configuration Options
Stealth Mode
Use stealth mode to flush context without git operations:Remove Hooks
To uninstall Claude Code hooks:How It Works
Automatic Context Injection
When you start a Claude Code session, the SessionStart hook automatically runs:- Available bd commands
- Issue tracking workflow
- Priority levels and issue types
- Best practices for AI agents
Context Preservation
Before Claude Code compacts context (to manage token limits), the PreCompact hook runsbd prime again, ensuring workflow instructions persist throughout long sessions.
Usage Examples
Starting Work
Simply ask Claude Code:Creating Issues
Updating Issues
Completing Work
Best Practices
Let hooks do the work
Don’t manually run
bd prime - the hooks inject context automaticallyUse natural language
Claude understands your intent - describe what you want in plain English
Trust the workflow
Claude knows the bd workflow from context injection
Review before push
Always review Claude’s changes before running
bd syncTroubleshooting
Hooks not running
Check hook installation:Claude not using bd commands
Manually inject context:Context gets lost during long sessions
The PreCompact hook should prevent this, but if context is lost:-
Check that the PreCompact hook is installed:
-
Manually run
bd primeto reinject context
Wrong database detected
Bd uses tree-walking to find the.beads/ directory. Ensure you’re in the correct project directory:
CLI vs MCP Comparison
| Approach | Token Overhead | Best For | Compute Cost |
|---|---|---|---|
| CLI + Hooks | ~1-2k tokens | Claude Code, Cursor, Windsurf | Low |
| MCP Server | ~10-50k tokens | Claude Desktop (MCP-only) | High |
Related Files
For developers extending Beads:cmd/bd/prime.go- Context generation logiccmd/bd/setup/claude.go- Hook installation codecmd/bd/doctor/claude.go- Integration verificationdocs/CLAUDE.md- General Claude Code guidance
See Also
MCP Server
Alternative integration for MCP-only environments
Copilot Integration
Use Beads with GitHub Copilot in VS Code
Aider Integration
Integrate with Aider for AI pair programming
Quick Start
Get started with Beads basics