Add agent-first 'bd onboard' command (bd-173)

- Refactor bd onboard to output instructions instead of doing string replacement
- Leverage agent intelligence to naturally integrate bd into documentation
- Bootstrap via 'BEFORE ANYTHING ELSE: run bd onboard' in AGENTS.md
- Agent receives formatted instructions to update AGENTS.md and CLAUDE.md
- More agentic approach - adapts to existing project structure
- Update README with new bootstrap workflow

Amp-Thread-ID: https://ampcode.com/threads/T-d70fd1bf-8d44-48b6-bb55-5ae49efb23b8
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-20 15:04:33 -07:00
parent 01aeed6997
commit e10e34b221
5 changed files with 300 additions and 7 deletions

View File

@@ -76,6 +76,8 @@
{"id":"bd-167","title":"Test issue with labels","description":"","status":"closed","priority":2,"issue_type":"task","created_at":"2025-10-19T22:42:23.516678-07:00","updated_at":"2025-10-19T22:47:07.915048-07:00","closed_at":"2025-10-19T22:46:09.247654-07:00"}
{"id":"bd-168","title":"Test with labels","description":"","status":"closed","priority":2,"issue_type":"task","created_at":"2025-10-19T22:43:56.761279-07:00","updated_at":"2025-10-19T22:47:07.915193-07:00","closed_at":"2025-10-19T22:46:09.24785-07:00","labels":["frontend"]}
{"id":"bd-17","title":"Improve session management","description":"Current session management is basic. Need to improve with better expiration handling.","status":"closed","priority":2,"issue_type":"task","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.879664-07:00","closed_at":"2025-10-16T10:07:34.005199-07:00"}
{"id":"bd-172","title":"Fix MCP server None/null crashes in list/ready/stats","description":"","status":"closed","priority":0,"issue_type":"bug","created_at":"2025-10-19T23:22:56.591289-07:00","updated_at":"2025-10-19T23:23:25.755169-07:00","closed_at":"2025-10-19T23:23:25.755169-07:00"}
{"id":"bd-173","title":"Add 'bd onboard' command to configure AGENTS.md for AI agents","description":"Create a 'bd onboard' command that automatically sets up AGENTS.md (and adds a note to CLAUDE.md if present) with instructions for AI agents to use beads instead of markdown TODOs.\n\nProblem: Users report that AI agents get confused between beads issue tracking and markdown-based planning, leading to duplicate tracking systems and confusion about which to use.\n\nSolution: Add 'bd onboard' command that:\n1. Appends (or creates) AGENTS.md with beads workflow instructions\n2. Includes command examples, issue types, priorities, and workflow\n3. Adds note to CLAUDE.md if it exists, directing agents to use beads\n4. Makes it clear agents should abandon markdown TODOs in favor of bd\n5. Idempotent - safe to run multiple times\n\nThe onboarding content should emphasize:\n- Use bd for ALL task tracking, not markdown TODOs\n- How to check ready work, create/update/close issues\n- When to use discovered-from dependencies\n- Priority and issue type conventions\n- Auto-sync behavior\n\nThis will reduce onboarding friction and prevent agents from creating parallel tracking systems.","status":"closed","priority":1,"issue_type":"feature","created_at":"2025-10-20T14:34:52.483607-07:00","updated_at":"2025-10-20T14:57:39.014109-07:00","closed_at":"2025-10-20T14:57:39.014109-07:00"}
{"id":"bd-18","title":"Fix: bd init --prefix test -q flag not recognized","description":"The init command doesn't recognize the -q flag. When running 'bd init --prefix test -q', it fails silently or behaves unexpectedly. The flag should either be implemented for quiet mode or removed from documentation if not supported.","status":"closed","priority":2,"issue_type":"bug","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.87987-07:00","closed_at":"2025-10-17T00:09:18.921816-07:00"}
{"id":"bd-19","title":"Implement storage driver interface for pluggable backends","description":"Create abstraction layer for storage to support multiple backends (SQLite, Postgres, Turso, in-memory testing, etc.).\n\n**Current state:** All storage logic hardcoded to SQLite in internal/storage/sqlite/sqlite.go\n\n**Proposed design:**\n\n```go\n// internal/storage/storage.go\ntype Store interface {\n // Issue CRUD\n CreateIssue(issue *Issue) error\n GetIssue(id string) (*Issue, error)\n UpdateIssue(id string, updates *Issue) error\n DeleteIssue(id string) error\n ListIssues(filter *Filter) ([]*Issue, error)\n \n // Dependencies\n AddDependency(from, to string, depType DependencyType) error\n RemoveDependency(from, to string, depType DependencyType) error\n GetDependencies(id string) ([]*Dependency, error)\n \n // Counters, stats\n GetNextID(prefix string) (string, error)\n GetStats() (*Stats, error)\n \n Close() error\n}\n```\n\n**Benefits:**\n- Better testing (mock/in-memory stores)\n- Future flexibility (Postgres, cloud APIs, etc.)\n- Clean architecture (business logic decoupled from storage)\n- Enable Turso or other backends without refactoring everything\n\n**Implementation steps:**\n1. Define Store interface in internal/storage/storage.go\n2. Refactor SQLiteStore to implement interface\n3. Update all commands to use interface, not concrete type\n4. Add MemoryStore for testing\n5. Add driver selection via config (storage.driver = sqlite|turso|postgres)\n6. Update tests to use interface\n\n**Note:** This is valuable even without adopting Turso. Good architecture practice.\n\n**Context:** From GH issue #2 RFC evaluation. Driver interface is low-cost, high-value regardless of whether we add alternative backends.","status":"closed","priority":2,"issue_type":"feature","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.880038-07:00","closed_at":"2025-10-17T23:46:22.447301-07:00"}
{"id":"bd-2","title":"Sub-task under A","description":"","status":"closed","priority":1,"issue_type":"task","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.876832-07:00","closed_at":"2025-10-16T10:07:34.130096-07:00"}
@@ -88,7 +90,7 @@
{"id":"bd-26","title":"Add EXPLAIN QUERY PLAN tests for ready work query","description":"Verify that the hierarchical blocking query uses proper indexes and doesn't do full table scans.\n\n**Queries to analyze:**\n1. The recursive CTE (both base case and recursive case)\n2. The final SELECT with NOT EXISTS\n3. Impact of various filters (status, priority, assignee)\n\n**Implementation:**\nAdd test function that:\n- Runs EXPLAIN QUERY PLAN on GetReadyWork query\n- Parses output to verify no SCAN TABLE operations\n- Documents expected query plan in comments\n- Fails if query plan degrades\n\n**Benefits:**\n- Catch performance regressions in tests\n- Document expected query behavior\n- Ensure indexes are being used\n\nRelated to: bd-52 (composite index on depends_on_id, type)","status":"closed","priority":3,"issue_type":"task","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.915924-07:00","closed_at":"2025-10-18T12:47:44.284846-07:00"}
{"id":"bd-27","title":"Add performance benchmarks document","description":"Document actual performance metrics with hyperfine tests","status":"closed","priority":3,"issue_type":"task","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.881528-07:00","closed_at":"2025-10-18T10:09:23.532938-07:00"}
{"id":"bd-28","title":"Investigate vector/semantic search for issue discovery","description":"From GH issue #2 RFC discussion: Evaluate if vector/semantic search over issues would provide value for beads.\n\n**Use case:** Find semantically related issues (e.g., 'login broken' finds 'authentication failure', 'session expired').\n\n**Questions to answer:**\n1. What workflows would this enable that we can't do now?\n2. Is dataset size (typically 50-200 issues) large enough to benefit?\n3. Do structured features (deps, tags, types) already provide better relationships?\n4. What's the maintenance cost (embeddings, storage, recomputation)?\n\n**Alternatives to consider:**\n- Improve 'bd list' filtering with regex/boolean queries\n- Add 'bd related \u003cid\u003e' showing deps + mentions + same tags\n- Export to JSON and pipe to external AI tools\n\n**Decision:** Only implement if clear use case emerges. Don't add complexity for theoretical benefits.\n\n**Context:** Part of evaluating Turso RFC ideas (GH #2). Vector search was proposed but unclear if needed for typical beads usage.","status":"closed","priority":3,"issue_type":"task","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.881732-07:00","closed_at":"2025-10-18T10:09:23.532858-07:00"}
{"id":"bd-29","title":"Add visual indicators for nodes with multiple parents in dep tree","description":"When a node appears in the dependency tree via multiple paths (diamond dependencies), add a visual indicator like (*) or (multiple parents) to help users understand the graph structure. This would make it clear when deduplication has occurred. Example: 'bd-503: Shared dependency (*) [P1] (open)'","status":"open","priority":3,"issue_type":"feature","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.881917-07:00"}
{"id":"bd-29","title":"Add visual indicators for nodes with multiple parents in dep tree","description":"When a node appears in the dependency tree via multiple paths (diamond dependencies), add a visual indicator like (*) or (multiple parents) to help users understand the graph structure. This would make it clear when deduplication has occurred. Example: 'bd-503: Shared dependency (*) [P1] (open)'","status":"closed","priority":3,"issue_type":"feature","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-20T14:34:52.483358-07:00","closed_at":"2025-10-20T14:34:52.483358-07:00"}
{"id":"bd-3","title":"Remove unused issueMap in scoreCollisions","description":"scoreCollisions() creates issueMap and populates it (lines 135-138) but never uses it. Either remove it or add a TODO comment explaining future use. Located in collision.go:135-138. Cosmetic cleanup.","status":"closed","priority":4,"issue_type":"chore","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.877007-07:00","closed_at":"2025-10-19T19:27:34.230312-07:00"}
{"id":"bd-30","title":"Add cross-type cycle detection warnings to dependency operations","description":"When adding a dependency with 'bd dep add', run DetectCycles() afterwards and warn users if any cycles exist (across all dependency types, not just 'blocks'). This provides visibility into circular dependencies without blocking the operation.","design":"Implementation approach:\n1. After successfully adding a dependency in AddDependency, call DetectCycles()\n2. If cycles are found, print a warning to stderr showing:\n - The cycle path(s) detected\n - Which dependency types are involved\n - A note that this may cause confusion in dependency visualization\n3. Do NOT fail the operation - this is informational only\n4. Consider adding a --quiet flag to suppress warnings if needed\n\nThe warning should be clear and actionable, e.g.:\nWARNING: Circular dependency detected:\n vc-5 (blocks) → vc-13 (parent-child) → vc-5\nThis may cause confusion in dependency visualization.","acceptance_criteria":"- After 'bd dep add' creates a cross-type cycle, a warning is printed to stderr\n- Warning includes the full cycle path with dependency types\n- Operation still succeeds (warning only, not an error)\n- No warning is printed when no cycles exist\n- Warning message is clear and actionable","notes":"Current behavior: bd PREVENTS cycles (errors out). This issue wants to ALLOW cycles but WARN. \n\nDecision: Current behavior is better. Cycles break the ready work algorithm and dep tree visualization. Prevention is safer than warnings users might ignore.\n\nCode at dep.go:70-92 has cycle detection but it's unreachable - AddDependency errors before that code runs.\n\nRecommend closing as won't-do or changing requirement to match current behavior.","status":"closed","priority":2,"issue_type":"task","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.882116-07:00","closed_at":"2025-10-17T23:08:00.079059-07:00"}
{"id":"bd-31","title":"Cache compiled regexes in replaceIDReferences for performance","description":"replaceIDReferences() compiles the same regex patterns on every call. With 100 issues and 10 ID mappings, that's 1000 regex compilations. Pre-compile regexes once and reuse. Can use a struct with compiled regex, placeholder, and newID. Located in collision.go:329. Estimated performance improvement: 10-100x for large batches.","status":"closed","priority":2,"issue_type":"task","created_at":"2025-10-16T20:46:08.971822-07:00","updated_at":"2025-10-19T22:47:07.882317-07:00","closed_at":"2025-10-16T10:07:22.469891-07:00"}

