|
| 1 | +--- |
| 2 | +sidebar_position: 10 |
| 3 | +--- |
| 4 | + |
| 5 | +# AI Agent Integration |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +td is designed for AI agents. Any agent that can run shell commands can use td for structured task management -- tracking issues, logging progress, handing off between contexts, and enforcing review before close. |
| 10 | + |
| 11 | +Works with: Claude Code, Cursor, OpenAI Codex, GitHub Copilot, Gemini CLI, or any agent with shell access. |
| 12 | + |
| 13 | +## Setup for Claude Code |
| 14 | + |
| 15 | +Add to your project's `CLAUDE.md`: |
| 16 | + |
| 17 | +```markdown |
| 18 | +## MANDATORY: Use `td` for Task Management |
| 19 | + |
| 20 | +Run `td usage --new-session` at conversation start (or after /clear). |
| 21 | + |
| 22 | +Sessions are automatic. Optional: |
| 23 | +- `td session "name"` to label the current session |
| 24 | +- `td session --new` to force a new session |
| 25 | + |
| 26 | +Use `td usage -q` after first read. |
| 27 | +``` |
| 28 | + |
| 29 | +Claude Code reads `CLAUDE.md` at the start of every conversation, so this ensures td is always used. |
| 30 | + |
| 31 | +## Setup for Other Agents |
| 32 | + |
| 33 | +Add to your system prompt or project config: |
| 34 | + |
| 35 | +``` |
| 36 | +Run `td usage --new-session` at conversation start. |
| 37 | +Use td commands to track work: td start, td log, td handoff, td review. |
| 38 | +``` |
| 39 | + |
| 40 | +The key requirement is that the agent runs `td usage --new-session` before doing any work. This gives it full context on what to do next. |
| 41 | + |
| 42 | +## The `td usage` Command |
| 43 | + |
| 44 | +`td usage` gives the agent everything it needs in one call: |
| 45 | + |
| 46 | +- Current session info |
| 47 | +- Focused issue with handoff state (what was done, what remains) |
| 48 | +- Issues awaiting review |
| 49 | +- Open issues by priority |
| 50 | +- Workflow instructions |
| 51 | + |
| 52 | +Flags: |
| 53 | +- `--new-session` -- start a fresh session (use at conversation start) |
| 54 | +- `-q` -- quiet mode, shorter output (use after first read) |
| 55 | + |
| 56 | +## Recommended Agent Workflow |
| 57 | + |
| 58 | +```bash |
| 59 | +td usage --new-session # 1. Get context at start |
| 60 | +td start <id> # 2. Begin work on an issue |
| 61 | +td log "progress msg" # 3. Track progress as you go |
| 62 | +td handoff <id> --done "..." --remaining "..." # 4. Before stopping |
| 63 | +td review <id> # 5. Submit for review |
| 64 | +``` |
| 65 | + |
| 66 | +Steps 3-4 are critical for multi-context work. Logs and handoffs persist across context windows, so the next agent picks up exactly where you left off. |
| 67 | + |
| 68 | +## Session Isolation for Agents |
| 69 | + |
| 70 | +Each agent instance (terminal, context window) gets a unique session ID. This ensures: |
| 71 | + |
| 72 | +- Agent A's work is reviewed by Agent B (no self-approval) |
| 73 | +- Handoffs between contexts are explicit and trackable |
| 74 | +- Review history shows which session made which changes |
| 75 | + |
| 76 | +Sessions are created automatically based on the agent's terminal context. You can also force a new session with `td session --new` or label the current one with `td session "name"`. |
| 77 | + |
| 78 | +## Multi-Agent Workflows |
| 79 | + |
| 80 | +td enforces that the implementer cannot be the reviewer. This naturally supports multi-agent workflows: |
| 81 | + |
| 82 | +```bash |
| 83 | +# Agent 1 implements |
| 84 | +td start td-a1b2 |
| 85 | +td log "implemented feature X" |
| 86 | +td handoff td-a1b2 --done "Built X with tests" --remaining "Needs review" |
| 87 | +td review td-a1b2 |
| 88 | + |
| 89 | +# Agent 2 reviews (different session) |
| 90 | +td reviewable |
| 91 | +td approve td-a1b2 # or: td reject td-a1b2 --reason "needs fix" |
| 92 | +``` |
| 93 | + |
| 94 | +Because each agent context gets a different session ID, the system prevents the same agent from both implementing and approving a change. |
| 95 | + |
| 96 | +## Tips |
| 97 | + |
| 98 | +- **Always start with `td usage --new-session`** -- this is the single most important instruction for any agent. |
| 99 | +- **Log frequently** -- short, hyper-concise messages. These survive context resets. |
| 100 | +- **Handoff before stopping** -- if work is incomplete, `td handoff` captures state for the next agent. |
| 101 | +- **Don't start new sessions mid-work** -- sessions track implementers. A new session mid-task bypasses review enforcement. |
| 102 | +- **Use quiet mode after first read** -- `td usage -q` avoids repeating workflow instructions every time. |
0 commit comments