| name | mai-agent |
| description | Use when working in any git repo with maitake. Check for notes before touching files, leave notes after meaningful work. This is the base agent contract — all other mai skills build on it. |
Mai Agent — Arrival and Departure
The contract: read before you work, leave notes after.
Setup
First time in a repo:
mai init
mai init --remote forgejo
This creates .maitake/hooks/ (PII scanning), .maitake/config.toml (sync config), and adds .maitake/ to .gitignore. Without --remote, everything stays local. With --remote, notes auto-push after every write. github.com is blocked by default either way.
On arrival
Before touching any file:
mai context <file-you-will-touch>
mai ls
mai ls -k constraint
mai ls -k warning
mai search "topic you're working on"
mai ready
mai blocked
mai context is the most important command. It shows everything targeting a file — including file-located comments from other agents on tickets that span multiple files.
During work
Working on an existing ticket
mai show <ticket-id>
mai start <ticket-id>
mai add-note <ticket-id> "what you're doing"
mai add-note <ticket-id> --file src/auth.ts "details"
mai add-note <ticket-id> --file src/auth.ts --line 42 "line-level detail"
Long notes — use the pipe pattern. Write to /tmp first, then pipe in.
Never burn tokens rewriting a note that failed.
cat > /tmp/mai-draft.md << 'EOF'
...long note content...
EOF
mai add-note <ticket-id> < /tmp/mai-draft.md
Creating new work
mai ticket "Fix auth race condition" -p 1 -l auth --target src/auth.ts \
-d "Token refresh has a race condition."
Attaching things directly to files
Warnings, decisions, and artifacts can target files without a pre-existing ticket:
mai warn src/auth.ts "Token cache not thread-safe"
mai adr "Use mutex for token refresh" --target src/auth.ts \
-d "Chose mutex over single-flight. SF propagates errors to all waiters."
mai artifact "Perf analysis" --target src/physics/rebuild.rs -d "..."
mai context <file> shows all of these. This is how you stick the why onto the what.
Tagging and assigning
mai tag <id> +critical
mai tag <id> -wontfix
mai assign <id> "Alice"
Dependencies
mai dep <parent-id> <dep-id>
mai dep tree <id>
mai undep <id> <dep-id>
mai ready
mai blocked
Linking
mai link <id-a> <id-b>
mai unlink <id-a> <id-b>
On departure
mai close <ticket-id> -m "What was done and the result"
If you found something fragile:
mai warn src/auth.ts "Token cache not thread-safe — hold mutex during refresh"
If you made a decision worth recording:
mai create "Use single-flight for token refresh" -k decision --target src/auth.ts \
-d "Chose single-flight over mutex — coalesces concurrent callers."
Artifact tickets
For non-work outputs (research, reviews, ADRs):
mai review "Auth hardening review" --target src/auth.ts \
-d "Review findings for the auth changes."
Artifacts are born closed — they don't pollute mai ls. Query them explicitly:
mai ls --status=all
mai closed
mai ls --status=all -k review
Sync
If a remote is configured, notes auto-push after every write (debounced,
conflict-safe). Without a remote, nothing syncs — everything stays local.
Manual sync:
mai sync
Querying
mai show <id>
mai ls
mai ls -k <kind>
mai ls -l <tag>
mai ls --status=all
mai search "query"
mai search "auth" -k ticket
mai search "fix" --limit 5
mai closed
mai context <path>
mai ready
mai blocked
mai dep tree <id>
mai kinds
mai doctor
Rules
- Always check context before editing a file. Warnings, constraints, and review findings are there for a reason.
- Always leave a note after meaningful work. The next agent needs context.
- Close things you resolve. Keep the queue clean.
- Use
--file on comments when they're about a specific file, not the ticket in general.
- Use
--line on comments when you can point to a specific location.