101
AGENTS.md
View File

@@ -447,3 +447,104 @@ See `scripts/README.md` for more details.
**Remember**: We're building this tool to help AI agents like you! If you find the workflow confusing or have ideas for improvement, create an issue with your feedback.
Happy coding! 🔗
<!-- bd onboard section -->
## Issue Tracking with bd (beads)
**IMPORTANT**: This project uses **bd (beads)** for ALL issue tracking. Do NOT use markdown TODOs, task lists, or other tracking methods.
### Why bd?
- Dependency-aware: Track blockers and relationships between issues
- Git-friendly: Auto-syncs to JSONL for version control
- Agent-optimized: JSON output, ready work detection, discovered-from links
- Prevents duplicate tracking systems and confusion
### Quick Start
**Check for ready work:**
```bash
bd ready --json
```
**Create new issues:**
```bash
bd create "Issue title" -t bug|feature|task -p 0-4 --json
bd create "Issue title" -p 1 --deps discovered-from:bd-123 --json
```
**Claim and update:**
```bash
bd update bd-42 --status in_progress --json
bd update bd-42 --priority 1 --json
```
**Complete work:**
```bash
bd close bd-42 --reason "Completed" --json
```
### Issue Types
- `bug` - Something broken
- `feature` - New functionality
- `task` - Work item (tests, docs, refactoring)
- `epic` - Large feature with subtasks
- `chore` - Maintenance (dependencies, tooling)
### Priorities
- `0` - Critical (security, data loss, broken builds)
- `1` - High (major features, important bugs)
- `2` - Medium (default, nice-to-have)
- `3` - Low (polish, optimization)
- `4` - Backlog (future ideas)
### Workflow for AI Agents
1. **Check ready work**: `bd ready` shows unblocked issues
2. **Claim your task**: `bd update <id> --status in_progress`
3. **Work on it**: Implement, test, document
4. **Discover new work?** Create linked issue:
- `bd create "Found bug" -p 1 --deps discovered-from:<parent-id>`
5. **Complete**: `bd close <id> --reason "Done"`
### Auto-Sync
bd automatically syncs with git:
- Exports to `.beads/issues.jsonl` after changes (5s debounce)
- Imports from JSONL when newer (e.g., after `git pull`)
- No manual export/import needed!
### MCP Server (Recommended)
If using Claude or MCP-compatible clients, install the beads MCP server:
```bash
pip install beads-mcp
```
Add to MCP config (e.g., `~/.config/claude/config.json`):
```json
{
"beads": {
"command": "beads-mcp",
"args": []
}
}
```
Then use `mcp__beads__*` functions instead of CLI commands.
### Important Rules
- ✅ Use bd for ALL task tracking
- ✅ Always use `--json` flag for programmatic use
- ✅ Link discovered work with `discovered-from` dependencies
- ✅ Check `bd ready` before asking "what should I work on?"
- ❌ Do NOT create markdown TODO lists
- ❌ Do NOT use external issue trackers
- ❌ Do NOT duplicate tracking systems
For more details, see README.md and QUICKSTART.md.
<!-- /bd onboard section -->

