@event4u/agent-config 1.28.0 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.agent-src/commands/agents/audit.md +101 -197
  2. package/.agent-src/commands/{copilot-agents → agents}/init.md +18 -10
  3. package/.agent-src/commands/agents/optimize.md +181 -0
  4. package/.agent-src/commands/agents.md +19 -12
  5. package/.agent-src/commands/optimize/agents-dir.md +111 -0
  6. package/.agent-src/commands/optimize.md +10 -8
  7. package/.agent-src/contexts/communication/rules-auto/guidelines-mechanics.md +6 -0
  8. package/.agent-src/contexts/communication/rules-auto/slash-command-routing-policy-mechanics.md +2 -3
  9. package/.agent-src/contexts/contracts/agents-md-anatomy.md +132 -0
  10. package/.agent-src/skills/agents-md-thin-root/SKILL.md +8 -1
  11. package/.agent-src/skills/async-python-patterns/SKILL.md +147 -0
  12. package/.agent-src/skills/command-writing/SKILL.md +49 -0
  13. package/.agent-src/skills/copilot-agents-optimization/SKILL.md +3 -3
  14. package/.agent-src/skills/defense-in-depth/SKILL.md +152 -0
  15. package/.agent-src/skills/error-handling-patterns/SKILL.md +134 -0
  16. package/.agent-src/skills/mcp-builder/SKILL.md +108 -0
  17. package/.agent-src/skills/prompt-engineering-patterns/SKILL.md +145 -0
  18. package/.agent-src/skills/repomix-packer/SKILL.md +135 -0
  19. package/.agent-src/skills/roadmap-writing/SKILL.md +9 -0
  20. package/.agent-src/skills/rule-writing/SKILL.md +21 -0
  21. package/.agent-src/skills/secrets-management/SKILL.md +142 -0
  22. package/.agent-src/skills/skill-writing/SKILL.md +19 -0
  23. package/.agent-src/skills/testing-anti-patterns/SKILL.md +152 -0
  24. package/.agent-src/templates/AGENTS.md +9 -10
  25. package/.claude-plugin/marketplace.json +12 -7
  26. package/AGENTS.md +1 -2
  27. package/CHANGELOG.md +113 -0
  28. package/CONTRIBUTING.md +90 -0
  29. package/README.md +3 -3
  30. package/docs/architecture.md +3 -3
  31. package/docs/catalog.md +19 -13
  32. package/docs/contracts/command-clusters.md +20 -3
  33. package/docs/contracts/file-ownership-matrix.json +511 -48
  34. package/docs/contracts/package-self-orientation.md +1 -1
  35. package/docs/getting-started.md +1 -1
  36. package/docs/guidelines/code-clarity.md +95 -0
  37. package/docs/guidelines/php/general.md +8 -0
  38. package/docs/guidelines/php/php-coding-patterns.md +1 -0
  39. package/docs/skills-catalog.md +27 -3
  40. package/llms.txt +26 -2
  41. package/package.json +1 -1
  42. package/scripts/chat_history.py +166 -36
  43. package/scripts/check_command_count_messaging.py +12 -3
  44. package/scripts/check_portability.py +1 -0
  45. package/scripts/lint_agents_md.py +33 -0
  46. package/scripts/release.py +77 -2
  47. package/scripts/skill_linter.py +10 -3
  48. package/.agent-src/commands/agents/cleanup.md +0 -194
  49. package/.agent-src/commands/agents/prepare.md +0 -141
  50. package/.agent-src/commands/copilot-agents/optimize.md +0 -255
  51. package/.agent-src/commands/copilot-agents.md +0 -44
  52. package/.agent-src/commands/optimize/agents.md +0 -144
@@ -1,26 +1,31 @@
1
1
  ---
2
2
  name: agents
3
- description: Agents-folder orchestrator — routes to audit, cleanup, prepare
3
+ description: Agent-layer orchestrator — routes to init, optimize, audit. Covers AGENTS.md and its multi-tool stubs (CLAUDE.md, GEMINI.md, copilot-instructions.md, .cursorrules).
4
4
  cluster: agents
5
5
  disable-model-invocation: true
6
6
  suggestion:
7
7
  eligible: true
8
- trigger_description: "audit agents folder, prepare agents structure, clean up agent docs"
9
- trigger_context: "user wants to inspect, scaffold, or curate the agents/ tree"
8
+ trigger_description: "initialize agent layer, optimize AGENTS.md, audit agent infrastructure, AGENTS.md health-check"
9
+ trigger_context: "user wants to bootstrap, refactor, or health-check the agent layer (AGENTS.md + tool stubs + rules + skills)"
10
10
  ---
11
11
 
12
12
  # /agents
13
13
 
14
- Top-level orchestrator for the `/agents` family. Replaces 3 standalone
15
- commands with a single entry point + sub-command dispatch.
14
+ Top-level orchestrator for the `/agents` family the **file-family
15
+ cluster**: `AGENTS.md`, its multi-tool stubs (`CLAUDE.md`, `GEMINI.md`,
16
+ `.github/copilot-instructions.md`, `.cursorrules`), and the surrounding
17
+ agent infrastructure (rules, skills, pointers).
18
+
19
+ > Looking for `agents/` folder operations (scaffold, folder-audit,
20
+ > folder-cleanup)? Those live under [`/optimize agents-dir`](optimize/agents-dir.md).
16
21
 
17
22
  ## Sub-commands
18
23
 
19
24
  | Sub-command | Routes to | Purpose |
20
25
  |---|---|---|
21
- | `/agents audit` | `commands/agents/audit.md` | Audit `agents/` for outdated docs, duplicates, orphaned overrides |
22
- | `/agents cleanup` | `commands/agents/cleanup.md` | Execute cleanup actions from a prior audit |
23
- | `/agents prepare` | `commands/agents/prepare.md` | Scaffold the `agents/` directory structure |
26
+ | `/agents init` | `commands/agents/init.md` | Bootstrap the agent layer — create `AGENTS.md` + tool stubs from the canonical template |
27
+ | `/agents optimize` | `commands/agents/optimize.md` | Refactor `AGENTS.md` to the Thin-Root contract; propagate to multi-tool stubs |
28
+ | `/agents audit` | `commands/agents/audit.md` | Read-only health check token overhead, rule triggers, AGENTS.md health, stale references |
24
29
 
