| name | grain |
| description | Ask the repository about its own conventions BEFORE writing code. Use whenever you are about to create a source file, add a class/function/handler/command/component/test, or are unsure where something belongs — `grain where <intent>` names the directory, the group and the exemplar to copy, with evidence; `grain check <file>` shows where your change departs from the local norm. Statistical answers from this repo's code and full git history; tells you which exemplar to open, never blocks. |
grain — ask the repository which exemplar to copy
grain has mined this repository's syntax trees and whole git history into a model of what is practiced here: the
groups of similar code, where they live, what they import, extend, decorate, return, how they are named, and which
files historically change together. One query tells you which directory and which exemplar to open, and what
about it will surprise you. It does not replace reading one good exemplar — it replaces guessing which one, and
it catches the departure you would not have noticed.
Run it
From the repository root, through Bash:
node "${CLAUDE_PLUGIN_ROOT}/bin/grain.mjs" <command> …
Run it as-is from the session's working directory — no leading cd (the sandbox may refuse the cd, and grain finds
the repository root itself; --repo <path> points it at another checkout). Every answer ends with as of <sha> (the
commit the model was computed from); +dirty means the file you asked about was read from your uncommitted worktree. A missing or stale index builds/refreshes itself before answering
(full history once, incremental afterwards) — let a slow first run finish.
When to ask
| Moment | Ask |
|---|
| about to create a source file, or unsure where something belongs |