AgentFlow Framework Development
When to Use This Skill
Load this skill when you need to:
- Create or modify agents, skills, commands, or hooks
- Add or modify modules in the module registry
- Create integration guides for cross-module concerns
- Create or update module validation specs
- Understand framework component structure and V2 architecture
- Apply namespace rules and documentation standards
Rules (FOLLOW THESE)
Namespace Rules
- All framework components use
af- prefix (agents, skills, commands)
- Project-specific components never use
af- prefix
- Never mix framework and project components in same file
Documentation Rules
- All framework files require complete frontmatter (title, created, updated, tags, parent)
- Bidirectional linking is mandatory - parent lists children, child references parent
- Run docs-quality-agent after any framework changes
- Update dates when modifying files (updated, last_checked)
Size Rules
- Agents must be lightweight (~50 lines of procedure)
- Skills must be directive (rules + workflows, not reference dumps)
- Skills must be under 300 lines (target: 150-200)
- Skills link to comprehensive docs for depth
Structure Rules
- Agents reference skills for domain knowledge (use backticks:
af-skill-name)
- Agents have clear I/O specifications (inputs, outputs)
- Skills use MUST/SHOULD/MAY directives for clarity
- Commands validate arguments and provide usage examples
Validation Rules
- Test components before considering them complete
- Validate documentation with scripts (frontmatter, links)
- Restart Claude Code after creating new skills
- Verify invocation for agents and commands
Module Rules
- All modules are declared in
docs/reference/module-registry.yml
- Core modules are always installed (agentflow, linear, git, documentation, doppler)
- Optional modules are selected during Discovery and installed before Refinement
- Every module must have:
name, description, skill, validation_spec, depends_on
- Integration guides are created when two modules interact (e.g., cognito + SES)
- Validation specs are Playwright tests in
templates/setup/validation/specs/
- Run
validate-module-registry.ts after any registry change (169+ checks)
Workflows
Workflow: Adding a New Agent
When: You need a specialized subagent for a specific domain
Steps:
- Create file:
.claude/agents/af-<domain>-agent.md
- Add frontmatter with
name, description, tools, title, dates, tags, parent
- Write procedure: Role, Skills Used, Inputs, Procedure, Outputs, Error Handling
- Keep procedure ~50 lines (load skills, don't duplicate knowledge)
- Update
.claude/agents/README.md children array
- Validate:
npx ts-node .claude/scripts/validate-frontmatter.ts
- Test invocation:
Task tool → subagent_type="af-<domain>-agent"
- Run docs-quality-agent for comprehensive validation
Success criteria:
- ✅ Agent has complete frontmatter and bidirectional links
- ✅ Agent loads skills for domain knowledge
- ✅ Agent can be invoked successfully
- ✅ Validation scripts pass
Workflow: Creating a New Skill
When: You need to package domain knowledge for reuse
Steps:
- Create directory:
.claude/skills/af-<name>/
- Create file:
.claude/skills/af-<name>/SKILL.md
- Add frontmatter with
name, description, type, domain, dates, tags
- Structure content: When to Use, Rules (15-20), Workflows (4-5), Examples, Essential Reading
- Keep under 300 lines (target: 150-200) - move details to comprehensive guide
- Create guide if needed:
.claude/docs/guides/<domain>-guide.md (800-1500 lines)
- Update
.claude/skills/README.md children array
- Validate:
npx ts-node .claude/scripts/validate-links.ts
- Restart Claude Code session to pick up new skill
- Test with agent that loads the skill
Success criteria:
- ✅ Skill is directive (workflows, rules, examples)
- ✅ Skill is under 300 lines
- ✅ Skill links to comprehensive docs (if needed)
- ✅ Agents can load and use skill successfully
Workflow: Adding a Slash Command
When: You need a discoverable entry point for a workflow
Steps:
- Determine category: framework (
/af:), task (/task:), phase-specific
- Create file:
.claude/commands/<category>/<action>.md
- Add frontmatter with
description (shows in autocomplete), dates, tags
- Write command body: usage, examples, the prompt that executes
- Use
$1, $2 for positional args or $ARGUMENTS for all args
- Update
.claude/commands/<category>/README.md children array
- Test:
/<category>:<action> should autocomplete and execute
- Verify arguments work correctly
Success criteria:
- ✅ Command appears in autocomplete
- ✅ Command expands and executes correctly
- ✅ Arguments are handled properly
- ✅ Listed in category README
Workflow: Configuring a Hook
When: You need automated behavior on specific events
Steps:
- Identify trigger: PreToolUse, PostToolUse, Stop, SubagentStop
- Create script (if command type):
.claude/hooks/<name>.sh
- Write hook logic using hook variables ($TOOL_NAME, $ARGUMENTS, etc.)
- Configure in
settings.json with matcher and hook type
- Test hook fires on correct event
- Verify output is clear and helpful
- Document in
.claude/hooks/README.md
Success criteria:
- ✅ Hook fires on correct event
- ✅ Hook provides clear feedback
- ✅ Hook doesn't cause unintended side effects
- ✅ Hook is documented
Workflow: Adding a New Module
When: A new technology/concern needs to be installable via the setup process
Steps:
- Choose the right category section in
docs/reference/module-registry.yml
- Add the module entry with all required fields:
- name: my-module
description: One-line description of what this module provides
skill: af-relevant-expertise # Existing skill for this domain
guide: guides/path/to-guide.md # Setup guide (optional for simple modules)
validation_spec: my-module.spec.ts
depends_on:
- git # List dependencies
integrations: # Cross-module integration guides (optional)
- when: [my-module, other-module]
guide: guides/integrations/my-other.md
- Create validation spec:
templates/setup/validation/specs/my-module.spec.ts
- Follow existing spec patterns (check CLI tools, config files, project structure)
- Use
test.todo() for tests that need external services (never test.skip())
- Add project entry to
templates/setup/validation/playwright.config.ts
- Update
templates/setup/validation/package.json test scripts
- Create integration guides if this module interacts with others (see next workflow)
- Run validation:
npx ts-node scripts/validation/validate-module-registry.ts
- If adding a combination, add it under the
combinations: section
Success criteria:
- Registry validation passes (all checks green)
- Validation spec exists and runs against a test project
- Dependencies are correctly declared
- Integration guides exist for all declared integrations
Workflow: Creating an Integration Guide
When: Two modules interact and need cross-cutting setup knowledge
Steps:
- Create file:
docs/guides/integrations/<module-a>-<module-b>.md
- Add frontmatter (title, created, updated, tags, parent)
- Structure content:
- Problem: What goes wrong without this guide
- Solution: Step-by-step configuration
- Verification: How to confirm it works
- Reference the guide in module-registry.yml under
integrations:integrations:
- when: [module-a, module-b]
guide: guides/integrations/module-a-module-b.md
- Update
docs/guides/integrations/README.md children array
- Run registry validation to confirm guide file exists
Success criteria:
- Guide explains the cross-cutting concern clearly
- Referenced in module-registry.yml under correct module(s)
- Listed in integrations README
Workflow: Creating a Module Validation Spec
When: A module needs a Playwright spec to verify its setup
Steps:
- Create file:
templates/setup/validation/specs/<module-name>.spec.ts
- Import from
@playwright/test and use test.describe('<module-name> module', ...)
- Read
PROJECT_ROOT from environment for file path assertions
- Test categories:
- CLI tools: Verify required CLIs are installed (
which <tool>)
- Config files: Verify required files exist in project
- Project structure: Verify directories and conventions
- External services: Verify accounts/configs (use
test.todo() if fragile — never test.skip())
- Add to
playwright.config.ts:{ name: 'my-module', testMatch: 'specs/my-module.spec.ts' },
- Add test script to
package.json:"test:my-module": "npx playwright test --project=my-module"
- Test against a real project:
PROJECT_ROOT=/path/to/project npm run test:my-module
Success criteria:
- Spec runs and produces clear pass/fail results
- Core module specs always pass on any AgentFlow project
- Optional module specs pass only when that module is installed
- Graceful skips for tests requiring external services
Examples
Good Example: Lightweight Agent
## Procedure
1. **MUST load expertise skill**
Load `af-write-bdd-scenarios` skill for scenario patterns
2. **MUST read Linear issue**
Extract requirements and acceptance criteria
3. **MUST transform to Markdown scenarios**
Follow skill workflow: "Creating Scenarios from Refinement"
Apply glossary compliance rules
4. **SHOULD validate output**
Check coverage and test type classification
Why this is good:
- Agent is thin (~30 lines)
- Loads skill for domain knowledge
- Clear MUST/SHOULD directives
- References skill workflows
Bad Example: Heavy Agent
## Procedure
1. Understand scenario syntax:
Preconditions: initial state
Steps: user actions
[200 lines of scenario reference...]
2. Check glossary for approved terms
[100 lines explaining glossary...]
Why this is bad:
- Agent contains reference material (should be in skill)
- No skill loading
- Too verbose (~400 lines)
- Knowledge baked in instead of reusable
Good Example: Directive Skill
## Rules (FOLLOW THESE)
1. All test files must end in `.test.ts` or `.spec.ts`
2. Never mock internal code - only external dependencies
3. Tests must be independent (no shared state)
## Workflows
### Workflow: Writing Unit Tests from BDD
1. Read BDD scenario Given/When/Then
2. Create test file: `<feature>.test.ts`
3. Write describe block matching Feature name
4. Write it block for each Scenario
5. Implement Given (setup), When (action), Then (assertions)
6. Run tests: `npm test`
Why this is good:
- Rules up front
- Step-by-step workflow
- Actionable directives
- Under 200 lines
Bad Example: Reference-Heavy Skill
## Testing in TypeScript
TypeScript provides excellent support for testing...
[500 lines explaining testing concepts, frameworks, patterns...]
Jest is a popular choice because...
Mocha is another option...
Why this is bad:
- Reads like documentation, not directives
- No clear workflows
- Too long (500+ lines)
- Claude treats as "background reading" and may skip
Essential Reading
Comprehensive framework development guide:
Module system:
Architecture and standards:
Claude Code official docs:
Remember:
- Framework components use
af- prefix
- Agents are lightweight, skills are directive
- Comprehensive details go in guides
- Always validate and test before considering complete
- Run docs-quality-agent after framework changes
- New modules need: registry entry, validation spec, playwright config, package.json script
- Run
validate-module-registry.ts after any registry changes
1---2name: af-modify-agentflow3description: Modify AgentFlow framework components including agents, skills, commands, hooks, and modules. Use when creating or changing framework infrastructure, documentation tooling, or module definitions.4---5
6# AgentFlow Framework Development
7
8## When to Use This Skill
9
10Load this skill when you need to:
11- Create or modify agents, skills, commands, or hooks
12- Add or modify modules in the module registry
13- Create integration guides for cross-module concerns
14- Create or update module validation specs
15- Understand framework component structure and V2 architecture
16- Apply namespace rules and documentation standards
17
18## Rules (FOLLOW THESE)
19
20### Namespace Rules
211. **All framework components** use `af-` prefix (agents, skills, commands)
222. **Project-specific components** never use `af-` prefix
233. **Never mix** framework and project components in same file
24
25### Documentation Rules
264. **All framework files** require complete frontmatter (title, created, updated, tags, parent)
275. **Bidirectional linking** is mandatory - parent lists children, child references parent
286. **Run docs-quality-agent** after any framework changes
297. **Update dates** when modifying files (updated, last_checked)
30
31### Size Rules
328. **Agents must be lightweight** (~50 lines of procedure)
339. **Skills must be directive** (rules + workflows, not reference dumps)
3410. **Skills must be under 300 lines** (target: 150-200)
3511. **Skills link to comprehensive docs** for depth
36
37### Structure Rules
3812. **Agents reference skills** for domain knowledge (use backticks: `af-skill-name`)
3913. **Agents have clear I/O** specifications (inputs, outputs)
4014. **Skills use MUST/SHOULD/MAY** directives for clarity
4115. **Commands validate arguments** and provide usage examples
42
43### Validation Rules
4416. **Test components** before considering them complete
4517. **Validate documentation** with scripts (frontmatter, links)
4618. **Restart Claude Code** after creating new skills
4719. **Verify invocation** for agents and commands
48
49### Module Rules
5020. **All modules** are declared in `docs/reference/module-registry.yml`
5121. **Core modules** are always installed (agentflow, linear, git, documentation, doppler)
5222. **Optional modules** are selected during Discovery and installed before Refinement
5323. **Every module** must have: `name`, `description`, `skill`, `validation_spec`, `depends_on`
5424. **Integration guides** are created when two modules interact (e.g., cognito + SES)
5525. **Validation specs** are Playwright tests in `templates/setup/validation/specs/`
5626. **Run `validate-module-registry.ts`** after any registry change (169+ checks)
57
58---
59
60## Workflows
61
62### Workflow: Adding a New Agent
63
64**When:** You need a specialized subagent for a specific domain
65
66**Steps:**
671. Create file: `.claude/agents/af-<domain>-agent.md`
682. Add frontmatter with `name`, `description`, `tools`, `title`, dates, tags, parent
693. Write procedure: Role, Skills Used, Inputs, Procedure, Outputs, Error Handling
704. Keep procedure ~50 lines (load skills, don't duplicate knowledge)
715. Update `.claude/agents/README.md` children array
726. Validate: `npx ts-node .claude/scripts/validate-frontmatter.ts`
737. Test invocation: `Task tool → subagent_type="af-<domain>-agent"`
748. Run docs-quality-agent for comprehensive validation
75
76**Success criteria:**
77- ✅ Agent has complete frontmatter and bidirectional links
78- ✅ Agent loads skills for domain knowledge
79- ✅ Agent can be invoked successfully
80- ✅ Validation scripts pass
81
82---
83
84### Workflow: Creating a New Skill
85
86**When:** You need to package domain knowledge for reuse
87
88**Steps:**
891. Create directory: `.claude/skills/af-<name>/`
902. Create file: `.claude/skills/af-<name>/SKILL.md`
913. Add frontmatter with `name`, `description`, `type`, `domain`, dates, tags
924. Structure content: When to Use, Rules (15-20), Workflows (4-5), Examples, Essential Reading
935. Keep under 300 lines (target: 150-200) - move details to comprehensive guide
946. Create guide if needed: `.claude/docs/guides/<domain>-guide.md` (800-1500 lines)
957. Update `.claude/skills/README.md` children array
968. Validate: `npx ts-node .claude/scripts/validate-links.ts`
979. Restart Claude Code session to pick up new skill
9810. Test with agent that loads the skill
99
100**Success criteria:**
101- ✅ Skill is directive (workflows, rules, examples)
102- ✅ Skill is under 300 lines
103- ✅ Skill links to comprehensive docs (if needed)
104- ✅ Agents can load and use skill successfully
105
106---
107
108### Workflow: Adding a Slash Command
109
110**When:** You need a discoverable entry point for a workflow
111
112**Steps:**
1131. Determine category: framework (`/af:`), task (`/task:`), phase-specific
1142. Create file: `.claude/commands/<category>/<action>.md`
1153. Add frontmatter with `description` (shows in autocomplete), dates, tags
1164. Write command body: usage, examples, the prompt that executes
1175. Use `$1`, `$2` for positional args or `$ARGUMENTS` for all args
1186. Update `.claude/commands/<category>/README.md` children array
1197. Test: `/<category>:<action>` should autocomplete and execute
1208. Verify arguments work correctly
121
122**Success criteria:**
123- ✅ Command appears in autocomplete
124- ✅ Command expands and executes correctly
125- ✅ Arguments are handled properly
126- ✅ Listed in category README
127
128---
129
130### Workflow: Configuring a Hook
131
132**When:** You need automated behavior on specific events
133
134**Steps:**
1351. Identify trigger: PreToolUse, PostToolUse, Stop, SubagentStop
1362. Create script (if command type): `.claude/hooks/<name>.sh`
1373. Write hook logic using hook variables ($TOOL_NAME, $ARGUMENTS, etc.)
1384. Configure in `settings.json` with matcher and hook type
1395. Test hook fires on correct event
1406. Verify output is clear and helpful
1417. Document in `.claude/hooks/README.md`
142
143**Success criteria:**
144- ✅ Hook fires on correct event
145- ✅ Hook provides clear feedback
146- ✅ Hook doesn't cause unintended side effects
147- ✅ Hook is documented
148
149---
150
151### Workflow: Adding a New Module
152
153**When:** A new technology/concern needs to be installable via the setup process
154
155**Steps:**
1561. Choose the right category section in `docs/reference/module-registry.yml`
1572. Add the module entry with all required fields:
158 ```yaml
159 - name: my-module
160 description: One-line description of what this module provides
161 skill: af-relevant-expertise # Existing skill for this domain
162 guide: guides/path/to-guide.md # Setup guide (optional for simple modules)
163 validation_spec: my-module.spec.ts
164 depends_on:
165 - git # List dependencies
166 integrations: # Cross-module integration guides (optional)
167 - when: [my-module, other-module]
168 guide: guides/integrations/my-other.md
169 ```
1703. Create validation spec: `templates/setup/validation/specs/my-module.spec.ts`
171 - Follow existing spec patterns (check CLI tools, config files, project structure)
172 - Use `test.todo()` for tests that need external services (never `test.skip()`)
1734. Add project entry to `templates/setup/validation/playwright.config.ts`
1745. Update `templates/setup/validation/package.json` test scripts
1756. Create integration guides if this module interacts with others (see next workflow)
1767. Run validation: `npx ts-node scripts/validation/validate-module-registry.ts`
1778. If adding a combination, add it under the `combinations:` section
178
179**Success criteria:**
180- Registry validation passes (all checks green)
181- Validation spec exists and runs against a test project
182- Dependencies are correctly declared
183- Integration guides exist for all declared integrations
184
185---
186
187### Workflow: Creating an Integration Guide
188
189**When:** Two modules interact and need cross-cutting setup knowledge
190
191**Steps:**
1921. Create file: `docs/guides/integrations/<module-a>-<module-b>.md`
1932. Add frontmatter (title, created, updated, tags, parent)
1943. Structure content:
195 - **Problem**: What goes wrong without this guide
196 - **Solution**: Step-by-step configuration
197 - **Verification**: How to confirm it works
1984. Reference the guide in module-registry.yml under `integrations`:
199 ```yaml
200 integrations:
201 - when: [module-a, module-b]
202 guide: guides/integrations/module-a-module-b.md
203 ```
2045. Update `docs/guides/integrations/README.md` children array
2056. Run registry validation to confirm guide file exists
206
207**Success criteria:**
208- Guide explains the cross-cutting concern clearly
209- Referenced in module-registry.yml under correct module(s)
210- Listed in integrations README
211
212---
213
214### Workflow: Creating a Module Validation Spec
215
216**When:** A module needs a Playwright spec to verify its setup
217
218**Steps:**
2191. Create file: `templates/setup/validation/specs/<module-name>.spec.ts`
2202. Import from `@playwright/test` and use `test.describe('<module-name> module', ...)`
2213. Read `PROJECT_ROOT` from environment for file path assertions
2224. Test categories:
223 - **CLI tools**: Verify required CLIs are installed (`which <tool>`)
224 - **Config files**: Verify required files exist in project
225 - **Project structure**: Verify directories and conventions
226 - **External services**: Verify accounts/configs (use `test.todo()` if fragile — never `test.skip()`)
2275. Add to `playwright.config.ts`:
228 ```typescript
229 { name: 'my-module', testMatch: 'specs/my-module.spec.ts' },
230 ```
2316. Add test script to `package.json`:
232 ```json
233 "test:my-module": "npx playwright test --project=my-module"
234 ```
2357. Test against a real project: `PROJECT_ROOT=/path/to/project npm run test:my-module`
236
237**Success criteria:**
238- Spec runs and produces clear pass/fail results
239- Core module specs always pass on any AgentFlow project
240- Optional module specs pass only when that module is installed
241- Graceful skips for tests requiring external services
242
243---
244
245## Examples
246
247### Good Example: Lightweight Agent
248
249```markdown
250## Procedure
251
2521. **MUST load expertise skill**
253 Load `af-write-bdd-scenarios` skill for scenario patterns
254
2552. **MUST read Linear issue**
256 Extract requirements and acceptance criteria
257
2583. **MUST transform to Markdown scenarios**
259 Follow skill workflow: "Creating Scenarios from Refinement"
260 Apply glossary compliance rules
261
2624. **SHOULD validate output**
263 Check coverage and test type classification
264```
265
266**Why this is good:**
267- Agent is thin (~30 lines)
268- Loads skill for domain knowledge
269- Clear MUST/SHOULD directives
270- References skill workflows
271
272### Bad Example: Heavy Agent
273
274```markdown
275## Procedure
276
2771. Understand scenario syntax:
278 Preconditions: initial state
279 Steps: user actions
280 [200 lines of scenario reference...]
281
2822. Check glossary for approved terms
283 [100 lines explaining glossary...]
284```
285
286**Why this is bad:**
287- Agent contains reference material (should be in skill)
288- No skill loading
289- Too verbose (~400 lines)
290- Knowledge baked in instead of reusable
291
292---
293
294### Good Example: Directive Skill
295
296```markdown
297## Rules (FOLLOW THESE)
2981. All test files must end in `.test.ts` or `.spec.ts`
2992. Never mock internal code - only external dependencies
3003. Tests must be independent (no shared state)
301
302## Workflows
303### Workflow: Writing Unit Tests from BDD
3041. Read BDD scenario Given/When/Then
3052. Create test file: `<feature>.test.ts`
3063. Write describe block matching Feature name
3074. Write it block for each Scenario
3085. Implement Given (setup), When (action), Then (assertions)
3096. Run tests: `npm test`
310```
311
312**Why this is good:**
313- Rules up front
314- Step-by-step workflow
315- Actionable directives
316- Under 200 lines
317
318### Bad Example: Reference-Heavy Skill
319
320```markdown
321## Testing in TypeScript
322
323TypeScript provides excellent support for testing...
324
325[500 lines explaining testing concepts, frameworks, patterns...]
326
327Jest is a popular choice because...
328Mocha is another option...
329```
330
331**Why this is bad:**
332- Reads like documentation, not directives
333- No clear workflows
334- Too long (500+ lines)
335- Claude treats as "background reading" and may skip
336
337---
338
339## Essential Reading
340
341**Comprehensive framework development guide:**
342- [Framework Development Guide](../../docs/guides/framework-development-guide.md) - Complete guide to creating agents, skills, commands, hooks (1700+ lines)
343
344**Module system:**
345- [Module Registry](../../docs/reference/module-registry.yml) - All modules, dependencies, integrations
346- [Integration Guides](../../docs/guides/integrations/README.md) - Cross-module setup knowledge
347- [Validation Specs](../../templates/setup/validation/specs/) - Playwright module validation tests
348- [Registry Validator](../../scripts/validation/validate-module-registry.ts) - 169+ automated checks
349
350**Architecture and standards:**
351- [Documentation Standards](../../docs/standards/documentation-standards.md) - Frontmatter and linking requirements
352- [Framework Architecture](../../docs/architecture/README.md) - V2 architecture overview
353- [Project Structure](../../docs/standards/project-structure.md) - Where files go
354
355**Claude Code official docs:**
356- [Skills](https://code.claude.com/docs/en/skills) - Official skills documentation
357- [Sub-agents](https://code.claude.com/docs/en/sub-agents) - Official agents documentation
358- [Slash Commands](https://code.claude.com/docs/en/slash-commands) - Official commands documentation
359- [Hooks](https://code.claude.com/docs/en/hooks) - Official hooks documentation
360
361---
362
363**Remember:**
3641. Framework components use `af-` prefix
3652. Agents are lightweight, skills are directive
3663. Comprehensive details go in guides
3674. Always validate and test before considering complete
3685. Run docs-quality-agent after framework changes
3696. New modules need: registry entry, validation spec, playwright config, package.json script
3707. Run `validate-module-registry.ts` after any registry changes