25
30
  Sub-command names match the locked contract in
26
31
  [`docs/contracts/command-clusters.md`](../docs/contracts/command-clusters.md).
@@ -29,13 +34,13 @@ Sub-command names match the locked contract in
29
34
 
30
35
  1. Parse the user's argument: `/agents <sub-command> [args]`.
31
36
  2. Look up the sub-command in the table above.
32
- 3. Load the body of the routed file and follow its `## Instructions` section
37
+ 3. Load the body of the routed file and follow its `## Steps` section
33
38
  verbatim with the remaining args.
34
39
  4. If the sub-command is unknown or missing, print the table above and ask:
35
40
 
36
- > 1. auditfind outdated docs, duplicates, orphaned overrides
37
- > 2. cleanupexecute actions from a prior audit
38
- > 3. preparescaffold the agents/ tree
41
+ > 1. initbootstrap AGENTS.md + tool stubs
42
+ > 2. optimizerefactor AGENTS.md to the Thin-Root contract
43
+ > 3. auditread-only health check on the agent layer
39
44
 
40
45
  ## Rules
41
46
 
@@ -44,3 +49,5 @@ Sub-command names match the locked contract in
44
49
  - **Do NOT chain sub-commands.** One `/agents <sub>` per turn.
45
50
  - If the user invokes `/agents` with no argument, **show the menu** — do
46
51
  not guess which sub-command they meant.