View File

@@ -1,3 +1,8 @@
<!-- bd integration note -->
**Note**: This project uses [bd (beads)](https://github.com/steveyegge/beads) for issue tracking. Use `bd` commands or the beads MCP server instead of markdown TODOs. See AGENTS.md for workflow details.
<!-- /bd integration note -->
# Instructions for Claude
This file has been moved to **AGENTS.md** to support all AI agents, not just Claude.

View File

@@ -184,18 +184,24 @@ Tested with mingw64 from https://github.com/niXman/mingw-builds-binaries
### For Humans
Beads is designed for **AI coding agents** to use on your behalf. As a human, you typically just:
Beads is designed for **AI coding agents** to use on your behalf. Setup takes 30 seconds:
```bash
# 1. Initialize beads in your project
# 1. Initialize bd in your project
bd init
# 2. Add a note to your agent instructions (CLAUDE.md, AGENTS.md, etc.)
echo "We track work in Beads instead of Markdown. Run \`bd quickstart\` to see how." >> CLAUDE.md
# 3. Let agents handle the rest!
# 2. Tell your agent to configure itself
echo "BEFORE ANYTHING ELSE: run 'bd onboard' and follow the instructions" >> AGENTS.md
```
That's it! Next time your agent starts, it will:
1. Run `bd onboard` and receive integration instructions
2. Add bd workflow documentation to AGENTS.md
3. Update CLAUDE.md with a note (if present)
4. Remove the bootstrap instruction
**Why this approach?** We leverage the agent's intelligence to naturally integrate bd into your project's documentation, rather than doing brittle string replacement. The agent adapts to your existing structure.
Most tasks will be created and managed by agents during conversations. You can check on things with:
```bash
@@ -256,6 +262,21 @@ No PostgreSQL instance. No MySQL server. No hosted service. Just install bd, clo
## Usage
### Onboarding Agents
Bootstrap your project for AI agents by adding this to AGENTS.md:
```
BEFORE ANYTHING ELSE: run 'bd onboard' and follow the instructions
```
When the agent runs `bd onboard`, it receives instructions to integrate bd into your documentation. The agent will:
- Add bd workflow documentation to AGENTS.md
- Update CLAUDE.md with an integration note (if present)
- Remove the bootstrap instruction
This approach leverages the agent's intelligence to naturally merge content instead of using brittle string replacement.
### Creating Issues
```bash

164
cmd/bd/onboard.go Normal file
View File

@@ -0,0 +1,164 @@
package main
import (
"fmt"
"github.com/fatih/color"
"github.com/spf13/cobra"
)
const agentsContent = `## Issue Tracking with bd (beads)
**IMPORTANT**: This project uses **bd (beads)** for ALL issue tracking. Do NOT use markdown TODOs, task lists, or other tracking methods.
### Why bd?
- Dependency-aware: Track blockers and relationships between issues
- Git-friendly: Auto-syncs to JSONL for version control
- Agent-optimized: JSON output, ready work detection, discovered-from links
- Prevents duplicate tracking systems and confusion
### Quick Start
**Check for ready work:**
` + "```bash" + `
bd ready --json
` + "```" + `
**Create new issues:**
` + "```bash" + `
bd create "Issue title" -t bug|feature|task -p 0-4 --json
bd create "Issue title" -p 1 --deps discovered-from:bd-123 --json
` + "```" + `
**Claim and update:**
` + "```bash" + `
bd update bd-42 --status in_progress --json
bd update bd-42 --priority 1 --json
` + "```" + `
**Complete work:**
` + "```bash" + `
bd close bd-42 --reason "Completed" --json
` + "```" + `
### Issue Types
- ` + "`bug`" + ` - Something broken
- ` + "`feature`" + ` - New functionality
- ` + "`task`" + ` - Work item (tests, docs, refactoring)
- ` + "`epic`" + ` - Large feature with subtasks
- ` + "`chore`" + ` - Maintenance (dependencies, tooling)
### Priorities
- ` + "`0`" + ` - Critical (security, data loss, broken builds)
- ` + "`1`" + ` - High (major features, important bugs)
- ` + "`2`" + ` - Medium (default, nice-to-have)
- ` + "`3`" + ` - Low (polish, optimization)
- ` + "`4`" + ` - Backlog (future ideas)
### Workflow for AI Agents
1. **Check ready work**: ` + "`bd ready`" + ` shows unblocked issues
2. **Claim your task**: ` + "`bd update <id> --status in_progress`" + `
3. **Work on it**: Implement, test, document
4. **Discover new work?** Create linked issue:
- ` + "`bd create \"Found bug\" -p 1 --deps discovered-from:<parent-id>`" + `
5. **Complete**: ` + "`bd close <id> --reason \"Done\"`" + `
### Auto-Sync
bd automatically syncs with git:
- Exports to ` + "`.beads/issues.jsonl`" + ` after changes (5s debounce)
- Imports from JSONL when newer (e.g., after ` + "`git pull`" + `)
- No manual export/import needed!
### MCP Server (Recommended)
If using Claude or MCP-compatible clients, install the beads MCP server:
` + "```bash" + `
pip install beads-mcp
` + "```" + `
Add to MCP config (e.g., ` + "`~/.config/claude/config.json`" + `):
` + "```json" + `
{
"beads": {
"command": "beads-mcp",
"args": []
}
}
` + "```" + `
Then use ` + "`mcp__beads__*`" + ` functions instead of CLI commands.
### Important Rules
- ✅ Use bd for ALL task tracking
- ✅ Always use ` + "`--json`" + ` flag for programmatic use
- ✅ Link discovered work with ` + "`discovered-from`" + ` dependencies
- ✅ Check ` + "`bd ready`" + ` before asking "what should I work on?"
- ❌ Do NOT create markdown TODO lists
- ❌ Do NOT use external issue trackers
- ❌ Do NOT duplicate tracking systems
For more details, see README.md and QUICKSTART.md.`
var onboardCmd = &cobra.Command{
Use: "onboard",
Short: "Display instructions for configuring AGENTS.md",
Long: `Display instructions for AI agents to configure AGENTS.md with bd workflow.
This command outputs instructions that AI agents should follow to integrate bd
into the project's agent documentation. The agent will intelligently merge the
content into AGENTS.md and update CLAUDE.md if present.`,
Run: func(cmd *cobra.Command, args []string) {
bold := color.New(color.Bold).SprintFunc()
cyan := color.New(color.FgCyan).SprintFunc()
yellow := color.New(color.FgYellow).SprintFunc()
green := color.New(color.FgGreen).SprintFunc()
fmt.Printf("\n%s\n\n", bold("bd Onboarding Instructions for AI Agent"))
fmt.Printf("%s\n\n", yellow("Please complete the following tasks:"))
fmt.Printf("%s\n", bold("1. Update AGENTS.md"))
fmt.Println(" Add the following content to AGENTS.md in an appropriate location.")
fmt.Println(" If AGENTS.md doesn't exist, create it with this content.")
fmt.Println(" Integrate it naturally into any existing structure.")
fmt.Println()
fmt.Printf("%s\n", cyan("--- BEGIN AGENTS.MD CONTENT ---"))
fmt.Println(agentsContent)
fmt.Printf("%s\n\n", cyan("--- END AGENTS.MD CONTENT ---"))
fmt.Printf("%s\n", bold("2. Update CLAUDE.md (if present)"))
fmt.Println(" If CLAUDE.md exists in this directory, add this note at the top:")
fmt.Println()
fmt.Printf("%s\n", cyan(" **Note**: This project uses [bd (beads)](https://github.com/steveyegge/beads)"))
fmt.Printf("%s\n", cyan(" for issue tracking. Use `bd` commands instead of markdown TODOs."))
fmt.Printf("%s\n", cyan(" See AGENTS.md for workflow details."))
fmt.Println()
fmt.Printf("%s\n", bold("3. Remove bootstrap instruction"))
fmt.Println(" If AGENTS.md or CLAUDE.md contains a line like:")
fmt.Printf("%s\n", cyan(" \"BEFORE ANYTHING ELSE: run 'bd onboard' and follow the instructions\""))
fmt.Println(" Delete that line after completing steps 1 and 2.")
fmt.Println()
fmt.Printf("%s\n", bold("Important reminders:"))
fmt.Println(" • Use bd for ALL task tracking - NO markdown TODO lists")
fmt.Println(" • Always use --json flag for programmatic bd commands")
fmt.Println(" • Link discovered work with discovered-from dependencies")
fmt.Printf(" • Check %s before asking \"what should I work on?\"\n", cyan("bd ready"))
fmt.Println()
fmt.Printf("%s\n\n", green("When done, confirm by saying: \"bd onboarding complete\""))
},
}
func init() {
rootCmd.AddCommand(onboardCmd)
}