Updates project documentation to reflect the complete CP2 feature set with merge request ingestion and robot mode capabilities. README.md: - Add MR-related CLI examples (gi list mrs, gi show mr, gi ingest) - Document robot mode (--robot flag, GI_ROBOT env, auto-detect) - Update feature list with MR support and DiffNote positions - Add configuration section with all config file options - Expand CLI reference with new commands and flags AGENTS.md: - Add MR ingestion patterns for AI agent consumption - Document robot mode JSON schemas for parsing - Include error handling patterns with exit codes - Add discussion/note querying examples for code review context Cargo.toml: - Bump version to 0.2.0 reflecting major feature addition The documentation emphasizes the robot mode design which enables AI agents like Claude Code to reliably parse gi output for automated GitLab workflow integration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
7.5 KiB
AGENTS.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
TDD Requirements
Test-first development is mandatory:
- RED - Write failing test first
- GREEN - Minimal implementation to pass
- REFACTOR - Clean up while green
Key Patterns
Find the simplest solution that meets all acceptance criteria. Use third party libraries whenever there's a well-maintained, active, and widely adopted solution (for example, date-fns for TS date math) Build extensible pieces of logic that can easily be integrated with other pieces. DRY principles should be loosely held. Architecture MUST be clear and well thought-out. Ask the user for clarification whenever ambiguity is discovered around architecture, or you think a better approach than planned exists.
Beads Rust Workflow Integration
This project uses beads_viewer for issue tracking. Issues are stored in .beads/ and tracked in git.
Essential Commands
# View issues (launches TUI - NOT FOR AGENT USE, human only)
bv
# CLI commands for agents (use --json for machine-readable output)
br ready --json # Show issues ready to work (no blockers)
br list --status=open --json # All open issues
br show <id> --json # Full issue details with dependencies
br create --title="..." --type=task --priority=2
br update <id> --status=in_progress
br close <id> --reason="Completed"
br close <id1> <id2> # Close multiple issues at once
br sync # Commit and push changes
Robot Mode (Agent-Optimized bv Commands)
Use bv --robot-* flags for structured JSON output optimized for AI agents:
# Essential robot commands
bv --robot-triage # THE MEGA-COMMAND: unified analysis, recommendations, health
bv --robot-next # Single top recommendation (minimal output)
bv --robot-plan # Dependency-respecting execution plan
bv --robot-priority # Priority recommendations with reasoning
bv --robot-insights # Deep graph analysis (PageRank, bottlenecks, etc.)
# File impact analysis (check before editing)
bv --robot-impact <file> # Risk assessment for modifying files
bv --robot-file-beads <path> # What beads have touched this file?
bv --robot-file-hotspots # High-churn files (conflict zones)
bv --robot-related <bead-id> # Find related beads
# Filtering options (work with most robot commands)
bv --robot-triage --robot-by-label=backend
bv --robot-priority --robot-min-confidence=0.7
bv --robot-insights --label=api # Scope to label subgraph
Run bv -robot-help for complete robot mode documentation.
Workflow Pattern
- Start: Run
br readyto find actionable work - Claim: Use
br update <id> --status=in_progress - Work: Implement the task
- Complete: Use
br close <id> - Sync: Always run
br syncat session end
Key Concepts
- Dependencies: Issues can block other issues.
br readyshows only unblocked work. - Priority: P0=critical, P1=high, P2=medium, P3=low, P4=backlog (use numbers, not words)
- Types: task, bug, feature, epic, question, docs
- Blocking:
br dep add <issue> <depends-on>to add dependencies
Session Protocol
Before ending any session, run this checklist:
git status # Check what changed
git add <files> # Stage code changes
br sync # Commit beads changes
git commit -m "..." # Commit code
br sync # Commit any new beads changes
git push # Push to remote
Best Practices
- Check
br readyat session start to find available work - Update status as you work (in_progress → closed)
- Create new issues with
br createwhen you discover tasks - Use descriptive titles and set appropriate priority/type
- Always
br syncbefore ending session
Beads Workflow Integration
This project uses beads_viewer for issue tracking. Issues are stored in .beads/ and tracked in git.
Essential Commands
# View issues (launches TUI - avoid in automated sessions)
bv
# CLI commands for agents (use these instead)
bd ready # Show issues ready to work (no blockers)
bd list --status=open # All open issues
bd show <id> # Full issue details with dependencies
bd create --title="..." --type=task --priority=2
bd update <id> --status=in_progress
bd close <id> --reason="Completed"
bd close <id1> <id2> # Close multiple issues at once
bd sync # Commit and push changes
Workflow Pattern
- Start: Run
bd readyto find actionable work - Claim: Use
bd update <id> --status=in_progress - Work: Implement the task
- Complete: Use
bd close <id> - Sync: Always run
bd syncat session end
Key Concepts
- Dependencies: Issues can block other issues.
bd readyshows only unblocked work. - Priority: P0=critical, P1=high, P2=medium, P3=low, P4=backlog (use numbers, not words)
- Types: task, bug, feature, epic, question, docs
- Blocking:
bd dep add <issue> <depends-on>to add dependencies
Session Protocol
Before ending any session, run this checklist:
git status # Check what changed
git add <files> # Stage code changes
bd sync # Commit beads changes
git commit -m "..." # Commit code
bd sync # Commit any new beads changes
git push # Push to remote
Best Practices
- Check
bd readyat session start to find available work - Update status as you work (in_progress → closed)
- Create new issues with
bd createwhen you discover tasks - Use descriptive titles and set appropriate priority/type
- Always
bd syncbefore ending session
GitLab Inbox Robot Mode
The gi CLI has a robot mode optimized for AI agent consumption with structured JSON output, meaningful exit codes, and TTY auto-detection.
Activation
# Explicit flag
gi --robot list issues
# Auto-detection (when stdout is not a TTY)
gi list issues | jq .
# Environment variable
GI_ROBOT=1 gi list issues
Robot Mode Commands
# List issues/MRs with JSON output
gi --robot list issues --limit=10
gi --robot list mrs --state=opened
# Count entities
gi --robot count issues
gi --robot count discussions --type=mr
# Show detailed entity info
gi --robot show issue 123
gi --robot show mr 456 --project=group/repo
# Check sync status
gi --robot sync-status
# Run ingestion (quiet, JSON summary)
gi --robot ingest --type=issues
# Check environment health
gi --robot doctor
Response Format
All commands return consistent JSON:
{"ok":true,"data":{...},"meta":{...}}
Errors return structured JSON to stderr:
{"error":{"code":"CONFIG_NOT_FOUND","message":"...","suggestion":"Run 'gi init'"}}
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Internal error |
| 2 | Config not found |
| 3 | Config invalid |
| 4 | Token not set |
| 5 | GitLab auth failed |
| 6 | Resource not found |
| 7 | Rate limited |
| 8 | Network error |
| 9 | Database locked |
| 10 | Database error |
| 11 | Migration failed |
| 12 | I/O error |
| 13 | Transform error |
Best Practices
- Use
gi --robotfor all agent interactions - Check exit codes for error handling
- Parse JSON errors from stderr
- Use
--limitto control response size - TTY detection handles piped commands automatically