AI Assets
Guides creation, modification, and validation of Claude Code AI assets. Every asset is a prompt for an LLM — apply prompt engineering rigor throughout.
Apply Agent(prompt-engineer) role for all steps below.
1. Determine Operation and Scope
Clarify with the user:
- Operation:
create | modify | validate | analyze
- Asset type:
rule | workflow | skill | hook | agents-md
- Target: file path or asset name
If the user's intent is ambiguous, ask before proceeding.
2. Gather Context
Read and internalize before making any changes:
- Target asset (if exists — for modify/validate/analyze)
- Vendor specs:
framework-summary.md — Section 2.x matching the asset type. This is the authoritative source for Claude Code capabilities, formats, and constraints
- Authoring standards:
rules/global_rules.md — language, file size limits, cross-reference rules
- Project conventions:
CLAUDE.md — naming, frontmatter, source management, interconnection patterns
- Existing assets of the same type — scan the target directory to understand tone, structure, and naming patterns already in use
- Context engineering guide:
context-engineering skill — context stack model, production checklists, reference templates. Required reading for AI-facing assets
3. Map Dependency Chain
Search the entire asset tree for references to/from the target. Build a dependency map:
[target asset]
├─ OUT (this asset references):
│ ├─ /workflow-name → file path [OK | MISSING]
│ ├─ @skill-name → file path [OK | MISSING]
│ └─ rule-name → file path [OK | MISSING]
├─ IN (referenced by):
│ ├─ asset-a.md (line N)
│ └─ asset-b.md (step N)
└─ HOOKS (enforced by):
└─ script.py → hook event
Search patterns: /asset-name, @asset-name, ../type/path.md, prose mentions in integration sections.
Flag issues:
- Broken refs: outgoing reference target doesn't exist
- Orphaned: zero incoming references (nothing calls or mentions this asset)
- Missing links: asset logically belongs in a chain but isn't connected
- Circular deps: A → B → A (acceptable for rules↔workflows, flag for review otherwise)
For analyze operations — present the full map and stop here. For other operations — use the map to inform subsequent steps.
4. Companion Asset Analysis
Before authoring, evaluate whether the target asset needs companion assets to be effective:
- Rule that defines a multi-step procedure → extract to a skill with checklists as resource files
- Rule that needs automated enforcement → propose a hook script
- Workflow with reusable sub-sequences → extract sub-workflows (
/sub-workflow)
- Workflow that bundles complex knowledge → extract a skill for the knowledge, reference via
@skill-name
- Skill that operationalizes a rule → verify the rule exists and cross-references the skill
- Any asset approaching 12K chars → split: offload detail to skill resources or sub-workflows
If companion assets are needed, create them as part of the same operation. Apply this entire workflow to each companion asset recursively (steps 2–8).
5. Author or Edit the Asset
Apply the asset-type spec from framework-summary.md Section 2.x:
Role Hierarchy and Routing
Design role rules for composable specialization via Claude Code's agent/skill system:
- Layer 1 — Base role ((agent)): Universal principles, reasoning protocol, hard rules. Example:
software-engineer.role.md
- Layer 2 — Specialization ((agent) or
glob): Stack-specific patterns. (agent) for project context matching; glob for file-type binding
- Layer 3 — Explicit override (
manual): User forces via @role-name
Routing: CLAUDE.md declares tech stack → (agent) roles with matching description keywords activate automatically → glob activates on file patterns → multiple roles compose (base + specialization)
Composability rules:
- Base MUST NOT duplicate specializations; specializations MUST NOT duplicate base
- Each role's
description must clearly state scope to avoid activation overlap
6. Prompt Engineering Review
Every asset is a prompt for an LLM. Apply Agent(prompt-engineer) Reasoning Protocol to evaluate each asset:
- Assess — identify the prompt surface: what will Claude Code read and how will it shape behavior?
- Diagnose — what could go wrong? (wrong activation, vague instructions, conflicting rules, token waste, missed edge cases)
- Design review — verify the asset follows prompt engineering principles below
- Eval — define ≥1 scenario proving the asset works as intended + ≥1 scenario where it should NOT activate
Universal Checks (all asset types)
- Instruction clarity: imperative, unambiguous. No hedging ("try to", "consider") — use "do X", "never Y", "always Z"
- Structure: sections separated via headings, XML tags, bullet lists. Instructions never buried in prose
- Token efficiency: every token earns its place. Remove filler, redundancy, obvious statements
- Instruction hierarchy: system constraints > developer guidelines > user preferences. Explicit priority on conflicts
- Security: no secrets, PII, API keys. Instructions separated from data. No injection vectors
- Conflict check: no contradictions with other active assets (rules, CLAUDE.md, other workflows)
Context Engineering Checks (all asset types)
Apply context-engineering skill principles — every asset is context that enters Claude Code's window:
- Context stack awareness: Which context stack layer does this asset operate in? (L1: policy, L2: developer instructions, L3: tool contracts, L4: runtime state, etc.)
- Position effects: Critical constraints (Hard Rules, NEVER items) placed at the beginning. Output contracts at the end. No critical info buried in the middle of long sections
- Layer separation: Policy ("never do X") is separate from knowledge ("how to do Y"). No mixed sections
- Token budget impact: Does this asset justify its token cost? Can any section be compressed without losing signal?
- Cacheable prefix: For roles/rules — static content that rarely changes grouped to enable KV cache reuse
Asset-Type-Specific Checks
Rules ((agent)):
- Does
description contain keywords users naturally use when the rule should activate?
- Is it specific enough to avoid false positives, broad enough to not miss real cases?
- Does it differentiate clearly from other rules with similar scope?
- Are negative instructions ("do NOT", anti-patterns) sufficient to prevent wrong behavior?
- Will Claude Code consistently produce the intended behavior when this rule is active?
Workflows:
- Does each step have a clear completion criterion?
- Are decision points (if/then) explicit — no ambiguous branching?
- Could Claude Code execute this workflow autonomously with minimal user input?
- Are sub-workflow calls (
/name) and skill refs (@name) correct?
Skills:
- Does
description trigger progressive disclosure for the right tasks only?
- Are resource files referenced and accessible?
- Is knowledge actionable (checklists, patterns) vs purely informational?
Rules (roles):
- Are Hard Rules concrete and testable (not aspirational)?
- Is the role boundary clear — what is in scope vs delegated?
- Does it compose cleanly with Layer 1 base role without duplication?
7. Validate (mandatory on every create/modify)
This step is non-optional. Run the full checklist on every create or modify operation to prevent dependency corruption, broken cross-references, and size violations.
Format and structure:
References and dependencies:
Prompt quality (per Agent(prompt-engineer) review — Step 6):
Context engineering (per context-engineering skill — Step 6):
Dependency chain integrity:
8. Finalize
- Verify all assets (primary + companions) are saved in correct directories
- If cross-references changed, verify all affected assets are updated
- Present a summary to the user:
- What was created/modified (list all assets including companions)
- Dependency chain status (all refs OK / issues found)
- Role routing status (for role assets: which layers are covered, CLAUDE.md tech stack alignment)
- Validation checklist result (all passed / items requiring attention)
- Any remaining action items
1---2name: ai-assets3description: Create, modify, validate, and analyze Claude Code AI assets (rules, workflows, skills, hooks, CLAUDE.md) with prompt engineering discipline and dependency chain awareness4---5
6# AI Assets
7
8Guides creation, modification, and validation of Claude Code AI assets. Every asset is a prompt for an LLM — apply prompt engineering rigor throughout.
9
10**Apply `Agent(prompt-engineer)` role for all steps below.**
11
12## 1. Determine Operation and Scope
13
14Clarify with the user:
15
16- **Operation**: `create` | `modify` | `validate` | `analyze`
17- **Asset type**: `rule` | `workflow` | `skill` | `hook` | `agents-md`
18- **Target**: file path or asset name
19
20If the user's intent is ambiguous, ask before proceeding.
21
22## 2. Gather Context
23
24Read and internalize before making any changes:
25
261. **Target asset** (if exists — for modify/validate/analyze)
272. **Vendor specs**: `framework-summary.md` — Section 2.x matching the asset type. This is the authoritative source for Claude Code capabilities, formats, and constraints
283. **Authoring standards**: `rules/global_rules.md` — language, file size limits, cross-reference rules
294. **Project conventions**: `CLAUDE.md` — naming, frontmatter, source management, interconnection patterns
305. **Existing assets of the same type** — scan the target directory to understand tone, structure, and naming patterns already in use
316. **Context engineering guide**: `context-engineering` skill — context stack model, production checklists, reference templates. Required reading for AI-facing assets
32
33## 3. Map Dependency Chain
34
35Search the entire asset tree for references to/from the target. Build a dependency map:
36
37```
38[target asset]
39├─ OUT (this asset references):
40│ ├─ /workflow-name → file path [OK | MISSING]
41│ ├─ @skill-name → file path [OK | MISSING]
42│ └─ rule-name → file path [OK | MISSING]
43├─ IN (referenced by):
44│ ├─ asset-a.md (line N)
45│ └─ asset-b.md (step N)
46└─ HOOKS (enforced by):
47 └─ script.py → hook event
48```
49
50**Search patterns**: `/asset-name`, `@asset-name`, `../type/path.md`, prose mentions in integration sections.
51
52**Flag issues**:
53- **Broken refs**: outgoing reference target doesn't exist
54- **Orphaned**: zero incoming references (nothing calls or mentions this asset)
55- **Missing links**: asset logically belongs in a chain but isn't connected
56- **Circular deps**: A → B → A (acceptable for rules↔workflows, flag for review otherwise)
57
58For `analyze` operations — present the full map and stop here. For other operations — use the map to inform subsequent steps.
59
60## 4. Companion Asset Analysis
61
62Before authoring, evaluate whether the target asset needs **companion assets** to be effective:
63
64- **Rule** that defines a multi-step procedure → extract to a **skill** with checklists as resource files
65- **Rule** that needs automated enforcement → propose a **hook** script
66- **Workflow** with reusable sub-sequences → extract **sub-workflows** (`/sub-workflow`)
67- **Workflow** that bundles complex knowledge → extract a **skill** for the knowledge, reference via `@skill-name`
68- **Skill** that operationalizes a rule → verify the **rule** exists and cross-references the skill
69- **Any asset** approaching 12K chars → split: offload detail to skill resources or sub-workflows
70
71If companion assets are needed, create them as part of the same operation. Apply this entire workflow to each companion asset recursively (steps 2–8).
72
73## 5. Author or Edit the Asset
74
75Apply the asset-type spec from `framework-summary.md` Section 2.x:
76
77<rule_spec>
78- **Frontmatter**: `trigger` ((auto-loaded) | (agent) | `glob` | `manual`), `description`
79- **`description`** is the activation signal for (agent) — write it as a keyword-rich, specific summary. Too broad = false positives. Too narrow = missed activations
80- Trigger mode: (auto-loaded) for foundational constraints; (agent) for contextual guidance; `glob` for file-type-specific; `manual` for on-demand roles/expertise
81- Structure: imperative instructions, bullet points, numbered lists, XML tags for sections
82- Max 12,000 chars
83</rule_spec>
84
85<workflow_spec>
86- **Frontmatter**: `description`
87- Numbered steps — each step is one concrete action with a clear completion criterion
88- Compose with `/sub-workflow` to avoid duplication across workflows
89- Include decision points (if/then) for branching logic
90- Max 12,000 chars
91</workflow_spec>
92
93<skill_spec>
94- **Folder**: `skill-name/SKILL.md` + resource files
95- **Frontmatter**: `name`, `description`
96- `description` drives progressive disclosure — optimize for automatic activation by Claude Code
97- Offload checklists, templates, guides to resource files (no size limit on resources)
98- Max 12,000 chars for SKILL.md only
99</skill_spec>
100
101<hook_spec>
102- **Config**: JSON with hook event name, command, working directory
103- **Script**: Python 3; stdin JSON; exit 0 (pass) or 2 (block)
104- 11 events: `pre/PostToolUse (Read)`, `pre/PostToolUse (Write|Edit)`, `pre/PostToolUse (Bash)`, `pre/PostToolUse`, `UserPromptSubmit`, `Stop`, `WorktreeCreate`
105- Merge order: System → User → Workspace (all execute)
106</hook_spec>
107
108<agents_md_spec>
109- No frontmatter — auto-scoped by directory placement
110- Root = always on; subdirectory = scoped to that dir tree
111- Focus: what this directory does, which rules/workflows/skills apply
112- Be specific, avoid redundancy with parent CLAUDE.md
113</agents_md_spec>
114
115### Role Hierarchy and Routing
116
117Design role rules for composable specialization via Claude Code's agent/skill system:
118
119- **Layer 1 — Base role** ((agent)): Universal principles, reasoning protocol, hard rules. Example: `software-engineer.role.md`
120- **Layer 2 — Specialization** ((agent) or `glob`): Stack-specific patterns. (agent) for project context matching; `glob` for file-type binding
121- **Layer 3 — Explicit override** (`manual`): User forces via `@role-name`
122
123**Routing**: CLAUDE.md declares tech stack → (agent) roles with matching `description` keywords activate automatically → `glob` activates on file patterns → multiple roles compose (base + specialization)
124
125**Composability rules**:
126- Base MUST NOT duplicate specializations; specializations MUST NOT duplicate base
127- Each role's `description` must clearly state scope to avoid activation overlap
128
129## 6. Prompt Engineering Review
130
131**Every asset is a prompt for an LLM.** Apply `Agent(prompt-engineer)` Reasoning Protocol to evaluate each asset:
132
1331. **Assess** — identify the prompt surface: what will Claude Code read and how will it shape behavior?
1342. **Diagnose** — what could go wrong? (wrong activation, vague instructions, conflicting rules, token waste, missed edge cases)
1353. **Design review** — verify the asset follows prompt engineering principles below
1364. **Eval** — define ≥1 scenario proving the asset works as intended + ≥1 scenario where it should NOT activate
137
138### Universal Checks (all asset types)
139
1401. **Instruction clarity**: imperative, unambiguous. No hedging ("try to", "consider") — use "do X", "never Y", "always Z"
1412. **Structure**: sections separated via headings, XML tags, bullet lists. Instructions never buried in prose
1423. **Token efficiency**: every token earns its place. Remove filler, redundancy, obvious statements
1434. **Instruction hierarchy**: system constraints > developer guidelines > user preferences. Explicit priority on conflicts
1445. **Security**: no secrets, PII, API keys. Instructions separated from data. No injection vectors
1456. **Conflict check**: no contradictions with other active assets (rules, CLAUDE.md, other workflows)
146
147### Context Engineering Checks (all asset types)
148
149Apply `context-engineering` skill principles — every asset is context that enters Claude Code's window:
150
1517. **Context stack awareness**: Which context stack layer does this asset operate in? (L1: policy, L2: developer instructions, L3: tool contracts, L4: runtime state, etc.)
1528. **Position effects**: Critical constraints (Hard Rules, NEVER items) placed at the beginning. Output contracts at the end. No critical info buried in the middle of long sections
1539. **Layer separation**: Policy ("never do X") is separate from knowledge ("how to do Y"). No mixed sections
15410. **Token budget impact**: Does this asset justify its token cost? Can any section be compressed without losing signal?
15511. **Cacheable prefix**: For roles/rules — static content that rarely changes grouped to enable KV cache reuse
156
157### Asset-Type-Specific Checks
158
159**Rules** ((agent)):
160- Does `description` contain keywords users naturally use when the rule should activate?
161- Is it specific enough to avoid false positives, broad enough to not miss real cases?
162- Does it differentiate clearly from other rules with similar scope?
163- Are negative instructions ("do NOT", anti-patterns) sufficient to prevent wrong behavior?
164- Will Claude Code consistently produce the intended behavior when this rule is active?
165
166**Workflows**:
167- Does each step have a clear completion criterion?
168- Are decision points (if/then) explicit — no ambiguous branching?
169- Could Claude Code execute this workflow autonomously with minimal user input?
170- Are sub-workflow calls (`/name`) and skill refs (`@name`) correct?
171
172**Skills**:
173- Does `description` trigger progressive disclosure for the right tasks only?
174- Are resource files referenced and accessible?
175- Is knowledge actionable (checklists, patterns) vs purely informational?
176
177**Rules (roles)**:
178- Are Hard Rules concrete and testable (not aspirational)?
179- Is the role boundary clear — what is in scope vs delegated?
180- Does it compose cleanly with Layer 1 base role without duplication?
181
182## 7. Validate (mandatory on every create/modify)
183
184**This step is non-optional.** Run the full checklist on every create or modify operation to prevent dependency corruption, broken cross-references, and size violations.
185
186**Format and structure:**
187- [ ] Correct YAML frontmatter for asset type
188- [ ] File size ≤ 12,000 characters (rules, workflows, SKILL.md)
189- [ ] All content in English
190- [ ] File name follows naming convention (see `CLAUDE.md`)
191
192**References and dependencies:**
193- [ ] All `/workflow` references resolve to existing workflow files
194- [ ] All `@skill` references resolve to existing skill folders
195- [ ] All relative paths are valid and point to existing files
196- [ ] No absolute or machine-specific paths (`C:\Users\...`, `/home/...`)
197- [ ] Related assets updated with cross-references to this asset
198
199**Prompt quality** (per `Agent(prompt-engineer)` review — Step 6):
200- [ ] All checks from Step 6 passed (universal + asset-type-specific)
201- [ ] `description` is keyword-rich and activation-appropriate
202- [ ] No secrets, API keys, or PII
203- [ ] Consistent with existing assets in tone and structure
204- [ ] Behavioral test: Claude Code would produce correct behavior with this asset active
205
206**Context engineering** (per `context-engineering` skill — Step 6):
207- [ ] Asset maps to a context stack layer (or spans multiple with justification)
208- [ ] No "lost-in-the-middle" — critical info not buried in middle of long asset
209- [ ] Policy and knowledge sections distinct
210- [ ] AI-facing assets reference `context-engineering` skill where relevant
211
212**Dependency chain integrity:**
213- [ ] No broken outgoing references
214- [ ] Asset is reachable (referenced by at least one other asset or is top-level)
215- [ ] No collateral damage — assets that reference this one still work after the change
216- [ ] Companion assets (from step 4) are also validated
217- [ ] SDLC lifecycle map in `ARCHITECTURE.md` updated if applicable
218
219## 8. Finalize
220
2211. Verify all assets (primary + companions) are saved in correct directories
2222. If cross-references changed, verify all affected assets are updated
2233. Present a summary to the user:
224 - What was created/modified (list all assets including companions)
225 - Dependency chain status (all refs OK / issues found)
226 - Role routing status (for role assets: which layers are covered, CLAUDE.md tech stack alignment)
227 - Validation checklist result (all passed / items requiring attention)
228 - Any remaining action items