Create prescriptive, action-oriented AGENTS.md files that tell agents what to DO, what to REUSE, and what rules to FOLLOW. Never write descriptive documentation — write instructions.
Core Philosophy
AGENTS.md files are not documentation. They are instruction sets for coding agents. Every sentence should either:
- Tell the agent what to do ("Use X when...")
- Constrain the agent's behavior ("MUST NOT...")
- Give a step-by-step procedure ("1. Create... 2. Add... 3. Run...")
File Structure Template
Every AGENTS.md follows this structure. Adapt sections based on file size (small: 40-80 lines, medium: 80-150 lines, large: 150+ lines).
# {Name} — Agent Guidelines
{One-line imperative directive: "Use X for Y." or "Use the Z module for A, B, and C."}
## MUST Rules
1. **MUST ...** — {consequence or rationale}
2. **MUST NOT ...** — {what to do instead}
3. **MUST ...** — {consequence or rationale}
## {Primary Task Section — "When You Need X" or "Adding a New Y"}
{Numbered checklist or decision table}
## {Secondary Sections}
{Tables with "When to use" / "When to modify" columns}
## Structure
{Directory tree — keep brief}
## {Cross-References} (if applicable)
- **For X**: `path/to/AGENTS.md` → Section
Prescriptive Tone Rules
NEVER start a section with
- "The module provides..."
- "This package is..."
- "This document describes..."
- "X is a Y that..."
ALWAYS start sections with
- Imperative verbs: "Use", "Add", "Create", "Configure", "Declare", "Follow", "Resolve"
- Conditional directives: "When you need X, do Y"
- Constraints: "MUST", "MUST NOT"
Transform Patterns
| Descriptive (BAD) |
Prescriptive (GOOD) |
| "The cache module provides multi-strategy caching" |
"Use @open-mercato/cache for all caching needs. MUST NOT use raw Redis directly." |
| "Products are core entities with media" |
"Products — core entities. MUST have at least a name" |
| "Events support local and async dispatch" |
"When QUEUE_STRATEGY=async, persistent events dispatch through BullMQ" |
| "The pricing system uses layered overrides" |
"Price layers compose in order: base → channel → customer → promotional" |
| Description column in tables |
"When to use" or "When to modify" column |
MUST Rules Requirements
| File size |
Minimum MUST rules |
| Small (< 80 lines) |
3 |
| Medium (80-150 lines) |
5 |
| Large (150+ lines) |
8+ |
Writing Effective MUST Rules
Each MUST rule follows this pattern: **MUST [verb]** — [rationale or consequence]
Good examples:
**MUST resolve via DI** — always use container.resolve('cacheService'), never instantiate directly
**MUST NOT reimplement pricing logic** — use selectBestPrice and the resolver pipeline
**MUST export metadata** with { queue, id?, concurrency? } from every worker file
**MUST follow document flow**: Quote → Order → Invoice — no skipping steps
Bad examples:
**MUST** follow best practices (too vague)
**MUST** be careful with... (not actionable)
**MUST** use the correct approach (says nothing)
Table Column Conventions
NEVER use these column headers
- "Description"
- "Purpose" (as standalone — use "Purpose / MUST rules" instead)
- "Details"
ALWAYS use these column headers
| Context |
Column headers to use |
| Feature/strategy tables |
"When to use", "Configuration" |
| Directory listings |
"When to modify" |
| Entity/data model |
Constraint-framed bullets: "Entity — description. MUST [constraint]" |
| File reference tables |
"When you need", "Copy from" |
| API/endpoint tables |
"When to use", "MUST rules" |
| Environment variables |
"When to configure" |
| DI tokens / imports |
"When to use", "Import path" |
Checklist Sections
Include numbered checklists for common tasks. Pattern: "Adding a New X" or "Checklist: Do Y"
## Adding a New Worker
1. Create worker file in `src/modules/<module>/workers/<worker-name>.ts`
2. Export `metadata` with `{ queue: '<queue-name>', id: '<worker-id>', concurrency: <n> }`
3. Export default async handler function
4. Ensure handler is idempotent — check state before mutating
5. Run `npm run modules:prepare` to register the worker
6. Test with `QUEUE_STRATEGY=local` in development
Every checklist MUST:
- Use numbered steps (not bullets)
- Start each step with an imperative verb
- Include the
npm run modules:prepare step when adding module files
- End with a testing/verification step
Data Model Sections
Convert entity lists to constraint-framed bullets:
## Data Model Constraints
- **Products** — core entities with media. MUST have at least a name
- **Categories** — hierarchical. MUST maintain parent-child integrity (no circular references)
- **Variants** — linked via `product_id`. MUST reference valid option schemas
- **Prices** — multi-tier with channel scoping. MUST use `selectBestPrice` for resolution
Pattern: **Entity** — brief description. MUST [constraint]
Cross-Reference Rules
When two AGENTS.md files cover related topics:
- Pick one authoritative source for each topic — never duplicate full content
- Use condensed quick-references in the non-authoritative file
- Add a Cross-Reference section at the bottom linking to related guides
- Keep the Task Router in root AGENTS.md accurate with descriptive task names
Example:
## Cross-Reference
- **Declaring events in a module**: `packages/core/AGENTS.md` → Events
- **Queue worker contract**: `packages/queue/AGENTS.md`
File Size Guidelines
| Type |
Target lines |
Examples |
| Small package |
40–80 |
cache, content, queue, events |
| Medium module |
60–100 |
catalog, sales, customers, onboarding |
| Large package |
80–150 |
shared, create-app, specs |
| Very large (tone rewrite) |
Keep original length |
ai-assistant (1100), search (700) |
Sizing Rules
- Keep small files focused — do not pad with unnecessary sections
- Large files: keep ALL technical content, only reframe tone
- Root AGENTS.md: MUST stay under 230 lines
Code Examples in AGENTS.md
- Include code examples only for contracts (worker metadata, event declaration, subscriber export)
- Keep examples minimal — 3-5 lines max for inline snippets
- For full API examples, cross-reference the relevant module or spec
- MUST NOT include implementation details — only show the interface/pattern
Verification Checklist
After writing an AGENTS.md, verify:
- Tone: Every section starts with imperative verb or "When you need..."
- MUST audit: File has required number of MUST rules (3+ small, 5+ medium, 8+ large)
- No descriptive openers: No section starts with "The module provides..." or similar
- Tables: All tables use "When to use" / "When to modify" columns, never "Description"
- Checklists: Common tasks have numbered step-by-step procedures
- Data models: Entity lists are constraint-framed with MUST rules
- Cross-references: No duplicated content between files; clear pointers instead
- Structure section: Directory tree is present and brief
- Opening line: File starts with one-line imperative directive, not a description
Anti-Patterns
- Explaining how things work instead of telling agents what to do
- Listing features instead of listing constraints
- Duplicating content across multiple AGENTS.md files
- Writing paragraphs where a checklist would be clearer
- Adding changelog sections to small/medium files (only for large files with complex history)
- Over-documenting internals — AGENTS.md guides usage, not implementation
- Missing the "when" framing — every table/section should answer "when do I use this?"
Reference Examples
Study these files as reference implementations:
| Size |
File |
Why it's good |
| Small |
packages/cache/AGENTS.md |
Clean structure, 5 MUST rules, decision table, checklist |
| Small |
packages/queue/AGENTS.md |
Concurrency guidelines table, idempotency rule, worker contract |
| Medium |
packages/core/src/modules/sales/AGENTS.md |
Data model constraints, document flow MUST rules, "MUST NOT modify directly" |
| Medium |
packages/core/src/modules/customers/AGENTS.md |
"Copy from here" directive, reference files table, module checklist |
| Large |
packages/search/AGENTS.md |
Strategy decision guide, dual checklists, DI token reference |
| Large |
packages/ai-assistant/AGENTS.md |
Common tasks up front, auth MUST rules, session debugging steps |
When Updating Root AGENTS.md Task Router
After creating a new AGENTS.md, update the Task Router table in root AGENTS.md:
- Add a row with descriptive task keywords (not just the package name)
- Include specific function names, patterns, and task verbs an agent would search for
- Keep the root file under 230 lines
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: create-agents-md-53description: Create or rewrite AGENTS.md files for Open Mercato packages and modules. Use this skill when adding a new package, creating a new module, or when an existing AGENTS.md needs to be created or refactored. Ensures prescriptive tone, MUST rules, checklists, and consistent structure across all agent guidelines. Use when this capability is needed.4---56Create prescriptive, action-oriented AGENTS.md files that tell agents **what to DO**, **what to REUSE**, and **what rules to FOLLOW**. Never write descriptive documentation — write instructions.78## Core Philosophy910AGENTS.md files are **not documentation**. They are **instruction sets for coding agents**. Every sentence should either:11- Tell the agent what to do ("Use X when...")12- Constrain the agent's behavior ("MUST NOT...")13- Give a step-by-step procedure ("1. Create... 2. Add... 3. Run...")1415## File Structure Template1617Every AGENTS.md follows this structure. Adapt sections based on file size (small: 40-80 lines, medium: 80-150 lines, large: 150+ lines).1819```markdown20# {Name} — Agent Guidelines2122{One-line imperative directive: "Use X for Y." or "Use the Z module for A, B, and C."}2324## MUST Rules25261. **MUST ...** — {consequence or rationale}272. **MUST NOT ...** — {what to do instead}283. **MUST ...** — {consequence or rationale}2930## {Primary Task Section — "When You Need X" or "Adding a New Y"}3132{Numbered checklist or decision table}3334## {Secondary Sections}3536{Tables with "When to use" / "When to modify" columns}3738## Structure3940{Directory tree — keep brief}4142## {Cross-References} (if applicable)4344- **For X**: `path/to/AGENTS.md` → Section45```4647## Prescriptive Tone Rules4849### NEVER start a section with5051- "The module provides..."52- "This package is..."53- "This document describes..."54- "X is a Y that..."5556### ALWAYS start sections with5758- Imperative verbs: "Use", "Add", "Create", "Configure", "Declare", "Follow", "Resolve"59- Conditional directives: "When you need X, do Y"60- Constraints: "MUST", "MUST NOT"6162### Transform Patterns6364| Descriptive (BAD) | Prescriptive (GOOD) |65|---|---|66| "The cache module provides multi-strategy caching" | "Use `@open-mercato/cache` for all caching needs. MUST NOT use raw Redis directly." |67| "Products are core entities with media" | "**Products** — core entities. MUST have at least a name" |68| "Events support local and async dispatch" | "When `QUEUE_STRATEGY=async`, persistent events dispatch through BullMQ" |69| "The pricing system uses layered overrides" | "Price layers compose in order: base → channel → customer → promotional" |70| Description column in tables | "When to use" or "When to modify" column |7172## MUST Rules Requirements7374| File size | Minimum MUST rules |75|-----------|-------------------|76| Small (< 80 lines) | 3 |77| Medium (80-150 lines) | 5 |78| Large (150+ lines) | 8+ |7980### Writing Effective MUST Rules8182Each MUST rule follows this pattern: `**MUST [verb]** — [rationale or consequence]`8384Good examples:85- `**MUST resolve via DI** — always use container.resolve('cacheService'), never instantiate directly`86- `**MUST NOT reimplement pricing logic** — use selectBestPrice and the resolver pipeline`87- `**MUST export metadata** with { queue, id?, concurrency? } from every worker file`88- `**MUST follow document flow**: Quote → Order → Invoice — no skipping steps`8990Bad examples:91- `**MUST** follow best practices` (too vague)92- `**MUST** be careful with...` (not actionable)93- `**MUST** use the correct approach` (says nothing)9495## Table Column Conventions9697### NEVER use these column headers98- "Description"99- "Purpose" (as standalone — use "Purpose / MUST rules" instead)100- "Details"101102### ALWAYS use these column headers103104| Context | Column headers to use |105|---------|----------------------|106| Feature/strategy tables | "When to use", "Configuration" |107| Directory listings | "When to modify" |108| Entity/data model | Constraint-framed bullets: "Entity — description. MUST [constraint]" |109| File reference tables | "When you need", "Copy from" |110| API/endpoint tables | "When to use", "MUST rules" |111| Environment variables | "When to configure" |112| DI tokens / imports | "When to use", "Import path" |113114## Checklist Sections115116Include numbered checklists for common tasks. Pattern: "Adding a New X" or "Checklist: Do Y"117118```markdown119## Adding a New Worker1201211. Create worker file in `src/modules/<module>/workers/<worker-name>.ts`1222. Export `metadata` with `{ queue: '<queue-name>', id: '<worker-id>', concurrency: <n> }`1233. Export default async handler function1244. Ensure handler is idempotent — check state before mutating1255. Run `npm run modules:prepare` to register the worker1266. Test with `QUEUE_STRATEGY=local` in development127```128129Every checklist MUST:130- Use numbered steps (not bullets)131- Start each step with an imperative verb132- Include the `npm run modules:prepare` step when adding module files133- End with a testing/verification step134135## Data Model Sections136137Convert entity lists to constraint-framed bullets:138139```markdown140## Data Model Constraints141142- **Products** — core entities with media. MUST have at least a name143- **Categories** — hierarchical. MUST maintain parent-child integrity (no circular references)144- **Variants** — linked via `product_id`. MUST reference valid option schemas145- **Prices** — multi-tier with channel scoping. MUST use `selectBestPrice` for resolution146```147148Pattern: `**Entity** — brief description. MUST [constraint]`149150## Cross-Reference Rules151152When two AGENTS.md files cover related topics:1531541. **Pick one authoritative source** for each topic — never duplicate full content1552. **Use condensed quick-references** in the non-authoritative file1563. **Add a Cross-Reference section** at the bottom linking to related guides1574. **Keep the Task Router in root AGENTS.md** accurate with descriptive task names158159Example:160```markdown161## Cross-Reference162163- **Declaring events in a module**: `packages/core/AGENTS.md` → Events164- **Queue worker contract**: `packages/queue/AGENTS.md`165```166167## File Size Guidelines168169| Type | Target lines | Examples |170|------|-------------|---------|171| Small package | 40–80 | cache, content, queue, events |172| Medium module | 60–100 | catalog, sales, customers, onboarding |173| Large package | 80–150 | shared, create-app, specs |174| Very large (tone rewrite) | Keep original length | ai-assistant (~1100), search (~700) |175176## Sizing Rules177178- Keep small files focused — do not pad with unnecessary sections179- Large files: keep ALL technical content, only reframe tone180- Root AGENTS.md: MUST stay under 230 lines181182## Code Examples in AGENTS.md183184- Include code examples only for **contracts** (worker metadata, event declaration, subscriber export)185- Keep examples minimal — 3-5 lines max for inline snippets186- For full API examples, cross-reference the relevant module or spec187- MUST NOT include implementation details — only show the interface/pattern188189## Verification Checklist190191After writing an AGENTS.md, verify:1921931. **Tone**: Every section starts with imperative verb or "When you need..."1942. **MUST audit**: File has required number of MUST rules (3+ small, 5+ medium, 8+ large)1953. **No descriptive openers**: No section starts with "The module provides..." or similar1964. **Tables**: All tables use "When to use" / "When to modify" columns, never "Description"1975. **Checklists**: Common tasks have numbered step-by-step procedures1986. **Data models**: Entity lists are constraint-framed with MUST rules1997. **Cross-references**: No duplicated content between files; clear pointers instead2008. **Structure section**: Directory tree is present and brief2019. **Opening line**: File starts with one-line imperative directive, not a description202203## Anti-Patterns2042051. **Explaining how things work** instead of telling agents what to do2062. **Listing features** instead of listing constraints2073. **Duplicating content** across multiple AGENTS.md files2084. **Writing paragraphs** where a checklist would be clearer2095. **Adding changelog sections** to small/medium files (only for large files with complex history)2106. **Over-documenting internals** — AGENTS.md guides usage, not implementation2117. **Missing the "when" framing** — every table/section should answer "when do I use this?"212213## Reference Examples214215Study these files as reference implementations:216217| Size | File | Why it's good |218|------|------|---------------|219| Small | `packages/cache/AGENTS.md` | Clean structure, 5 MUST rules, decision table, checklist |220| Small | `packages/queue/AGENTS.md` | Concurrency guidelines table, idempotency rule, worker contract |221| Medium | `packages/core/src/modules/sales/AGENTS.md` | Data model constraints, document flow MUST rules, "MUST NOT modify directly" |222| Medium | `packages/core/src/modules/customers/AGENTS.md` | "Copy from here" directive, reference files table, module checklist |223| Large | `packages/search/AGENTS.md` | Strategy decision guide, dual checklists, DI token reference |224| Large | `packages/ai-assistant/AGENTS.md` | Common tasks up front, auth MUST rules, session debugging steps |225226## When Updating Root AGENTS.md Task Router227228After creating a new AGENTS.md, update the Task Router table in root `AGENTS.md`:2291. Add a row with descriptive task keywords (not just the package name)2302. Include specific function names, patterns, and task verbs an agent would search for2313. Keep the root file under 230 lines232233---234> Converted and distributed by [TomeVault](https://tomevault.io/claim/open-mercato) — claim your Tome and manage your conversions.235<!-- tomevault:4.0:skill_md:2026-04-11 -->