Goal
Create an AGENTS.md that makes the agent effective on day 1:
- •Clear repo/workspace map
- •"Golden commands" that match CI
- •Conventions + guardrails
- •Consistent task wrap-up expectations
Supported scenarios
A) Existing repo (single git root)
- •Detect build/test/lint/format/run commands from the repo.
- •Summarize CI-required checks from
.github/workflows/*. - •Write/overwrite
<repo>/AGENTS.mdusing the templates inreferences/.
B) Empty repo (or too little signal)
- •Ask the user a short questionnaire (below).
- •Create a minimal
AGENTS.mdwith explicit TODOs (no vague placeholders).
C) Polyrepo workspace (e.g. <root>/frontend and <root>/backend are separate git repos)
- •Treat the current directory as workspace root if it is not itself a git root.
- •Detect child repos by locating
.gitmarkers under immediate subfolders. - •Generate:
- •
<workspace>/AGENTS.md(cross-cutting rules + repo map) - •Optional:
<workspace>/frontend/AGENTS.mdand<workspace>/backend/AGENTS.md(repo-specific commands)
- •
Discovery algorithm (do this, in order)
- •Determine scope:
- •Try
git rev-parse --show-toplevel.- •If it succeeds, you are in scenario A.
- •If it fails, you are in scenario B or C. Use the current directory as workspace root.
- •Try
- •Detect language/tooling per folder:
- •.NET:
.sln,*.csproj,global.json - •Node:
package.json, lockfiles (package-lock.json,pnpm-lock.yaml,yarn.lock) - •Python/others: only if present; otherwise ignore.
- •.NET:
- •Extract "golden commands":
- •Prefer commands found in CI or repo scripts over inventing new ones.
- •For Node, read
package.jsonscripts. - •For .NET, prefer solution/project commands that run fast and match CI.
- •Extract CI quality gates:
- •Inspect
.github/workflows/*.ymlfor: build, test, lint, format, CodeQL, dependency review, SBOM/provenance attestations. - •Reflect them as a checklist in
AGENTS.md(only what exists today).
- •Inspect
- •Generate
AGENTS.md:- •Use a template from
references/and fill it with concrete commands and paths. - •Keep the file short (~150-200 lines). Prefer links to docs over copy-pasting.
- •Use a template from
- •Validate:
- •If any key command is unknown (especially "Run"/"Dev"), ask the user to provide it.
- •Never leave "(fill in ...)" placeholders; use explicit
TODO:bullets.
Questionnaire (only ask if needed)
Ask the minimum number of questions to remove ambiguity:
- •Is this a single repo or a workspace containing multiple repos?
- •What are the main parts? (e.g. backend .NET, frontend React)
- •For each part:
- •Package manager (
npm/pnpm/yarn) or.NETtooling - •Golden commands: install/restore, build, test, lint/format, dev/run
- •Package manager (
- •Anything special: DB migrations, codegen (OpenAPI), infra (Terraform), container runtime.
Hard rules to include in the generated AGENTS.md
- •Align with GitHub Actions: prefer commands that CI actually runs.
- •Security basics: never echo secrets; never commit secrets; avoid adding deps without approval.
- •Output expectations: summary + commands run + tests + manual verification steps.
Deliverables
- •Write the appropriate
AGENTS.mdfile(s). - •If polyrepo: ensure workspace
AGENTS.mdexplains how to run commands per repo folder. - •If you created repo-level
AGENTS.mdtoo, keep them narrower and point to workspace/global rules.
Finish with:
- •What files were created/updated (paths)
- •The key commands captured
- •Any remaining TODOs/questions for the user