52
+ - **Edit `.agent-src.uncompressed/` only.** `.agent-src/` and `.augment/`
53
+ regenerate from source.
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: optimize:agents-dir
3
+ cluster: optimize
4
+ sub: agents-dir
5
+ description: Manage the agents/ directory — scaffold, folder-audit, fix. Single command with three modes (--scaffold / --audit / --fix); default = interactive wizard.
6
+ skills: [agents-audit, agent-docs-writing, override-management, module-management]
7
+ disable-model-invocation: true
8
+ suggestion:
9
+ eligible: true
10
+ trigger_description: "scaffold agents folder, audit agents directory, fix agents docs, clean up overrides, prepare module agents"
11
+ trigger_context: "user wants to inspect, scaffold, or curate the agents/ tree (NOT AGENTS.md — that's /agents)"
12
+ ---
13
+
14
+ # /optimize agents-dir
15
+
16
+ One command for everything that touches the **`agents/` folder** — the
17
+ project's prose layer (features, contexts, roadmaps, overrides) and the
18
+ mirror dirs under `app/Modules/*/agents/`. Replaces the legacy three-leaf
19
+ surface (`/agents prepare` + `/agents audit` + `/agents cleanup`) with
20
+ one entry-point and three explicit modes.
21
+
22
+ > **Not for `AGENTS.md`** — the root-level Markdown file and its tool
23
+ > stubs (`CLAUDE.md`, `GEMINI.md`, `copilot-instructions.md`) live under
24
+ > [`/agents`](../agents.md) (`init / optimize / audit`).
25
+
26
+ ## Modes
27
+
28
+ | Flag | Mode | Was | What it does |
29
+ |---|---|---|---|
30
+ | `--scaffold` | scaffold | `/agents prepare` | Create `agents/`, `agents/features/`, `agents/contexts/`, `agents/roadmaps/`, module mirrors, `.gitkeep` files |
31
+ | `--audit` | folder-audit | `/agents audit` | Read-only inventory of `agents/`, module agents, overrides; flag duplicates, orphans, structural drift |
32
+ | `--fix` | fix | `/agents cleanup` | Execute actions from a prior `--audit` (or roadmap) — move, merge, delete, update; per-action confirmation |
33
+
34
+ **No flag → interactive wizard.** Print the table above, ask:
35
+
36
+ ```
37
+ > 1. scaffold — set up the agents/ tree (first-time setup)
38
+ > 2. audit — inventory and find issues
39
+ > 3. fix — execute actions from a prior audit
40
+ ```
41
+
42
+ ## Mode dispatch
43
+
44
+ After a mode is selected, follow the matching procedure verbatim. Each
45
+ mode preserves the behavior of the old leaf command exactly — only the
46
+ surface changes.
47
+
48
+ ### `--scaffold` (was `/agents prepare`)
49
+
50
+ 1. **Verify project root** — look for `composer.json`, `artisan`, or `package.json`.
51
+ 2. **Create directory structure** — `agents/{roadmaps,features,contexts}/.gitkeep` + `.augment/guidelines/php/.gitkeep`. Skip dirs that already exist with content.
52
+ 3. **Module support** — if `app/Modules/` exists, mirror the layout in every module: `app/Modules/{Module}/agents/{roadmaps,features,contexts}/.gitkeep`.
53
+ 4. **Verify templates** — confirm `.augment/templates/{features,roadmaps,contexts}.md` exist; warn on missing.
54
+ 5. **Clean up old templates** — offer to delete legacy `agents/features/template.md` etc. (now in `.augment/templates/`); ask before delete.
55
+ 6. **Show summary** — table with status per directory and template; flag missing as `⚠️`.
56
+
57
+ **Rules:** never overwrite existing files; only add `.gitkeep` to truly empty dirs; ask before deleting old templates.
58
+
59
+ ### `--audit` (was the folder side of `/agents audit`)
60
+
61
+ 1. **Inventory all agent docs** — `find agents/ -maxdepth 1`, `agents/features/`, `agents/contexts/`, `agents/overrides/`, `.augment/guidelines/`, `app/Modules/*/agents/`. For each: filename, first heading, size, last `git log` date.
62
+ 2. **Module coverage** — for every `app/Modules/*/`: docs count, presence of description file, features dir, contexts dir; flag inactive modules with no docs as `🔵 Info` only.
63
+ 3. **Scan overrides** — for every `agents/overrides/*.md`: extract `Mode:` (`extend`/`replace`) and `Original:` headers; check the original file exists; flag orphans.
64
+ 4. **Classify documents** — `Architecture / Convention / Pattern / Feature / Context / Module Doc / Override / Unclear`.
65
+ 5. **Detect issues**:
66
+ - Structural — files in wrong dirs, naming inconsistencies, kebab-case violations.
67
+ - Content — verify class/method/path references against the actual codebase via `codebase-retrieval` or file checks; flag stale references.
68
+ - Duplication — `agents/` ↔ `.augment/skills/`, root ↔ `.augment/guidelines/`, root ↔ module docs.
69
+ - Coverage gaps — active modules without docs, complex areas without contexts.
70
+ 6. **Display audit report** — sectioned table (Inventory · Module Agents · Overrides · Issues · Duplicates · Gaps) with severity buckets `🔴 Critical`, `🟡 Warning`, `🔵 Info`, `⚪ Clean`.
71
+ 7. **Offer improvement roadmap**:
72
+ ```
73
+ > 1. Yes — create agents/roadmaps/agents-cleanup.md
74
+ > 2. Show recommendations only (no file)
75
+ > 3. No — audit was enough
76
+ ```
77
+ Roadmap phases: critical fixes → structural cleanup → fill gaps → cleanup.
78
+ 8. **Offer next steps** — `/optimize agents-dir --fix`, `/context refactor`, or done.
79
+
80
+ **Rules:** read-only — no file edits; do NOT audit `agents/roadmaps/` or `app/Modules/*/agents/roadmaps/` (separate lifecycle); do NOT audit `.augment/` (route to `/agents audit`); be specific (file, reference, what's wrong); don't flag inactive modules.
81
+
82
+ ### `--fix` (was `/agents cleanup`)
83
+
84
+ 1. **Locate the audit roadmap** — most recent `agents/roadmaps/road-to-agents-cleanup*.md` (or named cleanup roadmap from a prior `--audit` run). Missing → recommend `/optimize agents-dir --audit` first; allow `--ad-hoc` only on explicit override.
85
+ 2. **Show action plan** — phases from the roadmap (Critical fixes · Structural cleanup · Fill gaps · Cleanup) with action counts; ask which phase to start.
86
+ 3. **Execute actions** — for each: per-action confirmation, then run the matching workflow:
87
+ - **Move** — move file + update references in `.augment/` skills/commands and other docs.
88
+ - **Merge** — preview merged content, confirm, write merged file, delete originals, update references.
89
+ - **Delete** — preview file, confirm, delete, scrub references.
90
+ - **Update** — apply explicit content changes (remove stale refs, refresh sections, add missing info).
91
+ - **Create context** — hand off to `/context create` with area pre-selected.
92
+ 4. **Update roadmap progress** — flip `[ ]` → `[x]` after each action; show progress bar. Per `verbosity.routine_confirmations`: `false` → continue silently, user can interrupt; `true` → confirm next.
93
+ 5. **Summary** — gated by `verbosity.post_action_reports` (`off` / `minimal` / `full`); minimal = one line counts (moved · merged · deleted · updated · remaining).
94
+
95
+ **Rules:** confirm before every destructive action; always update references when moving/renaming; update the roadmap after each completed action; show file content before delete; check `.augment/` references too.
96
+
97
+ ## What this command does NOT do
98
+
99
+ - **No edits to `AGENTS.md`** or its tool stubs — that's [`/agents optimize`](../agents/optimize.md).
100
+ - **No edits to rules / skills / `.augment/`** — that's [`/agents audit`](../agents/audit.md), `/optimize skills`, or `skill-reviewer`.
101
+ - **No commits, no push, no PR** — finishing is a user decision per
102
+ [`commit-policy`](../../rules/commit-policy.md).
103
+ - **No edits to `.agent-src/` or `.augment/`** — those regenerate from
104
+ `.agent-src.uncompressed/`. Edit the source.
105
+
106
+ ## See also
107
+
108
+ - [`/agents`](../agents.md) — `init / optimize / audit` for `AGENTS.md` and tool stubs.
109
+ - [`agent-docs-writing`](../../skills/agent-docs-writing/SKILL.md) — voice, structure, anchor conventions for prose under `agents/`.
110
+ - [`agents-audit`](../../skills/agents-audit/SKILL.md) — folder-audit heuristics and severity matrix.
111
+ - [`override-management`](../../skills/override-management/SKILL.md) — `extend` vs `replace` semantics and orphan detection.
@@ -1,25 +1,27 @@
1
1
  ---
2
2
  name: optimize
3
- description: Optimize orchestrator — routes to skills, agents, augmentignore, rtk-filters
3
+ description: Optimize orchestrator — routes to skills, agents-dir, augmentignore, rtk-filters
4
4
  cluster: optimize
5
5
  disable-model-invocation: true
6
6
  suggestion:
7
7
  eligible: true
8
- trigger_description: "optimize my skills, audit agents, tune augmentignore, optimize rtk filters"
9
- trigger_context: "maintainer auditing or trimming agent infrastructure"
8
+ trigger_description: "optimize my skills, manage agents directory, tune augmentignore, optimize rtk filters"
9
+ trigger_context: "maintainer auditing or trimming the agent layer (NOT AGENTS.md — that's /agents)"
10
10
  ---
11
11
 
12
12
  # /optimize
13
13
 
14
- Top-level orchestrator for the `/optimize` family. Replaces 4 standalone
15
- commands with a single entry point + sub-command dispatch.
14
+ Top-level orchestrator for the `/optimize` family.
15
+
16
+ > Looking for `AGENTS.md` operations (init, refactor, audit)? Those
17
+ > live under [`/agents`](agents.md) (`init / optimize / audit`).
16
18
 
17
19
  ## Sub-commands
18
20
 
19
21
  | Sub-command | Routes to | Purpose |
20
22
  |---|---|---|
21
23
  | `/optimize skills` | `commands/optimize/skills.md` | Audit skills — measure baseline, find duplicates, run linter |
22
- | `/optimize agents` | `commands/optimize/agents.md` | Audit agent infrastructuretoken overhead, rule triggers, AGENTS.md |
24
+ | `/optimize agents-dir` | `commands/optimize/agents-dir.md` | Manage the `agents/` directory `--scaffold` / `--audit` / `--fix` (interactive wizard if no flag) |
23
25
  | `/optimize augmentignore` | `commands/optimize/augmentignore.md` | Create or refine `.augmentignore` based on actual stack |
24
26
  | `/optimize rtk` | `commands/optimize/rtk.md` | Create or refine project-local rtk filters |
25
27
 
@@ -30,12 +32,12 @@ Sub-command names match the locked contract in
30
32
 
31
33
  1. Parse the user's argument: `/optimize <sub-command> [args]`.
32
34
  2. Look up the sub-command in the table above.
33
- 3. Load the body of the corresponding `commands/optimize-<sub>.md` file and
35
+ 3. Load the body of the corresponding `commands/optimize/<sub>.md` file and
34
36
  follow its `## Steps` (or `## Instructions`) section verbatim.
35
37
  4. If the sub-command is unknown or missing, print the menu and ask:
36
38
 
37
39
  > 1. skills — audit skills (find duplicates, run linter)
38
- > 2. agents — audit agent infrastructure (token overhead, rule triggers)
40
+ > 2. agents-dirscaffold / audit / fix the `agents/` tree
39
41
  > 3. augmentignore — create or refine `.augmentignore`
40
42
  > 4. rtk — create or refine project-local rtk filters
41
43
 
@@ -5,6 +5,12 @@ Full table of available coding guidelines for the
5
5
  holds the obligation surface (always check the relevant guideline
6
6
  before writing or reviewing code); this file is the catalog.
7
7
 
8
+ ## Universal (`docs/guidelines/`)
9
+
10
+ | File | Topic |
11
+ |---|---|
12
+ | `code-clarity.md` | Cross-language clarity rules — inline single-use values, carve-outs (side effects, loops, type narrowing, debugger) |
13
+
8
14
  ## PHP (`docs/guidelines/php/`)
9
15
 
10
16
  | File | Topic |
@@ -4,7 +4,7 @@ Lookup table for the `slash-command-routing-policy` rule. Lists the
4
4
  locked clusters and their sub-commands so the rule itself can stay at
5
5
  its current LOC while still reflecting the full surface. Source of
6
6
  truth for the cluster names is
7
- [`docs/contracts/command-clusters.md`](../../../../../docs/contracts/command-clusters.md);
7
+ [`docs/contracts/command-clusters.md`](../../../../../../docs/contracts/command-clusters.md);
8
8
  this file mirrors that contract for runtime lookup. Linter:
9
9
  `scripts/check_cluster_patterns.py` (verifies dispatcher shape).
10
10
 
@@ -16,14 +16,13 @@ this file mirrors that contract for runtime lookup. Linter:
16
16
  | `/optimize` | 1 | `agents` · `augmentignore` · `rtk` · `skills` | `/optimize-agents` · `/optimize-augmentignore` · `/optimize-rtk-filters` · `/optimize-skills` |
17
17
  | `/feature` | 1 | `explore` · `plan` · `refactor` · `roadmap` | `/feature-explore` · `/feature-plan` · `/feature-refactor` · `/feature-roadmap` |
18
18
  | `/chat-history` | 2 | `show` | `/chat-history` (legacy status) — `resume` / `clear` / `checkpoint` removed in `road-to-chat-history-hook-only` |
19
- | `/agents` | 2 | `audit` · `cleanup` · `prepare` | `/agents-audit` · `/agents-cleanup` · `/agents-prepare` |
19
+ | `/agents` | 2 | `init` · `optimize` · `audit` | `/copilot-agents-init` · merger of `/optimize-agents-md` + `/copilot-agents-optimize` · `/optimize-agents` (folder ops moved to `/optimize:agents-dir`) |
20
20
  | `/memory` | 2 | `add` · `load` · `promote` · `propose` | `/memory-add` · `/memory-full` · `/memory-promote` · `/propose-memory` |
21
21
  | `/roadmap` | 2 | `create` · `process-step` · `process-phase` · `process-full` | `/roadmap-create` · `/roadmap-process` (replaced — autonomous, no per-step gate; `process-phase` is the default execution scope) |
22
22
  | `/module` | 2 | `create` · `explore` | `/module-create` · `/module-explore` |
23
23
  | `/tests` | 2 | `create` · `execute` | `/tests-create` · `/tests-execute` |
24
24
  | `/context` | 2 | `create` · `refactor` | `/context-create` · `/context-refactor` |
25
25
  | `/override` | 2 | `create` · `manage` | `/override-create` · `/override-manage` |
26
- | `/copilot-agents` | 2 | `init` · `optimize` | `/copilot-agents-init` · `/copilot-agents-optimize` |
27
26
  | `/judge` | 2 | `solo` · `on-diff` · `steps` | `/judge` (legacy standalone) · `/do-and-judge` · `/do-in-steps` |
28
27
  | `/commit` | 2 | flag: `--in-chunks` | `/commit:in-chunks` |
29
28
  | `/create-pr` | 2 | flag: `--description-only` | `/create-pr:description-only` |
@@ -0,0 +1,132 @@
1
+ # AGENTS.md Anatomy — outboard reference
2
+
3
+ > Companion context to the
4
+ > [`agents-md-thin-root`](../../skills/agents-md-thin-root/SKILL.md)
5
+ > skill. Holds the long-form anatomy guidance that does not fit
6
+ > inside the skill body without breaching its size budget.
7
+
8
+ ## Iron Law — Capabilities over Structure
9
+
10
+ Every entry in AGENTS.md describes **what the project can do** or
11
+ **where to learn more**, never **where individual files live**.
12
+
13
+ ```
14
+ A FILE PATH WITHOUT A WHY-CLAUSE IS DEAD WEIGHT.
15
+ PATH ENUMERATION (≥ 3 PATHS WITHOUT POINTERS) IS A LINT WARNING.
16
+ ```
17
+
18
+ Path lists rot every refactor; capability lists survive structural
19
+ churn because they describe intent. Concrete substitutions:
20
+
21
+ | Anti-pattern (path enumeration) | Capability rewrite |
22
+ |---|---|
23
+ | `- src/auth/`<br>`- src/auth/jwt.ts`<br>`- src/auth/middleware.ts` | `- **Authentication** — OAuth + JWT session handling: [`src/auth/`](src/auth/)` |
24
+ | `- packages/payments/`<br>`- packages/billing/` | `- **Billing** — Stripe Checkout + invoice generation, dunning + tax: [`docs/billing.md`](docs/billing.md)` |
25
+ | Three bullets listing test directories | One pointer to the testing strategy doc with a *why*-clause |
26
+
27
+ A pointer is **substantive** only if its surrounding sentence carries
28
+ a *why*-clause ≥ 60 chars. Bare paths get filtered out by the lint.
29
+
30
+ ## 1-liner project description slot
31
+
32
+ The first prose line under the project title is the **only place** the
33
+ agent learns what the repo is in one sentence when retrieval is
34
+ degraded. Required content:
35
+
36
+ ```
37
+ > {What it is} — {primary capability} for {audience}, {differentiator}.
38
+ ```
39
+
40
+ ✅ Right: `> Multi-tenant SaaS billing — Stripe-backed subscription
41
+ and invoicing for B2B sellers, audit-grade ledger.`
42
+ ❌ Wrong: `> A modern web app built with Next.js and TypeScript.`
43
+ (stack ≠ capability; an agent already knows what those are.)
44
+
45
+ ## Multi-tool symlink strategy
46
+
47
+ `AGENTS.md` is the canonical entry point. Tool-specific files
48
+ (`CLAUDE.md`, `GEMINI.md`, `.cursorrules`, `.windsurfrules`) point at
49
+ the same content via a symlink-or-stub pattern. Two acceptable shapes:
50
+
51
+ **Symlink** (POSIX, monorepo-friendly):
52
+
53
+ ```bash
54
+ ln -s AGENTS.md CLAUDE.md
55
+ ln -s AGENTS.md GEMINI.md
56
+ ln -s AGENTS.md .cursorrules
57
+ ```
58
+
59
+ **Stub** (Windows-safe, generation-pipeline-friendly):
60
+
61
+ ```markdown
62
+ <!-- CLAUDE.md -->
63
+ > See [`AGENTS.md`](AGENTS.md) — single source of truth for agent
64
+ > instructions in this repo.
65
+ ```
66
+
67
+ Do not duplicate AGENTS.md content into the tool-specific files; the
68
+ agent ends up with two diverging versions and the budget is paid
69
+ twice. The package's `task generate-tools` pipeline produces stubs
70
+ deterministically — never hand-edit them.
71
+
72
+ ## Monorepo — per-package AGENTS.md
73
+
74
+ Each top-level package (or app, depending on layout) gets its own
75
+ `AGENTS.md` at the package root, **not** a section inside the
76
+ monorepo-root file. Why:
77
+
78
+ 1. Agents working in `packages/foo/` retrieve the nearest `AGENTS.md`
79
+ first — irrelevant siblings stay out of the budget.
80
+ 2. The monorepo-root `AGENTS.md` becomes a navigation surface that
81
+ points at each package's entry, capability-style:
82
+ `- **Web app** — Next.js storefront and customer dashboard:
83
+ [`apps/web/AGENTS.md`](apps/web/AGENTS.md)`.
84
+ 3. Per-package emergency-triage blocks answer the five canonical
85
+ questions in the package's local idiom (own lint / test entry,
86
+ own source-of-truth path).
87
+
88
+ Anti-pattern: a single 6 KB monorepo `AGENTS.md` with five
89
+ package-specific sections. Spend lives in the wrong budget and every
90
+ package edit touches the same hot file.
91
+
92
+ ## Refactor recipe — bloated AGENTS.md → Thin-Root
93
+
94
+ 1. **Snapshot.** `wc -c AGENTS.md` and stash a copy of the
95
+ pre-refactor file (e.g. `AGENTS.md.before` in your scratch dir)
96
+ so you can diff before / after.
97
+ 2. **Section inventory.** List every `## ` heading + its char-count.
98
+ Mark `keep-inline` (Iron-Law-adjacent, ≤ 200 chars) vs.
99
+ `outboard-candidate`.
100
+ 3. **Path-enumeration sweep.** Find every line that is just a path
101
+ inside backticks with no *why*-clause; collapse runs of three or
102
+ more into a single capability pointer.
103
+ 4. **Outboard.** Move each `outboard-candidate` into
104
+ `agents/contexts/`, `docs/contracts/`, an existing rule body, or
105
+ an existing skill body. Replace in-file with a substantive
106
+ pointer. Never invent a new top-level dir.
107
+ 5. **Verify.** Run `python3 scripts/lint_agents_md.py` until green;
108
+ `wc -c AGENTS.md` ≤ target cap; emergency-triage block intact.
109
+
110
+ ## Common gotchas
111
+
112
+ - **"Quick reference" sections.** A two-line table of common commands
113
+ feels useful but doubles every package release. Outboard to the
114
+ README's quickstart and link with one pointer.
115
+ - **Tech-stack dumps.** "We use React, Tailwind, tRPC, Postgres, …"
116
+ costs budget without unblocking decisions. Move to a single
117
+ `## Stack` pointer at `docs/architecture.md#stack`.
118
+ - **Roadmap snippets.** Roadmaps move every sprint; pin the agent to
119
+ the directory (`agents/roadmaps/`) and let it discover the active
120
+ one rather than naming the current file.
121
+ - **Per-feature subsections.** "How auth works", "How billing works"
122
+ belong in capability docs, not in the root entry. AGENTS.md
123
+ references them with one *why*-clause line each.
124
+
125
+ ## See also
126
+
127
+ - [`agents-md-thin-root`](../../skills/agents-md-thin-root/SKILL.md)
128
+ — caps, pointer-ratio, pointer-anatomy, emergency-triage contract.
129
+ - [`emergency-triage-block`](emergency-triage-block.md) — canonical
130
+ source for the five-question block both AGENTS.md variants embed.
131
+ - [`consumer-agents-md-guide`](consumer-agents-md-guide.md) — section
132
+ templates a consumer fills in after install.
@@ -31,6 +31,10 @@ Use when:
31
31
 
