Agents Md
Remember
Use judgment, adapt to context, and stay within explicit safety and scope constraints.
Compliance
- Check against GOLD Industry Standards guide in ~/.codex/instructions/standards.md
- Use ~/.codex/AGENTS.md as the global index that links to current standards docs.
- If this skill is used from
~/.codex/, write reference links only under ~/.codex/instructions/ (and not to docs/ for global protocols).
- Visual reference: agents-md workflow map
Philosophy
Prefer concise, verifiable instructions over comprehensive prose. Every command and path must be real and sourced from the repo. Treat AGENTS.md as an operator checklist: short, direct, and actionable. Use progressive disclosure: keep root minimal, link out for details.
Guiding principles:
- Optimize for reader success in under 2 minutes.
- Favor deterministic steps over narrative.
- Keep scope tight; expand only when the repo requires it.
- Default to canonical implementations for unreleased/greenfield projects; do not add backwards-compatibility layers unless explicitly required.
Mandatory snippet (include verbatim in guidance):
- Explore project first, then invoke skill.
- IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any React, Tauri, Apps-SDK-ui, Tailwind, Vite, Storybook + Chat Widget tasks.
- Add a Table of Contents for docs.
Core Engineering Principles
- Clarity over cleverness — Prefer straightforward, maintainable instructions over elegant or complex phrasing.
- Explicit over implicit — State assumptions, decisions, and side effects directly.
- Composition over inheritance — Prefer small, reusable instruction units over monolithic guidance blocks.
- Fail fast, fail loud — Surface validation failures at the point they occur and stop safely.
- Delete before adding — Remove redundant, outdated, or duplicate instructions before writing new ones.
- Verify, don’t assume — Confirm commands and paths from source files before presenting them.
- Stop before you are asked — Do not expand scope beyond the request without explicit consent.
Token Efficiency
- Prefer short, one-shot edits; avoid unnecessary tool calls or repeated edits for the same intent.
- Do not re-read files that were just written when the result is known and unchanged.
- Do not rerun validation commands unless behavior or assumptions changed.
- Summarize decisions, not large chunks of raw file contents.
- Batch related changes into one cohesive update.
- Avoid confirmation loops like “I will continue...” unless branching is required.
- Ask once for missing scope questions, then act.
Scope and triggers
- The user asks to create or update AGENTS.md.
- The user asks to refactor AGENTS.md for progressive disclosure or split instructions into multiple files.
- The repo needs a short contributor guide for agents or humans.
- The user requests “Repository Guidelines” content under 400 words.
- The repo already has
AGENTS.md, CLAUDE.md, and GEMINI.md, and the user asks to keep shared instruction guidance synchronized across them.
Response format (required)
- Always include all three sections in every response:
## When to use explaining the trigger or noting "in scope".
## Outputs describing delivered artifacts.
## Inputs listing missing info or noting "none".
- Use the exact heading text and casing shown above.
- For out-of-scope requests, start with
## When to use and still include ## Outputs and ## Inputs below.
- Do not omit
## When to use under any circumstance.
- For out-of-scope requests, do not write any text before
## When to use.
Cognitive Support / Plain-Language
- Optimize for low cognitive load (TBI support): one task at a time, explicit steps.
- Use plain language first; define jargon in parentheses.
- Keep steps short and checklist-driven where possible.
- Externalize state: decisions, assumptions, and the next step.
- Provide ELI5 explanations for non-trivial logic.
- Ask one question at a time; prefer multiple-choice when possible.
Response template (minimum)
## When to use
- in scope
## Outputs
- ...
## Inputs
- ...
Failure-mode template (out of scope)
## When to use
- This skill applies when the user asks to create or refactor AGENTS.md using progressive disclosure.
## Outputs
- None (out of scope).
## Inputs
- None (out of scope).
Use the failure-mode template verbatim for out-of-scope requests.
Required inputs
- Target repo root path.
- Existing AGENTS.md content (if present).
- Verified commands and paths from the repo (README, docs, config files).
- Package-manager signals from repo facts (
package.json#packageManager, lockfiles, and existing command style in README/CI/docs).
- Any adjacent instruction files that may conflict (global or per-directory).
- Whether Jamie's agent-first scaffold standard is requested (
~/.codex/instructions/agent-first-scaffold-spec.md).
- Compatibility posture (default: canonical-only for unreleased/greenfield repos; replace only when explicitly requested).
Local Memory usage
- Follow
instructions/local-memory.md for memory read/write workflow, tagging, and safety rules.
- Rule: search memory before writing new memory; store durable facts only.
- Never store secrets in memory.
local-memory-mcp policy
- Use
local-memory-mcp for durable context and cross-run continuity.
- Mandatory workflow:
bootstrap(mode="minimal", include_questions=true, session_id="repo:<name>:task:<id>")
search(query="...", session_id="repo:<name>:task:<id>")
- Record durable facts only with
observe(...) (level observation|learning) and stable tags.
- Do not store secrets, tokens, keys, or PII.
Deliverables
- A minimal root
AGENTS.md that links to separate instruction files.
- One file per instruction category under the repo's canonical instruction root (e.g.,
docs/agents/... or instructions/agents/...).
- A suggested
docs/ folder structure.
- A table of contents for docs that are created or updated.
- A contradictions list with a question for each conflict.
- A “flag for deletion” list (redundant, vague, overly obvious).
- A detected package-manager command map (
install, run, optional exec) derived from repo evidence and reused across generated docs.
- When requested: idempotent scaffold blocks for
AGENTS.md, .agent/PLANS.md, and README.md.
- Output contract schema_version: 1
Constraints
- Redact secrets/PII by default.
- Do not invent commands, scripts, or paths.
- Redact secrets and sensitive data by default.
- Use ASCII only unless the repo already uses non-ASCII.
- Do not add dependencies or tools.
- Do not add legacy shims, adapter layers, dual-write paths, or backwards-compatibility promises unless the user explicitly requires compatibility.
- Do not hardcode npm/pnpm/yarn/bun command examples without repo evidence.
Workflow
- Discover repo facts
- Read README and
docs/ for real commands and structure.
- Inspect config files (for example
pyproject.toml, package scripts).
- Determine canonical instruction root before generating files:
- If target path is
~/.codex or a Codex config repo clone (for example /Users/<user>/dev/config/codex), prefer instructions/ and do not create docs/ for agent guidance.
- Else, follow existing repo convention (
docs/agents vs instructions/agents) and avoid introducing a second instruction tree.
- Detect package manager in this precedence:
package.json#packageManager -> lockfiles (pnpm-lock.yaml, yarn.lock, bun.lockb/bun.lock, package-lock.json, npm-shrinkwrap.json) -> existing command style in README/CI/docs.
- If package-manager signals conflict or are missing, state "not observed" and ask which command style should be used before emitting manager-specific commands.
- Build one package-manager command map from detected evidence and apply it consistently in generated AGENTS/CLAUDE/GEMINI updates.
- If commit conventions are not visible, state “not observed.”
- Read global instructions from
~/.codex/AGENTS.md.
- Also check
~/.codex/instructions/ for applicable global standards and guidance.
- Then read project instructions from repo root down to the working directory and treat them as canonical.
- Note: Codex
AGENTS.md does not support @ imports; Claude CLAUDE.md and ~/.claude/rules/*.md do.
- Canonical hierarchy rule: when both
AGENTS.md and CLAUDE.md/GEMINI.md exist, treat AGENTS.md as canonical source of truth for repository-wide, cross-tool instructions. Keep CLAUDE/GEMINI focused on agent/CLI-specific usage and memory conventions.
- If a repo already has
AGENTS.md, CLAUDE.md, and GEMINI.md, update shared sections in CLAUDE.md and GEMINI.md to reference the canonical AGENTS.md guidance rather than duplicate it.
- If existing
AGENTS.md, .agent/PLANS.md, README.md, or required docs/ directories already exist, merge instead of overwrite.
- Apply idempotent updates: preserve existing content, insert only missing sections/links, and dedupe existing lines.
- Create directories/files only if absent; do not recreate duplicates.
- Find contradictions
- Identify conflicting instructions and ask which one should win.
- Do not resolve conflicts without user confirmation.
2.1) Set compatibility posture
- Default to canonical-only guidance for unreleased/greenfield projects.
- Only include backwards-compatibility instructions when explicitly requested or when the repo shows clear released-version compatibility commitments.
- Identify the essentials (root AGENTS.md)
- One-sentence project description.
- Repo-native package manager command style (install/run/exec, as observed).
- Non-standard build/typecheck commands.
- Anything truly relevant to every single task.
- Add inserts (global references)
- If a canonical global protocol exists (for example
~/.codex/instructions/rvcp-common.md), add a short "References" or "Imports" section at the top of the root AGENTS.md that points to it.
- Never duplicate the full protocol content in repo files; link only.
- If
CODEX_HOME is set, prefer $CODEX_HOME/... for global references; otherwise use ~/.codex/....
- Only insert references that exist on disk; if not found, state "not observed" and do not invent paths.
- In
~/.codex/ context, do not write global protocol references to docs/ paths. Always use ~/.codex/instructions/... for protocol links.
- If the repo uses a different global protocol, add the same style of reference block.
- When scaffold mode is requested, include references to the scaffold spec and governance docs listed above.
- Group the rest
- Organize remaining instructions into logical categories (TypeScript, testing, deployment, accessibility, etc.).
- Keep each category file focused and scoped.
- Create the file structure
- Output a minimal root
AGENTS.md with Markdown links to category files under the canonical instruction root selected in step 1.
- Output each category file with its relevant instructions.
- Provide a suggested folder structure rooted at the selected instruction root.
- Flag for deletion
- Identify redundant, vague, or overly obvious instructions.
- Validate content
- Confirm commands exist and are runnable.
- Confirm naming conventions match the codebase.
- Ensure no secrets or private endpoints appear.
- For scaffold mode: verify marker blocks are present and not duplicated.
- For scaffold mode: run
python3 ~/.codex/scripts/plan-graph-lint.py <repo>/.agent/PLANS.md.
- For scaffold mode: run link-integrity checks with
rg -n for required global references.
Required sections (root AGENTS.md)
- One-sentence project description
- Tooling essentials (repo-native package-manager commands, including install/run equivalents)
- Non-standard build/typecheck commands
- Code quality standards (inject when requested or supported by repo evidence)
- Planning guidance (inject plan-review rules for complex implementation work)
- Shell script conventions (inject when shell scripts/wrappers are present)
- References or imports (global protocol pointers; no duplication)
- Global instructions discovery order (brief, link to full doc)
- Links to category files
- For Codex home/config repos: prefer
instructions/agents/... links over docs/agents/....
Flaky Test Artifact Capture (injectable block, conditional)
Use this block when the repo has automated tests (Node, Python, Rust, Playwright, Vitest, Jest, or pytest evidence).
Decision rule:
- If the user asks for flaky-test detection/artifacts/history, always inject this block.
- Else, inject when repo facts show test commands/config (
test scripts, pytest, vitest, playwright, jest, Cargo test, or tests/ directory).
- If no test evidence exists, do not inject.
When injected, include these concrete requirements:
- Required script path:
scripts/test-with-artifacts.sh
- Required modes:
all, unit, integration, e2e
- Required output root:
artifacts/test
- Required stable outputs:
artifacts/test/summary-*.json
artifacts/test/test-output-*.log
artifacts/test/junit-*.xml (when runner supports it)
artifacts/test/*-results.json (when runner supports it)
artifacts/test/artifact-manifest.json
- If
package.json exists, wire scripts:
test:artifacts, test:artifacts:unit, test:artifacts:integration, test:artifacts:e2e
- Use the detected package-manager command map for script invocations; do not mix manager variants in one generated block.
Insert this exact section in generated AGENTS.md for test repos:
## Flaky Test Artifact Capture
- Run `bash scripts/test-with-artifacts.sh all` (or the detected repo-native command for `test:artifacts`) to emit machine-readable flaky evidence under `artifacts/test`.
- Optional targeted modes:
- `bash scripts/test-with-artifacts.sh unit`
- `bash scripts/test-with-artifacts.sh integration`
- `bash scripts/test-with-artifacts.sh e2e`
- Commit/retain stable artifact paths for local automation ingestion:
- `artifacts/test/summary-*.json`
- `artifacts/test/test-output-*.log`
- `artifacts/test/junit-*.xml` (when supported by test runner)
- `artifacts/test/*-results.json` (when supported by test runner)
- `artifacts/test/artifact-manifest.json`
- Keep artifact filenames stable (no timestamps in filenames) so recurring flake scans can compare runs.
Code Quality Standards (injectable block, conditional)
Decision rule:
- Inject when the user explicitly asks for code-quality or testing standards.
- Else, inject when repo evidence shows automated tests, linting, or typechecking workflows.
- If no evidence exists, do not inject.
Insert this section when injected:
## Code Quality Standards
- Run full test suite before committing: `npm test` or the detected repo-native equivalent.
- Fix TypeScript errors and lint issues before marking tasks complete.
- Ensure test isolation - tests should not depend on execution order.
Plan Review Guidelines (injectable block, conditional)
Decision rule:
- Inject when the user asks for planning guardrails.
- Else, inject when the task includes complex features, refactors, or architecture changes.
- Skip for trivial edits unless explicitly requested.
Insert this section when injected:
## Planning
### Plan Review Guidelines
- Before implementing complex features, create a minimal v1 scope.
- Avoid over-engineering - prefer simple solutions over comprehensive ones.
- Scale back ambition if initial plan feels too large.
Shell Script Conventions (injectable block, conditional)
Decision rule:
- Inject when the user asks for shell/script quality guidance.
- Else, inject when repo evidence includes shell scripts, wrapper scripts, or script-based automation.
- If no shell-script evidence exists, do not inject.
Insert this section when injected:
## Shell Script Conventions
- Always validate wrapper scripts with shellcheck before considering complete.
- Test script syntax with `bash -n script.sh` to catch errors early.
- Handle edge cases for function conflicts and environment variable loading.
Frontend Website Rules (injectable block, conditional)
Use this only when there is evidence the repo/task is frontend website work.
Decision rule (to let the skill "figure it out"):
- If the user explicitly requests UI/frontend implementation, visual parity, screenshot, component polish, or reference-based frontend behavior, treat as frontend.
- Else, infer from repo facts:
package.json includes React/Next/Vite/Tauri/Vue/Svelte frameworks or UI tooling.
index.html, vite.config.*, next.config.*, or src/main.* exists near src/.
- A
brand/ folder is relevant and used for style assets.
- If no evidence, do not inject this block; output a short note in
## Outputs asking for clarification.
If frontend evidence is present, inject the block into the generated AGENTS.md (or category docs) so behavior is concrete and repeatable:
AGENTS.md — Frontend Website Rules
- Always Do First: invoke
$ui-ux-creative-coding and $interface-craft before writing any frontend code.
- If a reference image is provided:
- Match layout, spacing, typography, and color exactly.
- Use placeholders (
https://placehold.co/) only when content is missing.
- Do not improve or add to the design beyond the reference.
- If no reference image: design from scratch with the guardrails in this section.
- Local server required: Always serve from
http://localhost:2000 using the project’s node serve.mjs.
- Never use
file:///.
- Start
node serve.mjs in background before screenshots.
- If already running, reuse that instance.
- Replace Puppeteer-specific assumptions with agent-browser:
- Use
agent-browser for navigation and screenshot capture.
- Keep workflow tool-first:
agent-browser open http://localhost:2000 then capture screenshots.
- Pair with
$agentation (or agentation MCP invocation) for execution orchestration:
- session setup, screenshot loop control, and comparison pass tracking.
- Screenshot naming convention:
- If the screenshot is a full page:
screenshot-page-<name>-<pass>.png
- If the screenshot is a component:
screenshot-component-<type>-<state>-<pass>.png
- examples:
screenshot-component-card-default-1.png, screenshot-component-button-hover-2.png
- Never overwrite; increment pass number when rerunning comparisons.
- Compare against the reference after each pass and continue at least 2 rounds until no visible mismatch.
- Output should use inline styles in a single
index.html and Tailwind via https://cdn.tailwindcss.com.
- Tailwind classes:
- Do not use default indigo/blue primaries.
- Do not use
transition-all.
- For clickables, define hover, focus-visible, and active states.
- If
brand/ assets exist, prefer them over placeholders.
- Use existing brand variables; do not invent colors, spacing tokens, or typography scales.
Runtime checks for screenshot workflows
- Run at least 2 screenshot rounds for visual parity.
- Use consistent comparison criteria: spacing/padding, typography scale, color values, alignment, border radii, shadows, sizing.
- For component screenshots, include the component type in filename (
card, button, modal, form, etc.) to keep review context explicit.
Agent-first scaffold integration (Jamie standard)
Apply this when the user asks for agent-first rollout/scaffold across repos (especially under ~/dev).
Required global references (verify they exist before insertion):
~/.codex/instructions/openai-agent-workflow-playbook.md
~/.codex/instructions/README.checklist.md
~/.codex/instructions/validator-contracts.md
~/.codex/instructions/strict-toggle-governance.md
~/.codex/instructions/agent-first-scaffold-spec.md
Use idempotent marker blocks:
AGENTS.md: <!-- AGENT-FIRST-SCAFFOLD:START --> ... <!-- AGENT-FIRST-SCAFFOLD:END -->
.agent/PLANS.md: <!-- AGENT-FIRST-PLANS:START --> ... <!-- AGENT-FIRST-PLANS:END -->
README.md: <!-- AGENT-FIRST-WORKFLOW:START --> ... <!-- AGENT-FIRST-WORKFLOW:END -->
.agent/PLANS.md contract requirements:
tasks[], each task has id, title, depends_on
id format ^T[1-9][0-9]*$
- IDs unique within plan
depends_on references in-plan IDs only
- no self-dependency; DAG required; single connected component
- validation command:
python3 ~/.codex/scripts/plan-graph-lint.py <plan-file>
Canonical verification command:
bash ~/.codex/scripts/verify-work.sh
Rollout policy:
- Link to 3-gate warn->block model in
~/.codex/instructions/agent-first-scaffold-spec.md.
Variation
- Vary examples and commands to match the target repo’s stack (Python vs Node).
- Use repo-specific paths and filenames; avoid repeating generic defaults across repos.
Empowerment
- Offer two to three clear next-step options after drafting (accept, revise, or add missing info).
- Call out unknowns explicitly and ask for confirmation before finalizing.
- Encourage the user to prioritize sections when the scope is broad.
- Empower the user to choose between a minimal or detailed guideline set.
- Empower the user with explicit choice and control over scope, depth, and inserts before expanding.
- Explicitly empower the user to defer optional inserts until core guidance is approved.
- Ask whether to proceed with inserts when the global protocol is detected but optional.
- Provide a one-sentence rationale for each recommended insert or deletion.
Validation
- Fail fast: stop at the first failed validation gate, fix it, then re-run.
- Run
~/.venvs/pyyaml/bin/python scripts/quick_validate.py <skill> if available.
- Run
~/.venvs/pyyaml/bin/python scripts/skill_gate.py <skill> and fix any missing sections.
- If needed, consult
references/contract.yaml and references/evals.yaml.
- If validation scripts or paths are missing, state "not run (tooling not available)" and continue.
Anti-patterns
- Generic boilerplate that ignores repo specifics.
- Fabricated commands or paths.
- Omitting contradictions or failing to ask which instruction wins.
- Burying risks or assumptions in long prose.
- Using vague headings like “Misc” or “Notes.”
- Presenting unverified commands as facts.
- Mixing unrelated policies into the same section.
- Adding global protocol content directly into repo
AGENTS.md instead of linking.
- Stating paths that do not exist under the current
$CODEX_HOME or repo.
- Treating imports as supported in Codex
AGENTS.md (they are not).
- Hiding conflicts in linked docs instead of calling them out in the root file.
- Expanding root
AGENTS.md beyond 400 words without explicit user approval.
- Creating a new
docs/agents tree in Codex home/config repos where instructions/ is canonical.
- Skipping project exploration before applying or invoking the skill.
- Adding a Table of Contents that does not match actual document headings.
- Never proceed with contradictory instructions without asking which one wins.
- Do not introduce new sections without confirming they are required for every task.
- Avoid “one‑size‑fits‑all” templates that erase repo‑specific commands.
- In scaffold mode, writing non-idempotent edits without marker blocks.
- Omitting
~/.codex/instructions/agent-first-scaffold-spec.md when Jamie standard is requested.
- Overwriting existing instruction files/directories instead of performing scoped, deduplicated inserts.
- Adding backwards-compatibility requirements by default in unreleased/greenfield projects.
- Generating extra legacy-preservation code paths without an explicit compatibility requirement.
- Mixing npm/pnpm/yarn/bun command examples in one output block or defaulting to npm without repository evidence.
Example prompts that should trigger this skill
- "Draft an AGENTS.md for this repo."
- "Create a Repository Guidelines AGENTS.md under 400 words."
- "Standardize our AGENTS.md using actual repo commands."
Procedure
- Clarify scope and inputs.
- Execute the core workflow.
- Summarize outputs and next steps.
1---2name: agents-md-33description: Refactor or create AGENTS.md using progressive disclosure: keep root minimal, split detailed instructions into linked docs, and flag contradictions/redundancy. Use when the user asks to create, update, or refactor AGENTS.md.4---5
6# Agents Md
7
8## Remember
9Use judgment, adapt to context, and stay within explicit safety and scope constraints.
10
11## Compliance
12- Check against GOLD Industry Standards guide in ~/.codex/instructions/standards.md
13- Use ~/.codex/AGENTS.md as the global index that links to current standards docs.
14- If this skill is used from `~/.codex/`, write reference links only under `~/.codex/instructions/` (and not to `docs/` for global protocols).
15- Visual reference: [agents-md workflow map](assets/agents-md.png)
16
17## Philosophy
18
19Prefer concise, verifiable instructions over comprehensive prose. Every command and path must be real and sourced from the repo. Treat AGENTS.md as an operator checklist: short, direct, and actionable. Use progressive disclosure: keep root minimal, link out for details.
20
21Guiding principles:
22- Optimize for reader success in under 2 minutes.
23- Favor deterministic steps over narrative.
24- Keep scope tight; expand only when the repo requires it.
25- Default to canonical implementations for unreleased/greenfield projects; do not add backwards-compatibility layers unless explicitly required.
26
27Mandatory snippet (include verbatim in guidance):
281. Explore project first, then invoke skill.
292. IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any React, Tauri, Apps-SDK-ui, Tailwind, Vite, Storybook + Chat Widget tasks.
303. Add a Table of Contents for docs.
31
32## Core Engineering Principles
33
341. **Clarity over cleverness** — Prefer straightforward, maintainable instructions over elegant or complex phrasing.
352. **Explicit over implicit** — State assumptions, decisions, and side effects directly.
363. **Composition over inheritance** — Prefer small, reusable instruction units over monolithic guidance blocks.
374. **Fail fast, fail loud** — Surface validation failures at the point they occur and stop safely.
385. **Delete before adding** — Remove redundant, outdated, or duplicate instructions before writing new ones.
396. **Verify, don’t assume** — Confirm commands and paths from source files before presenting them.
407. **Stop before you are asked** — Do not expand scope beyond the request without explicit consent.
41
42## Token Efficiency
43
44- Prefer short, one-shot edits; avoid unnecessary tool calls or repeated edits for the same intent.
45- Do not re-read files that were just written when the result is known and unchanged.
46- Do not rerun validation commands unless behavior or assumptions changed.
47- Summarize decisions, not large chunks of raw file contents.
48- Batch related changes into one cohesive update.
49- Avoid confirmation loops like “I will continue...” unless branching is required.
50- Ask once for missing scope questions, then act.
51
52## Scope and triggers
53
54- The user asks to create or update AGENTS.md.
55- The user asks to refactor AGENTS.md for progressive disclosure or split instructions into multiple files.
56- The repo needs a short contributor guide for agents or humans.
57- The user requests “Repository Guidelines” content under 400 words.
58- The repo already has `AGENTS.md`, `CLAUDE.md`, and `GEMINI.md`, and the user asks to keep shared instruction guidance synchronized across them.
59
60## Response format (required)
61- Always include all three sections in every response:
62 - `## When to use` explaining the trigger or noting "in scope".
63 - `## Outputs` describing delivered artifacts.
64 - `## Inputs` listing missing info or noting "none".
65- Use the exact heading text and casing shown above.
66- For out-of-scope requests, start with `## When to use` and still include `## Outputs` and `## Inputs` below.
67- Do not omit `## When to use` under any circumstance.
68- For out-of-scope requests, do not write any text before `## When to use`.
69
70## Cognitive Support / Plain-Language
71- Optimize for low cognitive load (TBI support): one task at a time, explicit steps.
72- Use plain language first; define jargon in parentheses.
73- Keep steps short and checklist-driven where possible.
74- Externalize state: decisions, assumptions, and the next step.
75- Provide ELI5 explanations for non-trivial logic.
76- Ask one question at a time; prefer multiple-choice when possible.
77
78### Response template (minimum)
79
80```md
81## When to use
82- in scope
83
84## Outputs
85- ...
86
87## Inputs
88- ...
89```
90
91### Failure-mode template (out of scope)
92
93```md
94## When to use
95- This skill applies when the user asks to create or refactor AGENTS.md using progressive disclosure.
96
97## Outputs
98- None (out of scope).
99
100## Inputs
101- None (out of scope).
102```
103
104Use the failure-mode template verbatim for out-of-scope requests.
105
106## Required inputs
107
108- Target repo root path.
109- Existing AGENTS.md content (if present).
110- Verified commands and paths from the repo (README, docs, config files).
111- Package-manager signals from repo facts (`package.json#packageManager`, lockfiles, and existing command style in README/CI/docs).
112- Any adjacent instruction files that may conflict (global or per-directory).
113- Whether Jamie's agent-first scaffold standard is requested (`~/.codex/instructions/agent-first-scaffold-spec.md`).
114- Compatibility posture (default: canonical-only for unreleased/greenfield repos; replace only when explicitly requested).
115
116
117## Local Memory usage
118
119- Follow `instructions/local-memory.md` for memory read/write workflow, tagging, and safety rules.
120- Rule: search memory before writing new memory; store durable facts only.
121- Never store secrets in memory.
122
123## local-memory-mcp policy
124
125- Use `local-memory-mcp` for durable context and cross-run continuity.
126- Mandatory workflow:
127 - `bootstrap(mode="minimal", include_questions=true, session_id="repo:<name>:task:<id>")`
128 - `search(query="...", session_id="repo:<name>:task:<id>")`
129- Record durable facts only with `observe(...)` (level `observation|learning`) and stable tags.
130- Do not store secrets, tokens, keys, or PII.
131
132## Deliverables
133
134- A minimal root `AGENTS.md` that links to separate instruction files.
135- One file per instruction category under the repo's canonical instruction root (e.g., `docs/agents/...` or `instructions/agents/...`).
136- A suggested `docs/` folder structure.
137- A table of contents for docs that are created or updated.
138- A contradictions list with a question for each conflict.
139- A “flag for deletion” list (redundant, vague, overly obvious).
140- A detected package-manager command map (`install`, `run`, optional `exec`) derived from repo evidence and reused across generated docs.
141- When requested: idempotent scaffold blocks for `AGENTS.md`, `.agent/PLANS.md`, and `README.md`.
142- Output contract schema_version: 1
143
144## Constraints
145- Redact secrets/PII by default.
146- Do not invent commands, scripts, or paths.
147- Redact secrets and sensitive data by default.
148- Use ASCII only unless the repo already uses non-ASCII.
149- Do not add dependencies or tools.
150- Do not add legacy shims, adapter layers, dual-write paths, or backwards-compatibility promises unless the user explicitly requires compatibility.
151- Do not hardcode npm/pnpm/yarn/bun command examples without repo evidence.
152
153## Workflow
154
1551) Discover repo facts
156- Read README and `docs/` for real commands and structure.
157- Inspect config files (for example `pyproject.toml`, package scripts).
158- Determine canonical instruction root before generating files:
159 - If target path is `~/.codex` or a Codex config repo clone (for example `/Users/<user>/dev/config/codex`), prefer `instructions/` and do not create `docs/` for agent guidance.
160 - Else, follow existing repo convention (`docs/agents` vs `instructions/agents`) and avoid introducing a second instruction tree.
161- Detect package manager in this precedence: `package.json#packageManager` -> lockfiles (`pnpm-lock.yaml`, `yarn.lock`, `bun.lockb`/`bun.lock`, `package-lock.json`, `npm-shrinkwrap.json`) -> existing command style in README/CI/docs.
162- If package-manager signals conflict or are missing, state "not observed" and ask which command style should be used before emitting manager-specific commands.
163- Build one package-manager command map from detected evidence and apply it consistently in generated AGENTS/CLAUDE/GEMINI updates.
164- If commit conventions are not visible, state “not observed.”
165- Read global instructions from `~/.codex/AGENTS.md`.
166- Also check `~/.codex/instructions/` for applicable global standards and guidance.
167- Then read project instructions from repo root down to the working directory and treat them as canonical.
168- Note: Codex `AGENTS.md` does not support `@` imports; Claude `CLAUDE.md` and `~/.claude/rules/*.md` do.
169- Canonical hierarchy rule: when both `AGENTS.md` and `CLAUDE.md`/`GEMINI.md` exist, treat `AGENTS.md` as canonical source of truth for repository-wide, cross-tool instructions. Keep CLAUDE/GEMINI focused on agent/CLI-specific usage and memory conventions.
170- If a repo already has `AGENTS.md`, `CLAUDE.md`, and `GEMINI.md`, update shared sections in `CLAUDE.md` and `GEMINI.md` to reference the canonical `AGENTS.md` guidance rather than duplicate it.
171- If existing `AGENTS.md`, `.agent/PLANS.md`, `README.md`, or required `docs/` directories already exist, merge instead of overwrite.
172- Apply **idempotent updates**: preserve existing content, insert only missing sections/links, and dedupe existing lines.
173- Create directories/files only if absent; do not recreate duplicates.
174
1752) Find contradictions
176- Identify conflicting instructions and ask which one should win.
177- Do not resolve conflicts without user confirmation.
178
1792.1) Set compatibility posture
180- Default to canonical-only guidance for unreleased/greenfield projects.
181- Only include backwards-compatibility instructions when explicitly requested or when the repo shows clear released-version compatibility commitments.
182
1833) Identify the essentials (root AGENTS.md)
184- One-sentence project description.
185- Repo-native package manager command style (install/run/exec, as observed).
186- Non-standard build/typecheck commands.
187- Anything truly relevant to every single task.
188
1894) Add inserts (global references)
190- If a canonical global protocol exists (for example `~/.codex/instructions/rvcp-common.md`), add a short "References" or "Imports" section at the top of the root `AGENTS.md` that points to it.
191- Never duplicate the full protocol content in repo files; link only.
192- If `CODEX_HOME` is set, prefer `$CODEX_HOME/...` for global references; otherwise use `~/.codex/...`.
193- Only insert references that exist on disk; if not found, state "not observed" and do not invent paths.
194- In `~/.codex/` context, do not write global protocol references to `docs/` paths. Always use `~/.codex/instructions/...` for protocol links.
195- If the repo uses a different global protocol, add the same style of reference block.
196- When scaffold mode is requested, include references to the scaffold spec and governance docs listed above.
197 - Example (root `AGENTS.md` block):
198 ```md
199 ## References (informational)
200 - Global protocol: ~/.codex/instructions/rvcp-common.md
201 - Security and standards baseline: ~/.codex/instructions/standards.md
202 ```
203
2045) Group the rest
205- Organize remaining instructions into logical categories (TypeScript, testing, deployment, accessibility, etc.).
206- Keep each category file focused and scoped.
207
2086) Create the file structure
209- Output a minimal root `AGENTS.md` with Markdown links to category files under the canonical instruction root selected in step 1.
210- Output each category file with its relevant instructions.
211- Provide a suggested folder structure rooted at the selected instruction root.
212
2137) Flag for deletion
214- Identify redundant, vague, or overly obvious instructions.
215
2168) Validate content
217- Confirm commands exist and are runnable.
218- Confirm naming conventions match the codebase.
219- Ensure no secrets or private endpoints appear.
220- For scaffold mode: verify marker blocks are present and not duplicated.
221- For scaffold mode: run `python3 ~/.codex/scripts/plan-graph-lint.py <repo>/.agent/PLANS.md`.
222- For scaffold mode: run link-integrity checks with `rg -n` for required global references.
223
224## Required sections (root AGENTS.md)
225
226- One-sentence project description
227- Tooling essentials (repo-native package-manager commands, including install/run equivalents)
228- Non-standard build/typecheck commands
229- Code quality standards (inject when requested or supported by repo evidence)
230- Planning guidance (inject plan-review rules for complex implementation work)
231- Shell script conventions (inject when shell scripts/wrappers are present)
232- References or imports (global protocol pointers; no duplication)
233- Global instructions discovery order (brief, link to full doc)
234- Links to category files
235 - For Codex home/config repos: prefer `instructions/agents/...` links over `docs/agents/...`.
236
237## Flaky Test Artifact Capture (injectable block, conditional)
238
239Use this block when the repo has automated tests (Node, Python, Rust, Playwright, Vitest, Jest, or pytest evidence).
240
241Decision rule:
2421) If the user asks for flaky-test detection/artifacts/history, always inject this block.
2432) Else, inject when repo facts show test commands/config (`test` scripts, `pytest`, `vitest`, `playwright`, `jest`, `Cargo test`, or `tests/` directory).
2443) If no test evidence exists, do not inject.
245
246When injected, include these concrete requirements:
247- Required script path: `scripts/test-with-artifacts.sh`
248- Required modes: `all`, `unit`, `integration`, `e2e`
249- Required output root: `artifacts/test`
250- Required stable outputs:
251 - `artifacts/test/summary-*.json`
252 - `artifacts/test/test-output-*.log`
253 - `artifacts/test/junit-*.xml` (when runner supports it)
254 - `artifacts/test/*-results.json` (when runner supports it)
255 - `artifacts/test/artifact-manifest.json`
256- If `package.json` exists, wire scripts:
257 - `test:artifacts`, `test:artifacts:unit`, `test:artifacts:integration`, `test:artifacts:e2e`
258- Use the detected package-manager command map for script invocations; do not mix manager variants in one generated block.
259
260Insert this exact section in generated AGENTS.md for test repos:
261
262```md
263## Flaky Test Artifact Capture
264- Run `bash scripts/test-with-artifacts.sh all` (or the detected repo-native command for `test:artifacts`) to emit machine-readable flaky evidence under `artifacts/test`.
265- Optional targeted modes:
266 - `bash scripts/test-with-artifacts.sh unit`
267 - `bash scripts/test-with-artifacts.sh integration`
268 - `bash scripts/test-with-artifacts.sh e2e`
269- Commit/retain stable artifact paths for local automation ingestion:
270 - `artifacts/test/summary-*.json`
271 - `artifacts/test/test-output-*.log`
272 - `artifacts/test/junit-*.xml` (when supported by test runner)
273 - `artifacts/test/*-results.json` (when supported by test runner)
274 - `artifacts/test/artifact-manifest.json`
275- Keep artifact filenames stable (no timestamps in filenames) so recurring flake scans can compare runs.
276```
277
278## Code Quality Standards (injectable block, conditional)
279
280Decision rule:
2811) Inject when the user explicitly asks for code-quality or testing standards.
2822) Else, inject when repo evidence shows automated tests, linting, or typechecking workflows.
2833) If no evidence exists, do not inject.
284
285Insert this section when injected:
286
287```md
288## Code Quality Standards
289- Run full test suite before committing: `npm test` or the detected repo-native equivalent.
290- Fix TypeScript errors and lint issues before marking tasks complete.
291- Ensure test isolation - tests should not depend on execution order.
292```
293
294## Plan Review Guidelines (injectable block, conditional)
295
296Decision rule:
2971) Inject when the user asks for planning guardrails.
2982) Else, inject when the task includes complex features, refactors, or architecture changes.
2993) Skip for trivial edits unless explicitly requested.
300
301Insert this section when injected:
302
303```md
304## Planning
305### Plan Review Guidelines
306- Before implementing complex features, create a minimal v1 scope.
307- Avoid over-engineering - prefer simple solutions over comprehensive ones.
308- Scale back ambition if initial plan feels too large.
309```
310
311## Shell Script Conventions (injectable block, conditional)
312
313Decision rule:
3141) Inject when the user asks for shell/script quality guidance.
3152) Else, inject when repo evidence includes shell scripts, wrapper scripts, or script-based automation.
3163) If no shell-script evidence exists, do not inject.
317
318Insert this section when injected:
319
320```md
321## Shell Script Conventions
322- Always validate wrapper scripts with shellcheck before considering complete.
323- Test script syntax with `bash -n script.sh` to catch errors early.
324- Handle edge cases for function conflicts and environment variable loading.
325```
326
327## Frontend Website Rules (injectable block, conditional)
328
329Use this only when there is evidence the repo/task is frontend website work.
330
331Decision rule (to let the skill "figure it out"):
3321) If the user explicitly requests UI/frontend implementation, visual parity, screenshot, component polish, or reference-based frontend behavior, treat as frontend.
3332) Else, infer from repo facts:
334 - `package.json` includes React/Next/Vite/Tauri/Vue/Svelte frameworks or UI tooling.
335 - `index.html`, `vite.config.*`, `next.config.*`, or `src/main.*` exists near `src/`.
336 - A `brand/` folder is relevant and used for style assets.
3373) If no evidence, do not inject this block; output a short note in `## Outputs` asking for clarification.
338
339If frontend evidence is present, inject the block into the generated `AGENTS.md` (or category docs) so behavior is concrete and repeatable:
340
341### AGENTS.md — Frontend Website Rules
342
343- **Always Do First**: invoke `$ui-ux-creative-coding` and `$interface-craft` before writing any frontend code.
344- If a reference image is provided:
345 - Match layout, spacing, typography, and color exactly.
346 - Use placeholders (`https://placehold.co/`) only when content is missing.
347 - Do not improve or add to the design beyond the reference.
348- If no reference image: design from scratch with the guardrails in this section.
349- **Local server required**: Always serve from `http://localhost:2000` using the project’s `node serve.mjs`.
350 - Never use `file:///`.
351 - Start `node serve.mjs` in background before screenshots.
352 - If already running, reuse that instance.
353- Replace Puppeteer-specific assumptions with **agent-browser**:
354 - Use `agent-browser` for navigation and screenshot capture.
355 - Keep workflow tool-first: `agent-browser open http://localhost:2000` then capture screenshots.
356- Pair with `$agentation` (or `agentation` MCP invocation) for execution orchestration:
357 - session setup, screenshot loop control, and comparison pass tracking.
358- **Screenshot naming convention**:
359 - If the screenshot is a full page: `screenshot-page-<name>-<pass>.png`
360 - If the screenshot is a component: `screenshot-component-<type>-<state>-<pass>.png`
361 - examples: `screenshot-component-card-default-1.png`, `screenshot-component-button-hover-2.png`
362 - Never overwrite; increment pass number when rerunning comparisons.
363- Compare against the reference after each pass and continue at least 2 rounds until no visible mismatch.
364- Output should use inline styles in a single `index.html` and Tailwind via `https://cdn.tailwindcss.com`.
365- Tailwind classes:
366 - Do not use default indigo/blue primaries.
367 - Do not use `transition-all`.
368 - For clickables, define hover, focus-visible, and active states.
369- If `brand/` assets exist, prefer them over placeholders.
370- Use existing brand variables; do not invent colors, spacing tokens, or typography scales.
371
372### Runtime checks for screenshot workflows
373
374- Run at least 2 screenshot rounds for visual parity.
375- Use consistent comparison criteria: spacing/padding, typography scale, color values, alignment, border radii, shadows, sizing.
376- For component screenshots, include the component type in filename (`card`, `button`, `modal`, `form`, etc.) to keep review context explicit.
377
378## Agent-first scaffold integration (Jamie standard)
379
380Apply this when the user asks for agent-first rollout/scaffold across repos (especially under `~/dev`).
381
382Required global references (verify they exist before insertion):
383- `~/.codex/instructions/openai-agent-workflow-playbook.md`
384- `~/.codex/instructions/README.checklist.md`
385- `~/.codex/instructions/validator-contracts.md`
386- `~/.codex/instructions/strict-toggle-governance.md`
387- `~/.codex/instructions/agent-first-scaffold-spec.md`
388
389Use idempotent marker blocks:
390- `AGENTS.md`: `<!-- AGENT-FIRST-SCAFFOLD:START --> ... <!-- AGENT-FIRST-SCAFFOLD:END -->`
391- `.agent/PLANS.md`: `<!-- AGENT-FIRST-PLANS:START --> ... <!-- AGENT-FIRST-PLANS:END -->`
392- `README.md`: `<!-- AGENT-FIRST-WORKFLOW:START --> ... <!-- AGENT-FIRST-WORKFLOW:END -->`
393
394`.agent/PLANS.md` contract requirements:
395- `tasks[]`, each task has `id`, `title`, `depends_on`
396- `id` format `^T[1-9][0-9]*$`
397- IDs unique within plan
398- `depends_on` references in-plan IDs only
399- no self-dependency; DAG required; single connected component
400- validation command: `python3 ~/.codex/scripts/plan-graph-lint.py <plan-file>`
401
402Canonical verification command:
403- `bash ~/.codex/scripts/verify-work.sh`
404
405Rollout policy:
406- Link to 3-gate warn->block model in `~/.codex/instructions/agent-first-scaffold-spec.md`.
407
408## Variation
409
410- Vary examples and commands to match the target repo’s stack (Python vs Node).
411- Use repo-specific paths and filenames; avoid repeating generic defaults across repos.
412
413## Empowerment
414
415- Offer two to three clear next-step options after drafting (accept, revise, or add missing info).
416- Call out unknowns explicitly and ask for confirmation before finalizing.
417- Encourage the user to prioritize sections when the scope is broad.
418- Empower the user to choose between a minimal or detailed guideline set.
419- Empower the user with explicit **choice and control** over scope, depth, and inserts before expanding.
420- Explicitly empower the user to defer optional inserts until core guidance is approved.
421- Ask whether to proceed with inserts when the global protocol is detected but optional.
422- Provide a one-sentence rationale for each recommended insert or deletion.
423
424## Validation
425
426- Fail fast: stop at the first failed validation gate, fix it, then re-run.
427- Run `~/.venvs/pyyaml/bin/python scripts/quick_validate.py <skill>` if available.
428- Run `~/.venvs/pyyaml/bin/python scripts/skill_gate.py <skill>` and fix any missing sections.
429- If needed, consult `references/contract.yaml` and `references/evals.yaml`.
430- If validation scripts or paths are missing, state "not run (tooling not available)" and continue.
431
432## Anti-patterns
433
434- Generic boilerplate that ignores repo specifics.
435- Fabricated commands or paths.
436- Omitting contradictions or failing to ask which instruction wins.
437- Burying risks or assumptions in long prose.
438- Using vague headings like “Misc” or “Notes.”
439- Presenting unverified commands as facts.
440- Mixing unrelated policies into the same section.
441- Adding global protocol content directly into repo `AGENTS.md` instead of linking.
442- Stating paths that do not exist under the current `$CODEX_HOME` or repo.
443- Treating imports as supported in Codex `AGENTS.md` (they are not).
444- Hiding conflicts in linked docs instead of calling them out in the root file.
445- Expanding root `AGENTS.md` beyond 400 words without explicit user approval.
446- Creating a new `docs/agents` tree in Codex home/config repos where `instructions/` is canonical.
447- Skipping project exploration before applying or invoking the skill.
448- Adding a Table of Contents that does not match actual document headings.
449- Never proceed with contradictory instructions without asking which one wins.
450- Do not introduce new sections without confirming they are required for every task.
451- Avoid “one‑size‑fits‑all” templates that erase repo‑specific commands.
452- In scaffold mode, writing non-idempotent edits without marker blocks.
453- Omitting `~/.codex/instructions/agent-first-scaffold-spec.md` when Jamie standard is requested.
454- Overwriting existing instruction files/directories instead of performing scoped, deduplicated inserts.
455- Adding backwards-compatibility requirements by default in unreleased/greenfield projects.
456- Generating extra legacy-preservation code paths without an explicit compatibility requirement.
457- Mixing npm/pnpm/yarn/bun command examples in one output block or defaulting to npm without repository evidence.
458
459## Example prompts that should trigger this skill
460
461- "Draft an AGENTS.md for this repo."
462- "Create a Repository Guidelines AGENTS.md under 400 words."
463- "Standardize our AGENTS.md using actual repo commands."
464## Procedure
4651) Clarify scope and inputs.
4662) Execute the core workflow.
4673) Summarize outputs and next steps.