[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6M9GM3NP1Q75E8CDKN1C1W6":3,"skill-same:01M6M9GM3NP1Q75E8CDKN1C1W6":68},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":51,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M6M9GM3NP1Q75E8CDKN1C1W6","cavekit-writing",null,"How to write Cavekit-quality kits that AI agents can consume effectively. Covers\nimplementation-agnostic cavekit design, testable acceptance criteria, hierarchical structure,\ncross-referencing, cavekit templates, greenfield and rewrite patterns, cavekit compaction, and gap analysis.\nTrigger phrases: \"write kits\", \"create kits\", \"cavekit this out\",\n\"define requirements for agents\", \"how to write kits for AI\"","hashgraph-online\u002Fawesome-codex-plugins","hashgraph-online","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160371962?v=4","01M6CNB6NRJVNNGN14TR01Q6D3","HOL (Hashgraph Online)","01M6JT1HSKKG9V68KQAQGBA7XP",1575,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FJuliusBrussee\u002Fblueprint\u002Fskills\u002Fcavekit-writing\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"writing","cavekit writing","define","design","for","can","compaction","how to","rewrite","gap analysis","trigger","ai agents","requirements","structure","patterns","write","how","analysis","acceptance","create","2026-11-10 10:12:30",false,"---\nname: cavekit-writing\ndescription: |\n  How to write Cavekit-quality kits that AI agents can consume effectively. Covers\n  implementation-agnostic cavekit design, testable acceptance criteria, hierarchical structure,\n  cross-referencing, cavekit templates, greenfield and rewrite patterns, cavekit compaction, and gap analysis.\n  Trigger phrases: \"write kits\", \"create kits\", \"cavekit this out\",\n  \"define requirements for agents\", \"how to write kits for AI\"\n---\n\n# Cavekit Writing\n\n## Core Principle: Kits Describe WHAT, Not HOW\n\nKits are **implementation-agnostic**. They define what the system must do and how to verify it, but never prescribe a specific framework, language, or architecture.\n\nThis is the fundamental distinction in Cavekit:\n- **Kits** = WHAT must be true (framework-agnostic, durable, portable)\n- **Plans** = HOW to build it (framework-specific, derived from kits)\n- **Code** = the implementation (generated from plans, validated against kits)\n\n### Why Implementation-Agnostic?\n\nWhen kits avoid prescribing HOW, they become:\n- **Portable** — the same kits can drive implementations in different frameworks\n- **Durable** — kits survive technology migrations\n- **Testable** — acceptance criteria are about behavior, not implementation details\n- **Reusable** — the same kits work for greenfield, rewrites, and cross-framework evaluation\n\n**Bad cavekit requirement:** \"Use React useState hook to manage form state\"\n**Good cavekit requirement:** \"Form state persists across user interactions within a session. Acceptance: entering values, navigating away, and returning preserves all entered values.\"\n\n---\n\n## Every Requirement Needs Testable Acceptance Criteria\n\nThis is the single most important rule in Cavekit writing. If an agent cannot automatically validate a requirement, that requirement will not be met.\n\n### The Validation-First Rule\n\nEvery requirement must answer: **\"How would an automated test verify this?\"**\n\n| Weak Criterion | Strong Criterion |\n|----------------|-----------------|\n| \"UI should look good\" | \"All interactive elements have minimum 44x44px touch targets\" |\n| \"System should be fast\" | \"API responses return within 200ms at p95 under 100 concurrent users\" |\n| \"Handle errors gracefully\" | \"Network failures display a retry prompt with exponential backoff (1s, 2s, 4s)\" |\n| \"Support authentication\" | \"Valid credentials return a session token; invalid credentials return 401 with error message\" |\n\n### Acceptance Criteria Format\n\nEach criterion should be:\n- **Observable** — can be checked by reading output, UI state, or logs\n- **Deterministic** — same input always produces same pass\u002Ffail result\n- **Automatable** — an agent can write a test that checks this\n- **Independent** — does not depend on subjective judgment\n\n```markdown\n**Acceptance Criteria:**\n- [ ] {Action} results in {observable outcome}\n- [ ] Given {precondition}, when {action}, then {result}\n- [ ] {Metric} meets {threshold} under {conditions}\n```\n\n---\n\n## Hierarchical Structure with Index\n\nKits must be organized as a hierarchy — one index file linking to domain-specific sub-kits. This enables progressive disclosure: agents read the index first, then only the sub-kits relevant to their task.\n\n### The Cavekit Index Pattern\n\nCreate a `cavekit-overview.md` as the entry point:\n\n```markdown\n# Cavekit Overview\n\n## Domains\n\n| Domain | Cavekit File | Summary |\n|--------|-----------|---------|\n| Authentication | cavekit-auth.md | User registration, login, session management, OAuth |\n| Data Models | cavekit-data-models.md | Core entities, relationships, validation rules |\n| API | cavekit-api.md | REST endpoints, request\u002Fresponse formats, error handling |\n| UI Components | cavekit-ui-components.md | Shared components, accessibility, responsive behavior |\n| Notifications | cavekit-notifications.md | Email, push, in-app notification delivery |\n\n## Cross-Cutting Concerns\n- Security requirements: see cavekit-auth.md R3, cavekit-api.md R7\n- Performance budgets: see cavekit-api.md R12, cavekit-ui-components.md R5\n- Accessibility: see cavekit-ui-components.md R8-R10\n```\n\n### Why Hierarchical?\n\n1. **Context window efficiency** — agents load only the domains they need\n2. **Parallel work** — different agents can own different spec domains\n3. **Review efficiency** — humans can review domain-by-domain\n4. **Cross-referencing** — domains link to each other explicitly\n\n---\n\n## Cross-Referencing Between Kits\n\nRelated kits must link to each other. Cross-references prevent requirements from being lost at domain boundaries.\n\n### Cross-Reference Patterns\n\n```markdown\n## Cross-References\n- **Depends on:** cavekit-auth.md R1 (session tokens required for API access)\n- **Depended on by:** cavekit-notifications.md R4 (uses user preferences from this cavekit)\n- **Related:** cavekit-ui-components.md R6 (error display components used by this domain)\n```\n\n### When to Cross-Reference\n\n- When one domain's requirement depends on another domain's output\n- When shared entities are defined in one cavekit but used in many\n- When validation criteria span multiple domains\n- When out-of-scope items are in-scope for another cavekit\n\n---\n\n## Full Cavekit Format Template\n\nUse this template for every domain cavekit:\n\n```markdown\n# Cavekit: {Domain Name}\n\n## Scope\n{One paragraph describing what this spec covers and its boundaries.}\n\n## Requirements\n\n### R1: {Requirement Name}\n**Description:** {What must be true — stated in terms of behavior, not implementation.}\n**Acceptance Criteria:**\n- [ ] {Testable criterion 1}\n- [ ] {Testable criterion 2}\n- [ ] {Testable criterion 3}\n**Dependencies:** {Other specs\u002Frequirements this depends on, or \"None\"}\n\n### R2: {Requirement Name}\n**Description:** {What must be true}\n**Acceptance Criteria:**\n- [ ] {Testable criterion 1}\n- [ ] {Testable criterion 2}\n**Dependencies:** {Dependencies}\n\n### R3: ...\n\n## Out of Scope\n{Explicit list of things this cavekit does NOT cover. This is critical — it prevents\nagents from over-building and clarifies domain boundaries.}\n- {Thing explicitly excluded and why}\n- {Another exclusion}\n\n## Cross-References\n- See also: cavekit-{related-domain}.md — {why it is related}\n- Depends on: cavekit-{dependency}.md R{N} — {what is needed}\n- Depended on by: cavekit-{dependent}.md R{N} — {what depends on this}\n```\n\n### Template Rules\n\n1. **Number requirements sequentially** (R1, R2, R3...) — agents reference them by ID\n2. **Every requirement gets acceptance criteria** — no exceptions\n3. **Out of Scope is mandatory** — explicit exclusions prevent scope creep\n4. **Cross-References section is mandatory** — even if it says \"None\"\n5. **Scope section is one paragraph** — concise boundary description\n\n---\n\n## Greenfield Pattern: Reference Material → Kits\n\nWhen building from scratch, you start with reference materials and derive kits from them.\n\n### Flow\n\n```\ncontext\u002Frefs\u002F              context\u002Fkits\u002F\n├── prd.md          →      ├── cavekit-overview.md\n├── design-doc.md   →      ├── cavekit-auth.md\n├── api-draft.md    →      ├── cavekit-api.md\n└── research\u002F       →      ├── cavekit-data-models.md\n    └── ...         →      └── cavekit-ui.md\n```\n\n### Process\n\n1. **Place all reference materials** in `context\u002Frefs\u002F`\n2. **Run cavekit generation** — agent reads all refs, decomposes into domains\n3. **Agent produces:**\n   - `cavekit-overview.md` — index with domain summaries\n   - One `cavekit-{domain}.md` per identified domain\n   - Cross-references between related domains\n4. **Human reviews** kits for completeness and correctness\n5. **Iterate** — refine kits based on review feedback\n\n### Greenfield Prompt Pattern\n\nThe first prompt in a greenfield pipeline (typically `001-generate-kits-from-refs.md`) should:\n- Read all files in `context\u002Frefs\u002F`\n- Decompose reference material into domains\n- Generate kits following the template above\n- Create `cavekit-overview.md` as the index\n- Cross-reference related kits\n\n---\n\n## Rewrite Pattern: Old Code → Reference Docs → Kits\n\nWhen rewriting an existing system, the existing code becomes your reference material. But you never go directly from old code to new code — you always extract kits first.\n\n### Flow\n\n```\nExisting codebase          context\u002Frefs\u002F              context\u002Fkits\u002F\n├── src\u002F            →      ├── ref-apis.md      →     ├── cavekit-overview.md\n├── tests\u002F          →      ├── ref-data-models.md →   ├── cavekit-auth.md\n└── docs\u002F           →      ├── ref-ui-components.md →  ├── cavekit-api.md\n                           └── ref-architecture.md →   └── cavekit-data.md\n```\n\n### Process\n\n1. **Agent explores the existing codebase** and generates reference documents\n2. **Reference docs capture** the current system's behavior, APIs, data models, and UI patterns\n3. **Agent generates kits** from reference docs — implementation-agnostic requirements\n4. **Validate kits against existing code** — verify acceptance criteria match current behavior\n5. **Proceed with normal Hunt** — kits drive the new implementation\n\n### Rewrite Prompt Pattern\n\nRewrites typically use more prompts because of the reverse-engineering step:\n- `001`: Generate reference materials from old code\n- `002`: Generate kits from references + feature scope\n- `003`: Validate kits against existing codebase\n- `004+`: Plans and implementation\n\nThe key difference from greenfield: step 003 validates that your kits actually describe what the old system does, before you start building the new one.\n\n---\n\n## Cavekit Compaction\n\nWhen implementation tracking or cavekit files grow beyond approximately 500 lines, they become unwieldy for agents to process efficiently. Spec compaction compresses large files while preserving active context.\n\n### When to Compact\n\n- Implementation tracking file exceeds 500 lines\n- Cavekit file has many resolved\u002Fcompleted requirements mixed with active ones\n- Agent is spending too much context window on historical information\n\n### How to Compact\n\n1. **Identify resolved content:** completed tasks, resolved issues, archived dead ends\n2. **Archive removed content** to a separate file (e.g., `impl\u002Farchive\u002Fimpl-domain-v1.md`)\n3. **Preserve in the compacted file:**\n   - All active\u002Fin-progress tasks\n   - All open issues\n   - Recent dead ends (last 2-3 sessions)\n   - Current test health status\n   - Active cross-references\n4. **Target:** under 500 lines in the active file\n\n### Compaction Rule\n\nNever delete information — move it to an archive. Agents can still find archived context if needed, but it will not consume context window during normal operations.\n\n---\n\n## Gap Analysis\n\nGap analysis compares what was built against what was intended, identifying where kits, plans, or validation fell short.\n\n### How to Perform Gap Analysis\n\n1. **Read kits** (intended behavior) and **implementation tracking** (what was built)\n2. **For each cavekit requirement,** check if acceptance criteria are satisfied\n3. **Classify each requirement:**\n\n| Status | Meaning |\n|--------|---------|\n| **Complete** | All acceptance criteria pass |\n| **Partial** | Some criteria pass, others do not |\n| **Missing** | Requirement not implemented at all |\n| **Over-built** | Implementation exceeds cavekit (may indicate cavekit gap) |\n\n4. **Report gaps** with: which cavekit, which criterion, what is missing\n5. **Feed gaps into revision** — update kits if needed, then re-implement\n\n### Gap Analysis as Feedback\n\nGap analysis is not a one-time activity. Run it:\n- After each implementation iteration\n- Before starting a new session (to prioritize work)\n- When convergence stalls (to identify what is blocking progress)\n\n---\n\n## Integration with Other Skills\n\n### Collaborative Design in the Draft Phase\n\nThe Draft phase (`\u002Fck:sketch`) now embeds brainstorming principles directly. When running in interactive mode (no arguments), the drafter follows a collaborative design process before generating any files:\n\n1. **Explore project context** — check existing files, docs, commits before asking questions\n2. **Ask clarifying questions one at a time** — understand purpose, constraints, success criteria\n3. **Propose 2-3 domain decomposition approaches** — with tradeoffs and a recommendation\n4. **Present the design incrementally** — section by section, get approval per domain\n5. **Generate kits only after design approval** — formalize with acceptance criteria\n6. **Cavekit review loop** — automated reviewer checks quality, up to 3 iterations\n7. **User review gate** — explicit approval before transitioning to Architect phase\n\nThis process applies to EVERY project regardless of perceived simplicity. The design can be short for simple projects, but it must happen.\n\n**Visual companion:** For projects involving visual elements (UI, architecture diagrams), the Draft phase can use a browser-based visual companion to show mockups and diagrams during the design conversation. See `references\u002Fvisual-companion.md`.\n\n**YAGNI enforcement:** During the design conversation and cavekit generation, actively strip requirements the user did not ask for. Smaller kits are better kits.\n\n### With `ck:design-system`\n\nWhen DESIGN.md exists at the project root, kits for UI domains should reference design tokens in acceptance criteria. This creates a traceable chain: DESIGN.md -> cavekit acceptance criterion -> plan task -> implementation.\n\n| Acceptance Criterion Type | Design Reference |\n|--------------------------|-----------------|\n| \"Button has primary CTA appearance\" | DESIGN.md Section 4, primary button variant |\n| \"Text follows heading hierarchy\" | DESIGN.md Section 3, type scale |\n| \"Card has subtle elevation\" | DESIGN.md Section 6, elevation level 1 |\n| \"Layout uses 12-column grid\" | DESIGN.md Section 5, grid system |\n| \"Colors adapt for dark mode\" | DESIGN.md Section 2, dark mode mapping |\n\n**Do NOT duplicate DESIGN.md content into kits.** Reference by section\u002Ftoken name only. If a color changes in DESIGN.md, kits should not need updating.\n\nWhen a cavekit needs a visual pattern not yet defined in DESIGN.md, note it in the acceptance criterion:\n```markdown\n- [ ] Component uses card-like container [DESIGN.md: pattern not yet defined — flag for design update]\n```\n\n### With `ck:validation-first`\n\nEvery acceptance criterion in a cavekit must map to at least one validation gate. When writing kits, think about which gate will verify each requirement:\n\n| Acceptance Criterion Type | Likely Gate |\n|--------------------------|-------------|\n| \"Code compiles without errors\" | Gate 1: Build |\n| \"Function returns correct output for input X\" | Gate 2: Unit Tests |\n| \"User can complete workflow end-to-end\" | Gate 3: E2E\u002FIntegration |\n| \"Response time under N ms\" | Gate 4: Performance |\n| \"Application starts and displays main screen\" | Gate 5: Launch Verification |\n| \"UI matches design intent\" | Gate 6: Human Review |\n\n### With `ck:context-architecture`\n\nKits live in the `context\u002Fkits\u002F` directory. See `ck:context-architecture` for the full context directory structure, CLAUDE.md conventions, and multi-repo strategies.\n\n### With `ck:impl-tracking`\n\nAs kits are implemented, progress is tracked in `context\u002Fimpl\u002F` documents. Dead ends discovered during implementation should be recorded to prevent future agents from retrying failed approaches.\n\n---\n\n## Common Mistakes\n\n### 1. Writing Implementation-Specific Kits\n\n**Wrong:** \"Use PostgreSQL with a users table containing columns: id (UUID), email (VARCHAR), ...\"\n**Right:** \"User accounts have a unique identifier and email. Email must be unique across all accounts. Acceptance: creating two accounts with the same email fails with a duplicate error.\"\n\n### 2. Vague Acceptance Criteria\n\n**Wrong:** \"System handles errors properly\"\n**Right:** \"When a network request fails, the UI displays an error message within 2 seconds and offers a retry action. Acceptance: simulating network failure shows error banner with retry button.\"\n\n### 3. Missing Out of Scope\n\nEvery cavekit needs explicit exclusions. Without them, agents will over-build or make assumptions.\n\n### 4. No Cross-References\n\nDomains do not exist in isolation. If cavekit-auth defines session tokens that cavekit-api uses, both kits must cross-reference each other.\n\n### 5. Monolithic Kits\n\nA single 1000-line cavekit file defeats progressive disclosure. Decompose into domains with a clear index.\n\n---\n\n## Summary\n\nWriting kits for AI agents follows these rules:\n\n1. **WHAT, not HOW** — describe behavior, not implementation\n2. **Every requirement gets testable acceptance criteria** — if agents cannot validate it, it will not be met\n3. **Hierarchical with an index** — progressive disclosure for context efficiency\n4. **Cross-referenced** — related domains link to each other\n5. **Explicitly scoped** — out-of-scope section prevents over-building\n6. **Compact when large** — archive resolved content, keep active files under 500 lines\n7. **Living documents** — kits evolve through revision as gaps are discovered\n","# Cavekit Writing\n\n## Core Principle: Kits Describe WHAT, Not HOW\n\nKits are **implementation-agnostic**. They define what the system must do and how to verify it, but never prescribe a specific framework, language, or architecture.\n\nThis is the fundamental distinction in Cavekit:\n- **Kits** = WHAT must be true (framework-agnostic, durable, portable)\n- **Plans** = HOW to build it (framework-specific, derived from kits)\n- **Code** = the implementation (generated from plans, validated against kits)\n\n### Why Implementation-Agnostic?\n\nWhen kits avoid prescribing HOW, they become:\n- **Portable** — the same kits can drive implementations in different frameworks\n- **Durable** — kits survive technology migrations\n- **Testable** — acceptance criteria are about behavior, not implementation details\n- **Reusable** — the same kits work for greenfield, rewrites, and cross-framework evaluation\n\n**Bad cavekit requirement:** \"Use React useState hook to manage form state\"\n**Good cavekit requirement:** \"Form state persists across user interactions within a session. Acceptance: entering values, navigating away, and returning preserves all entered values.\"\n\n---\n\n## Every Requirement Needs Testable Acceptance Criteria\n\nThis is the single most important rule in Cavekit writing. If an agent cannot automatically validate a requirement, that requirement will not be met.\n\n### The Validation-First Rule\n\nEvery requirement must answer: **\"How would an automated test verify this?\"**\n\n| Weak Criterion | Strong Criterion |\n|----------------|-----------------|\n| \"UI should look good\" | \"All interactive elements have minimum 44x44px touch targets\" |\n| \"System should be fast\" | \"API responses return within 200ms at p95 under 100 concurrent users\" |\n| \"Handle errors gracefully\" | \"Network failures display a retry prompt with exponential backoff (1s, 2s, 4s)\" |\n| \"Support authentication\" | \"Valid credentials return a session token; invalid credentials return 401 with error message\" |\n\n### Acceptance Criteria Format\n\nEach criterion should be:\n- **Observable** — can be checked by reading output, UI state, or logs\n- **Deterministic** — same input always produces same pass\u002Ffail result\n- **Automatable** — an agent can write a test that checks this\n- **Independent** — does not depend on subjective judgment\n\n```markdown\n**Acceptance Criteria:**\n- [ ] {Action} results in {observable outcome}\n- [ ] Given {precondition}, when {action}, then {result}\n- [ ] {Metric} meets {threshold} under {conditions}\n```\n\n---\n\n## Hierarchical Structure with Index\n\nKits must be organized as a hierarchy — one index file linking to domain-specific sub-kits. This enables progressive disclosure: agents read the index first, then only the sub-kits relevant to their task.\n\n### The Cavekit Index Pattern\n\nCreate a `cavekit-overview.md` as the entry point:\n\n```markdown\n# Cavekit Overview\n\n## Domains\n\n| Domain | Cavekit File | Summary |\n|--------|-----------|---------|\n| Authentication | cavekit-auth.md | User registration, login, session management, OAuth |\n| Data Models | cavekit-data-models.md | Core entities, relationships, validation rules |\n| API | cavekit-api.md | REST endpoints, request\u002Fresponse formats, error handling |\n| UI Components | cavekit-ui-components.md | Shared components, accessibility, responsive behavior |\n| Notifications | cavekit-notifications.md | Email, push, in-app notification delivery |\n\n## Cross-Cutting Concerns\n- Security requirements: see cavekit-auth.md R3, cavekit-api.md R7\n- Performance budgets: see cavekit-api.md R12, cavekit-ui-components.md R5\n- Accessibility: see cavekit-ui-components.md R8-R10\n```\n\n### Why Hierarchical?\n\n1. **Context window efficiency** — agents load only the domains they need\n2. **Parallel work** — different agents can own different spec domains\n3. **Review efficiency** — humans can review domain-by-domain\n4. **Cross-referencing** — domains link to each other explicitly\n\n---\n\n## Cross-Referencing Between Kits\n\nRelated kits must link to each other. Cross-references prevent requirements from being lost at domain boundaries.\n\n### Cross-Reference Patterns\n\n```markdown\n## Cross-References\n- **Depends on:** cavekit-auth.md R1 (session tokens required for API access)\n- **Depended on by:** cavekit-notifications.md R4 (uses user preferences from this cavekit)\n- **Related:** cavekit-ui-components.md R6 (error display components used by this domain)\n```\n\n### When to Cross-Reference\n\n- When one domain's requirement depends on another domain's output\n- When shared entities are defined in one cavekit but used in many\n- When validation criteria span multiple domains\n- When out-of-scope items are in-scope for another cavekit\n\n---\n\n## Full Cavekit Format Template\n\nUse this template for every domain cavekit:\n\n```markdown\n# Cavekit: {Domain Name}\n\n## Scope\n{One paragraph describing what this spec covers and its boundaries.}\n\n## Requirements\n\n### R1: {Requirement Name}\n**Description:** {What must be true — stated in terms of behavior, not implementation.}\n**Acceptance Criteria:**\n- [ ] {Testable criterion 1}\n- [ ] {Testable criterion 2}\n- [ ] {Testable criterion 3}\n**Dependencies:** {Other specs\u002Frequirements this depends on, or \"None\"}\n\n### R2: {Requirement Name}\n**Description:** {What must be true}\n**Acceptance Criteria:**\n- [ ] {Testable criterion 1}\n- [ ] {Testable criterion 2}\n**Dependencies:** {Dependencies}\n\n### R3: ...\n\n## Out of Scope\n{Explicit list of things this cavekit does NOT cover. This is critical — it prevents\nagents from over-building and clarifies domain boundaries.}\n- {Thing explicitly excluded and why}\n- {Another exclusion}\n\n## Cross-References\n- See also: cavekit-{related-domain}.md — {why it is related}\n- Depends on: cavekit-{dependency}.md R{N} — {what is needed}\n- Depended on by: cavekit-{dependent}.md R{N} — {what depends on this}\n```\n\n### Template Rules\n\n1. **Number requirements sequentially** (R1, R2, R3...) — agents reference them by ID\n2. **Every requirement gets acceptance criteria** — no exceptions\n3. **Out of Scope is mandatory** — explicit exclusions prevent scope creep\n4. **Cross-References section is mandatory** — even if it says \"None\"\n5. **Scope section is one paragraph** — concise boundary description\n\n---\n\n## Greenfield Pattern: Reference Material → Kits\n\nWhen building from scratch, you start with reference materials and derive kits from them.\n\n### Flow\n\n```\ncontext\u002Frefs\u002F              context\u002Fkits\u002F\n├── prd.md          →      ├── cavekit-overview.md\n├── design-doc.md   →      ├── cavekit-auth.md\n├── api-draft.md    →      ├── cavekit-api.md\n└── research\u002F       →      ├── cavekit-data-models.md\n    └── ...         →      └── cavekit-ui.md\n```\n\n### Process\n\n1. **Place all reference materials** in `context\u002Frefs\u002F`\n2. **Run cavekit generation** — agent reads all refs, decomposes into domains\n3. **Agent produces:**\n   - `cavekit-overview.md` — index with domain summaries\n   - One `cavekit-{domain}.md` per identified domain\n   - Cross-references between related domains\n4. **Human reviews** kits for completeness and correctness\n5. **Iterate** — refine kits based on review feedback\n\n### Greenfield Prompt Pattern\n\nThe first prompt in a greenfield pipeline (typically `001-generate-kits-from-refs.md`) should:\n- Read all files in `context\u002Frefs\u002F`\n- Decompose reference material into domains\n- Generate kits following the template above\n- Create `cavekit-overview.md` as the index\n- Cross-reference related kits\n\n---\n\n## Rewrite Pattern: Old Code → Reference Docs → Kits\n\nWhen rewriting an existing system, the existing code becomes your reference material. But you never go directly from old code to new code — you always extract kits first.\n\n### Flow\n\n```\nExisting codebase          context\u002Frefs\u002F              context\u002Fkits\u002F\n├── src\u002F            →      ├── ref-apis.md      →     ├── cavekit-overview.md\n├── tests\u002F          →      ├── ref-data-models.md →   ├── cavekit-auth.md\n└── docs\u002F           →      ├── ref-ui-components.md →  ├── cavekit-api.md\n                           └── ref-architecture.md →   └── cavekit-data.md\n```\n\n### Process\n\n1. **Agent explores the existing codebase** and generates reference documents\n2. **Reference docs capture** the current system's behavior, APIs, data models, and UI patterns\n3. **Agent generates kits** from reference docs — implementation-agnostic requirements\n4. **Validate kits against existing code** — verify acceptance criteria match current behavior\n5. **Proceed with normal Hunt** — kits drive the new implementation\n\n### Rewrite Prompt Pattern\n\nRewrites typically use more prompts because of the reverse-engineering step:\n- `001`: Generate reference materials from old code\n- `002`: Generate kits from references + feature scope\n- `003`: Validate kits against existing codebase\n- `004+`: Plans and implementation\n\nThe key difference from greenfield: step 003 validates that your kits actually describe what the old system does, before you start building the new one.\n\n---\n\n## Cavekit Compaction\n\nWhen implementation tracking or cavekit files grow beyond approximately 500 lines, they become unwieldy for agents to process efficiently. Spec compaction compresses large files while preserving active context.\n\n### When to Compact\n\n- Implementation tracking file exceeds 500 lines\n- Cavekit file has many resolved\u002Fcompleted requirements mixed with active ones\n- Agent is spending too much context window on historical information\n\n### How to Compact\n\n1. **Identify resolved content:** completed tasks, resolved issues, archived dead ends\n2. **Archive removed content** to a separate file (e.g., `impl\u002Farchive\u002Fimpl-domain-v1.md`)\n3. **Preserve in the compacted file:**\n   - All active\u002Fin-progress tasks\n   - All open issues\n   - Recent dead ends (last 2-3 sessions)\n   - Current test health status\n   - Active cross-references\n4. **Target:** under 500 lines in the active file\n\n### Compaction Rule\n\nNever delete information — move it to an archive. Agents can still find archived context if needed, but it will not consume context window during normal operations.\n\n---\n\n## Gap Analysis\n\nGap analysis compares what was built against what was intended, identifying where kits, plans, or validation fell short.\n\n### How to Perform Gap Analysis\n\n1. **Read kits** (intended behavior) and **implementation tracking** (what was built)\n2. **For each cavekit requirement,** check if acceptance criteria are satisfied\n3. **Classify each requirement:**\n\n| Status | Meaning |\n|--------|---------|\n| **Complete** | All acceptance criteria pass |\n| **Partial** | Some criteria pass, others do not |\n| **Missing** | Requirement not implemented at all |\n| **Over-built** | Implementation exceeds cavekit (may indicate cavekit gap) |\n\n4. **Report gaps** with: which cavekit, which criterion, what is missing\n5. **Feed gaps into revision** — update kits if needed, then re-implement\n\n### Gap Analysis as Feedback\n\nGap analysis is not a one-time activity. Run it:\n- After each implementation iteration\n- Before starting a new session (to prioritize work)\n- When convergence stalls (to identify what is blocking progress)\n\n---\n\n## Integration with Other Skills\n\n### Collaborative Design in the Draft Phase\n\nThe Draft phase (`\u002Fck:sketch`) now embeds brainstorming principles directly. When running in interactive mode (no arguments), the drafter follows a collaborative design process before generating any files:\n\n1. **Explore project context** — check existing files, docs, commits before asking questions\n2. **Ask clarifying questions one at a time** — understand purpose, constraints, success criteria\n3. **Propose 2-3 domain decomposition approaches** — with tradeoffs and a recommendation\n4. **Present the design incrementally** — section by section, get approval per domain\n5. **Generate kits only after design approval** — formalize with acceptance criteria\n6. **Cavekit review loop** — automated reviewer checks quality, up to 3 iterations\n7. **User review gate** — explicit approval before transitioning to Architect phase\n\nThis process applies to EVERY project regardless of perceived simplicity. The design can be short for simple projects, but it must happen.\n\n**Visual companion:** For projects involving visual elements (UI, architecture diagrams), the Draft phase can use a browser-based visual companion to show mockups and diagrams during the design conversation. See `references\u002Fvisual-companion.md`.\n\n**YAGNI enforcement:** During the design conversation and cavekit generation, actively strip requirements the user did not ask for. Smaller kits are better kits.\n\n### With `ck:design-system`\n\nWhen DESIGN.md exists at the project root, kits for UI domains should reference design tokens in acceptance criteria. This creates a traceable chain: DESIGN.md -> cavekit acceptance criterion -> plan task -> implementation.\n\n| Acceptance Criterion Type | Design Reference |\n|--------------------------|-----------------|\n| \"Button has primary CTA appearance\" | DESIGN.md Section 4, primary button variant |\n| \"Text follows heading hierarchy\" | DESIGN.md Section 3, type scale |\n| \"Card has subtle elevation\" | DESIGN.md Section 6, elevation level 1 |\n| \"Layout uses 12-column grid\" | DESIGN.md Section 5, grid system |\n| \"Colors adapt for dark mode\" | DESIGN.md Section 2, dark mode mapping |\n\n**Do NOT duplicate DESIGN.md content into kits.** Reference by section\u002Ftoken name only. If a color changes in DESIGN.md, kits should not need updating.\n\nWhen a cavekit needs a visual pattern not yet defined in DESIGN.md, note it in the acceptance criterion:\n```markdown\n- [ ] Component uses card-like container [DESIGN.md: pattern not yet defined — flag for design update]\n```\n\n### With `ck:validation-first`\n\nEvery acceptance criterion in a cavekit must map to at least one validation gate. When writing kits, think about which gate will verify each requirement:\n\n| Acceptance Criterion Type | Likely Gate |\n|--------------------------|-------------|\n| \"Code compiles without errors\" | Gate 1: Build |\n| \"Function returns correct output for input X\" | Gate 2: Unit Tests |\n| \"User can complete workflow end-to-end\" | Gate 3: E2E\u002FIntegration |\n| \"Response time under N ms\" | Gate 4: Performance |\n| \"Application starts and displays main screen\" | Gate 5: Launch Verification |\n| \"UI matches design intent\" | Gate 6: Human Review |\n\n### With `ck:context-architecture`\n\nKits live in the `context\u002Fkits\u002F` directory. See `ck:context-architecture` for the full context directory structure, CLAUDE.md conventions, and multi-repo strategies.\n\n### With `ck:impl-tracking`\n\nAs kits are implemented, progress is tracked in `context\u002Fimpl\u002F` documents. Dead ends discovered during implementation should be recorded to prevent future agents from retrying failed approaches.\n\n---\n\n## Common Mistakes\n\n### 1. Writing Implementation-Specific Kits\n\n**Wrong:** \"Use PostgreSQL with a users table containing columns: id (UUID), email (VARCHAR), ...\"\n**Right:** \"User accounts have a unique identifier and email. Email must be unique across all accounts. Acceptance: creating two accounts with the same email fails with a duplicate error.\"\n\n### 2. Vague Acceptance Criteria\n\n**Wrong:** \"System handles errors properly\"\n**Right:** \"When a network request fails, the UI displays an error message within 2 seconds and offers a retry action. Acceptance: simulating network failure shows error banner with retry button.\"\n\n### 3. Missing Out of Scope\n\nEvery cavekit needs explicit exclusions. Without them, agents will over-build or make assumptions.\n\n### 4. No Cross-References\n\nDomains do not exist in isolation. If cavekit-auth defines session tokens that cavekit-api uses, both kits must cross-reference each other.\n\n### 5. Monolithic Kits\n\nA single 1000-line cavekit file defeats progressive disclosure. Decompose into domains with a clear index.\n\n---\n\n## Summary\n\nWriting kits for AI agents follows these rules:\n\n1. **WHAT, not HOW** — describe behavior, not implementation\n2. **Every requirement gets testable acceptance criteria** — if agents cannot validate it, it will not be met\n3. **Hierarchical with an index** — progressive disclosure for context efficiency\n4. **Cross-referenced** — related domains link to each other\n5. **Explicitly scoped** — out-of-scope section prevents over-building\n6. **Compact when large** — archive resolved content, keep active files under 500 lines\n7. **Living documents** — kits evolve through revision as gaps are discovered\n",{"name":5,"description":7},"main","2b63f856ce19c2a797929cacabd9e0fc936812fa","plugins\u002FJuliusBrussee\u002Fblueprint\u002Fskills\u002Fcavekit-writing",491,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins","https:\u002F\u002Fhol.org\u002Fplugins\u002Fbest-codex-plugins","https:\u002F\u002Fgithub.com\u002Fhashgraph-online","https:\u002F\u002Fhol.org","Open-source standards and developer tools for interoperable AI agents: discovery, identity, communication, payments, privacy and security.","2026-11-14 14:06:13",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add hashgraph-online\u002Fawesome-codex-plugins --skill cavekit-writing",{"tool":60,"command":61},"bunx","bunx skills add hashgraph-online\u002Fawesome-codex-plugins --skill cavekit-writing",{"tool":63,"command":64},"pnpm","pnpm dlx skills add hashgraph-online\u002Fawesome-codex-plugins --skill cavekit-writing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FJuliusBrussee\u002Fblueprint\u002Fskills\u002Fcavekit-writing\u002FSKILL.md",true,[],[69,79,87,95,103,111],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":74,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":78},"01M7DV332YQMGD8WTRJ9DZQXTB","worktable-review-with-annotations","Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.","MIT","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-review-with-annotations\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-review-with-annotations\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":83,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":78},"01M7DV2YGHCZVBEB1AHYB6CGHE","worktable-find-and-synthesize-context","Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-find-and-synthesize-context\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-find-and-synthesize-context\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":91,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":78},"01M7DV2TQN1H11ME2SAF9MXN7V","worktable-create-or-update-docs","Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-update-docs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-update-docs\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":99,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":78},"01M7DV2NE452NEA8TXATKSNAJH","worktable-create-or-manage-records","Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-records\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-records\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":107,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":78},"01M7DV2HENRBR2KSCVM064WH0Y","worktable-create-or-manage-interactive-html","Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-interactive-html\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-interactive-html\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":115,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":78},"01M7DV2CADR5R7RQFFYPNAGR9Y","worktable-collaborate-threads","Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-collaborate-threads\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-collaborate-threads\u002FSKILL.md",[],[]]