32
32
  Augment Code injects `AGENTS.md` verbatim into every workspace prompt. Each kilobyte spent here permanently consumes the 49,512-char workspace-guidelines budget shared with always-rules and auto-rule registry stubs. The Thin-Root pattern keeps the entry point a navigation surface (pointers + intent) and pushes deep detail into files Augment loads on demand via `load_context` or that other tools fetch only when their search retrieves them. Strategic council R2 (2026-05-08, Sonnet 4.5 / Opus 4.1 / gpt-4o / o1) converged on the contract codified below as the minimum guard against AGENTS.md re-bloat.
33
33
 
34
+ ## Iron Law — Capabilities over Structure
35
+
36
+ Every entry describes **what** the project does or **where** to learn more — never **where** individual files live. Path lists rot every refactor and poison context; capability pointers survive structural churn. Full anatomy with rewrite recipes, monorepo guidance, and multi-tool symlink strategy: [`agents-md-anatomy`](../../contexts/contracts/agents-md-anatomy.md).
37
+
34
38
  ## The contract — hard caps
35
39
 
36
40
  | File | FAIL above | WARN above | Target |
@@ -106,6 +110,8 @@ Same procedure, applied to `.agent-src.uncompressed/templates/AGENTS.md`. Hard c
106
110
  - **Emergency-triage drift.** Editing the in-file emergency-triage block instead of the canonical `.agent-src.uncompressed/contexts/contracts/emergency-triage-block.md` causes the package-root and consumer-template versions to diverge silently. Always edit the canonical file and let the lint diff pull both back in sync.
