using-git-notes-for-ai-contextlisted
Install: claude install-skill msewell/agent-stuff
# Using Git Notes for AI Context
Git notes and trailers form a zero-infrastructure metadata layer for AI agent
context. Notes attach post-hoc metadata without changing commit SHAs. Trailers
embed structured key-value pairs inside commit messages.
## Notes vs. trailers
| Scenario | Use |
|----------|-----|
| Known at commit time, concise (<5 lines) | **Trailer** |
| Known at commit time, verbose | **Note** |
| Post-hoc (after commit) | **Note** |
| Attribution data | Note → `ai/attribution` |
| Prompts / sessions | Note → `ai/prompts` |
| Constraints, rejected alternatives, directives | Trailer (Lore protocol) |
| CI/CD output | Note → `ci/*` |
| Deployment records | Note → `deployments` |
**Rule of thumb:** If the metadata should travel with the commit and be visible
in `git log`, use trailers. If the metadata is post-hoc, verbose, or
machine-generated, use notes.
When authoring commits, keep subject/body format aligned with the repository's
commit convention; this skill focuses on metadata structure, storage, and
querying.
## Workflows
Identify the task, then follow the matching workflow.
### Annotating commits with AI context
1. Decide notes vs. trailers using the table above.
2. For **notes** — select the namespace per
[references/01-core-concepts-and-namespaces.md](references/01-core-concepts-and-namespaces.md)
§Namespace Scheme:
```bash
git notes --ref=ai/attribution add -m \
'{"schema":"ai-context/1.0","agent":{"tool":"claude-code","model":"cla