107
111
  - **Cap inversion under WARN.** A 2,250-char AGENTS.md (above 2,200 WARN, below 2,500 FAIL) is a yellow signal not a green one — every additional sentence raises the probability of the next FAIL. Treat WARN as the spend boundary, not a buffer.
108
112
  - **Char-count includes frontmatter.** `wc -c` counts every byte including the YAML preamble, blank lines, and the trailing newline. Stripping a section to "look smaller" without re-running `wc -c` understates the true budget impact.
113
+ - **Path enumeration.** A run of three or more bare `` `path/to/dir/` `` bullets without *why*-clauses is the classic re-bloat pattern. The lint emits a WARN at ≥ 3 such lines. Collapse them into one capability-style pointer — see the recipe in [`agents-md-anatomy § Iron Law`](../../contexts/contracts/agents-md-anatomy.md#iron-law--capabilities-over-structure).
114
+ - **Tool-specific duplicates.** Copy-pasting AGENTS.md into `CLAUDE.md` / `GEMINI.md` / `.cursorrules` doubles the budget cost across tools. Use the symlink-or-stub pattern in [`agents-md-anatomy § Multi-tool symlink strategy`](../../contexts/contracts/agents-md-anatomy.md#multi-tool-symlink-strategy) instead.
109
115
 
110
116
  ## Output format
111
117
 
@@ -119,7 +125,8 @@ When invoked as a planning step, produce:
119
125
 
120
126
  ## See also
121
127
 
122
- - [`copilot-agents-optimization`](../copilot-agents-optimization/SKILL.md) — sibling skill for `.github/copilot-instructions.md`; runs alongside Thin-Root in `/optimize/agents`.
128
+ - [`agents-md-anatomy`](../../contexts/contracts/agents-md-anatomy.md) — Capabilities-over-Structure Iron Law, multi-tool symlink strategy, monorepo per-package layout, refactor recipe, full gotcha catalog.
129
+ - [`copilot-agents-optimization`](../copilot-agents-optimization/SKILL.md) — sibling skill for `.github/copilot-instructions.md`; runs alongside Thin-Root in `/agents optimize`.
123
130
  - [`agent-docs-writing`](../agent-docs-writing/SKILL.md) — broader documentation-structure context for navigating outboard targets.
124
131
  - [`size-enforcement`](../../rules/size-enforcement.md) — covers per-skill / per-rule / per-command size budgets; AGENTS.md caps live in this skill instead.
125
132
  - [`ADR-004-rule-governance-pruning`](../../../docs/decisions/ADR-004-rule-governance-pruning.md) — captures the rule-governance pruning that freed the workspace-guidelines budget; the Thin-Root caps build on that headroom.
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: async-python-patterns
3
+ description: "Use when writing Python asyncio code — picking between gather / TaskGroup / wait, structured concurrency, timeouts, cancellation, sync-bridging — decision framework only, cookbook externalized."
4
+ source: package
5
+ status: active
6
+ refresh_trigger: "Python ships a new structured-concurrency primitive (post-TaskGroup), OR ≥30% of cited upstream cookbook examples become deprecated, OR the cited libraries (aiohttp, httpx, anyio, trio) cut a major version with breaking async surface changes."
7
+ sunset_criterion: "When `https://docs.python.org/3/library/asyncio.html` ships an in-tree decision framework AND consumer projects no longer cite this skill in PR reviews for two consecutive review cycles."
8
+ ---
9
+
10
+ # async-python-patterns
11
+
12
+ Decision framework for picking the right Python asyncio primitive. **The pattern cookbook lives upstream** (links in § Provenance) — this skill is the predicate, not the recipe library. Sunset-policy compliant: the 600+ lines of language-specific cookbook stay in authoritative Python docs.
13
+
14
+ ## When to use
15
+
16
+ - Designing a new async I/O-bound service (FastAPI, aiohttp, async DB client).
17
+ - Reviewing a diff that introduces `asyncio.gather`, `asyncio.create_task`, `TaskGroup`, `as_completed`, or `wait_for`.
18
+ - Mixing sync and async code (calling sync libs from async context, or vice versa).
19
+ - Diagnosing event-loop blocking, never-awaited warnings, or cancellation leaks.
20
+
21
+ Do NOT use when:
22
+
23
+ - The work is CPU-bound — async will not help; route to multiprocessing or threadpool.
24
+ - The runtime is not Python — read the host runtime's concurrency guide.
25
+ - The fix is a single missing `await` — read the upstream tutorial directly.
26
+
27
+ ## Decision framework
28
+
29
+ ### Step 1 — Verify async is the right tool
30
+
31
+ ```
32
+ Workload is:
33
+ I/O-bound, many concurrent waits → async fits (network, disk, IPC).
34
+ CPU-bound (parsing, math, crypto) → async is wrong; use ProcessPoolExecutor.
35
+ Mixed → async shell + run_in_executor for CPU bursts.
36
+ Single sequential call → don't introduce async; sync is simpler.
37
+ ```
38
+
39
+ ### Step 2 — Pick the concurrency primitive
40
+
41
+ ```
42
+ Run N independent coroutines, ALL must complete:
43
+ Same trust level, exceptions cancel siblings → asyncio.TaskGroup (3.11+; preferred).
44
+ Pre-3.11 OR exceptions must NOT cancel peers → asyncio.gather(*, return_exceptions=...).
45
+
46
+ Run N coroutines, react to results as they finish:
47
+ → asyncio.as_completed (yields completed futures in finish order).
48
+
49
+ Run N coroutines, race to first success / failure:
50
+ → asyncio.wait(..., return_when=FIRST_COMPLETED) + cancel pending.
51
+
52
+ Schedule fire-and-forget background work:
53
+ → asyncio.create_task + keep a strong reference (else GC eats it).
54
+ Forgetting the reference is the #1 silent-failure source.
55
+
56
+ Bound the wait time:
57
+ → asyncio.wait_for(coro, timeout=...) → raises TimeoutError on expiry.
58
+ → asyncio.timeout(...) context manager (3.11+; preferred when many awaits share a deadline).
59
+
60
+ Bound concurrency (rate-limit, connection pool):
61
+ → asyncio.Semaphore(n); acquire around the awaitable.
62
+ ```
63
+
64
+ ### Step 3 — Bridge sync ↔ async correctly
65
+
66
+ ```
67
+ Async code calls sync, blocking, function:
68
+ Short pure-CPU → fine, accept the block (microseconds).
69
+ Long, blocking, or I/O-sync → await loop.run_in_executor(None, fn, *args).
70
+ Library has async sibling → switch the library (httpx vs requests, aiosqlite vs sqlite3).
71
+
72
+ Sync code calls async function:
73
+ Top-level entrypoint → asyncio.run(coro()).
74
+ Inside running loop → never asyncio.run; create_task + await it.
75
+ Test suite → pytest-asyncio fixture; never raw run() in tests.
76
+ ```
77
+
78
+ ### Step 4 — Cancellation discipline
79
+
80
+ Every long-running coroutine MUST be cancellation-safe:
81
+
82
+ - Catch `asyncio.CancelledError`, perform cleanup, **re-raise**. Swallowing it silently breaks the propagation chain.
83
+ - Use `try / finally` (or `async with`) around resource acquisition so cancellation cannot leak file handles, DB connections, locks.
84
+ - Detached `create_task` without a strong reference is undefined behavior; either store the task or use a TaskGroup.
85
+
86
+ ### Step 5 — Don't block the event loop
87
+
88
+ A single blocking call (sync I/O, time.sleep, CPU-heavy parse, large JSON load) freezes every coroutine. Audit every leaf function under `async def`:
89
+
90
+ - Sleep → `await asyncio.sleep`, never `time.sleep`.
91
+ - HTTP → `httpx.AsyncClient` / `aiohttp`, never `requests`.
92
+ - DB → `asyncpg` / `aiosqlite` / `motor`, never the sync driver.
93
+ - File → `aiofiles` for hot-paths, or `run_in_executor` for one-shots.
94
+
95
+ ## Procedure: Apply to a new async feature
96
+
97
+ 1. Run Step 1; reject if work is CPU-bound.
98
+ 2. Sketch the call graph; tag each `await` site with its primitive (Step 2).
99
+ 3. Mark every sync↔async boundary; pick the bridge per Step 3.
100
+ 4. For each long-running coroutine, write the cancel-safety contract (Step 4).
101
+ 5. Grep the leaf calls for blocking sins (Step 5); replace or push to executor.
102
+ 6. Hand the sketch to a reviewer **before** coding; cite this skill.
103
+
104
+ ## Output format
105
+
106
+ 1. Call-graph table: coroutine · concurrency primitive · timeout · cancel-safety note.
107
+ 2. Sync↔async boundary list: site · bridge · justification.
108
+ 3. Blocking-call audit: leaf function · status (async / executor / accepted-block + reason).
109
+ 4. Cancel-safety contract for each background task.
110
+
111
+ ## Gotcha
112
+
113
+ - "It works in my REPL" — `asyncio.run` inside an already-running loop (Jupyter, FastAPI startup) raises `RuntimeError`. Use `await` directly or `nest_asyncio` (last resort).
114
+ - `asyncio.gather` swallows the second exception silently; use `return_exceptions=True` and inspect, or use `TaskGroup` (cancels all on first error, surfaces the group).
115
+ - `create_task` results that nobody awaits look fine until the program exits and Python prints `Task was destroyed but it is pending!`. Always `await` or use a TaskGroup.
116
+ - `wait_for` on a non-cancellation-safe coroutine leaks resources; the timeout cancels the task but cleanup never runs.
117
+ - Libraries that "support async" via thread pools (e.g. `requests-async`) often re-block the loop under load; verify with the cited upstream library docs, not the README.
118
+
119
+ ## Do NOT
120
+
121
+ - Do NOT call `asyncio.run` from a running loop.
122
+ - Do NOT swallow `CancelledError` without re-raising.
123
+ - Do NOT call sync blocking I/O from async paths without `run_in_executor`.
124
+ - Do NOT spawn `create_task` without storing the reference (or using TaskGroup).
125
+ - Do NOT inline the asyncio cookbook into this skill — externalize per Sunset Policy.
126
+
127
+ ## Auto-trigger keywords
128
+
129
+ - asyncio
130
+ - async / await
131
+ - gather / TaskGroup / wait_for
132
+ - event loop blocking
133
+ - cancellation
134
+ - sync to async bridge
135
+
136
+ ## Provenance
137
+
138
+ - Adopted from: `Microck/ordinary-claude-skills@8f5c83174f7aa683b4ddc7433150471983b93131:skills_all/async-python-patterns/SKILL.md` (MIT, © 2025 Microck) — **Sunset Policy applied**: 694-line cookbook source reduced to a ~140-line decision framework; pattern catalogues externalized to upstream docs below.
139
+ - Externalized cookbook:
140
+ - asyncio core: https://docs.python.org/3/library/asyncio.html · https://docs.python.org/3/library/asyncio-task.html
141
+ - TaskGroup (3.11+): https://docs.python.org/3/library/asyncio-task.html#task-groups
142
+ - Structured concurrency: https://anyio.readthedocs.io · https://trio.readthedocs.io
143
+ - Async HTTP: https://www.python-httpx.org/async/ · https://docs.aiohttp.org/en/stable/
144
+ - Async DB: https://magicstack.github.io/asyncpg/ · https://aiosqlite.omnilib.dev/
145
+ - Cross-linked: [`error-handling-patterns`](../error-handling-patterns/SKILL.md), [`mcp-builder`](../mcp-builder/SKILL.md), [`api-design`](../api-design/SKILL.md), [`performance`](../performance/SKILL.md).
146
+ - Provenance registry: `agents/contexts/skills-provenance.yml` (entry: `async-python-patterns`).
147
+ - Iron-Law floor: `verify-before-complete`, `skill-quality`, `non-destructive-by-default`.
@@ -32,6 +32,35 @@ A command is **user-invoked** and carries `disable-model-invocation: true`.
32
32
  A skill is model-invoked via description routing. If both audiences apply,
33
33
  author as a skill and add a thin command that delegates to it.
34
34
 
35
+ ## Commands ARE Claude skills (projection reality)
36
+
37
+ Every `.agent-src.uncompressed/commands/{name}.md` projects to
38
+ `.claude/skills/{slug}/SKILL.md` via `scripts/compress.py`
39
+ (`generate_claude_commands`). Nested commands flatten with `-`
40
+ (`council/default.md` → `council-default`). Skills + commands share the
41
+ **same `.claude/skills/` namespace** — Claude does not distinguish them.
42
+
43
+ Authoring consequences:
44
+
45
+ * Frontmatter `description` is Claude's **routing surface**. Generic
46
+ phrasing → undertriggering even with `disable-model-invocation: true`,
47
+ because the in-host suggester, fuzzy search, and any tooling that
48
+ scans `.claude/skills/` ranks by description match.
49
+ * `disable-model-invocation: true` blocks **automatic** invocation only.
50
+ It does NOT remove the command from discovery surfaces. Weak
51
+ description = invisible to the suggester even when intent matches.
52
+ * Trigger phrasing follows the same Iron Law as skill descriptions:
53
+ name 2+ trigger classes (domains, symptoms, user phrasing), end with
54
+ the `... even when the user just says ...` tail, ≤ 200 chars. See
55
+ `skill-writing` § 1b for the canonical before/after.
56
+ * `suggestion.trigger_description` / `suggestion.trigger_context` are
57
+ **separate** from frontmatter `description` — they drive the in-host
58
+ suggester (`command-suggestion-policy`), not Claude's skill router.
59
+ Both matter, both must be precise.
60
+
61
+ Bottom line: write the command's `description` as if a skill router
62
+ will read it — because one will.
63
+
35
64
  ## Procedure
36
65
 
37
66
  ### 0. Run the Drafting Protocol
@@ -149,6 +178,26 @@ multi-paragraph explanation, extract it into a skill and call it.
149
178
  * Run the full CI pipeline locally (see `Taskfile.yml` in this repo for
150
179
  the script list) — must exit 0 except for tolerated warnings.
151
180
 
181
+ ### 6. Governance baseline (when introducing a new linter check)
182
+
183
+ **Advisory, reviewer-checked — no CI gate.** When the same PR adds a
184
+ new check to `scripts/skill_linter.py` (or strengthens an existing one)
185
+ such that previously-clean commands now warn, the PR body MUST record
186
+ the pre-existing violations on `main` in a Markdown table:
187
+
188
+ ```markdown
189
+ ### Pre-existing baseline (informational)
190
+
191
+ | Code | Count on main | Bucket |
192
+ |---|---:|---|
193
+ | {new_code} | N | (a) genuine fix · (b) accept · (c) check too aggressive |
194
+ ```
195
+
196
+ Forward-only: the new check applies to **the file under review** and to
197
+ **future** edits. The baseline table is informational so reviewers can
198
+ spot intent (fix-now vs. backlog) without diffing the full lint output.
199
+ See `agents/analysis/lint-warning-triage.md` for the 3-bucket reference.
200
+
152
201
  ## Output format
153
202
 
154
203
  1. Complete command file at `.agent-src.uncompressed/commands/{name}.md`