claude-flow-novice 2.14.12 → 2.14.13

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 (32) hide show
  1. package/.claude/commands/CFN_LOOP_TASK_MODE.md +51 -7
  2. package/.claude/commands/cfn-loop-cli.md +1 -1
  3. package/.claude/skills/cfn-agent-selector/SKILL.md +2 -2
  4. package/.claude/skills/cfn-agent-selector/SKILL.md.backup_before_replace +91 -0
  5. package/.claude/skills/cfn-agent-selector/select-agents.sh +45 -0
  6. package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +69 -6
  7. package/.claude/skills/cfn-loop-orchestration/helpers/validate-task-context.sh +241 -0
  8. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +17 -0
  9. package/claude-assets/agents/cfn-dev-team/CLAUDE.md +3 -3
  10. package/claude-assets/agents/cfn-dev-team/CLAUDE.md.backup_before_replace +1086 -0
  11. package/claude-assets/agents/cfn-dev-team/README.md +1 -1
  12. package/claude-assets/agents/cfn-dev-team/README.md.backup_before_replace +116 -0
  13. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +2 -2
  14. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md.backup_before_replace +451 -0
  15. package/claude-assets/agents/cfn-dev-team/developers/README.md +3 -3
  16. package/claude-assets/agents/cfn-dev-team/developers/README.md.backup_before_replace +69 -0
  17. package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md +1 -1
  18. package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md.backup_before_replace +465 -0
  19. package/claude-assets/agents/cfn-dev-team/test-agent.md +2 -2
  20. package/claude-assets/agents/cfn-dev-team/test-agent.md.backup_before_replace +141 -0
  21. package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +51 -7
  22. package/claude-assets/commands/cfn-loop-cli.md +1 -1
  23. package/claude-assets/skills/cfn-agent-selector/SKILL.md +2 -2
  24. package/claude-assets/skills/cfn-agent-selector/SKILL.md.backup_before_replace +91 -0
  25. package/claude-assets/skills/cfn-agent-selector/select-agents.sh +45 -0
  26. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +69 -6
  27. package/claude-assets/skills/cfn-loop-orchestration/helpers/validate-task-context.sh +241 -0
  28. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +17 -0
  29. package/dist/cli/config-manager.js +109 -91
  30. package/dist/cli/config-manager.js.map +1 -1
  31. package/package.json +1 -1
  32. package/scripts/init-project.js +36 -1
@@ -0,0 +1,1086 @@
1
+ ---
2
+ name: agent-creation-guide
3
+ description: Practical guide to creating, customizing, and maintaining AI agents in the Claude Flow Novice system
4
+ model: claude-sonnet-4
5
+ tools: [Read, Write, Edit, Bash, Grep, Glob, TodoWrite]
6
+ ---
7
+
8
+ # Agent Creation & Customization Guide
9
+
10
+ **Version:** 4.0.0
11
+ **Last Updated:** 2025-10-20
12
+ **Audience:** NPM Users & Developers
13
+
14
+ This is your practical guide to creating, customizing, and maintaining AI agents in the Claude Flow Novice system. Whether you're using our npm package or building custom workflows, this guide will help you create powerful, specialized agents tailored to your needs.
15
+
16
+ ---
17
+
18
+ ## Table of Contents
19
+
20
+ 1. [Quick Start - Create Your First Agent](#quick-start-create-your-first-agent)
21
+ 2. [Understanding the Agent Directory](#understanding-the-agent-directory)
22
+ 3. [Agent Anatomy](#agent-anatomy)
23
+ 4. [Step-by-Step Agent Creation](#step-by-step-agent-creation)
24
+ 5. [Ready-to-Use Templates](#ready-to-use-templates)
25
+ 6. [Customization Guide](#customization-guide)
26
+ 7. [Testing Your Agent](#testing-your-agent)
27
+ 8. [Advanced Concepts](#advanced-concepts)
28
+ 9. [Troubleshooting](#troubleshooting)
29
+
30
+ ## CFN Dev Team Specific Resources
31
+
32
+ ### New Agent Structure Documentation
33
+ - [CFN Dev Team README.md](./README.md) - Comprehensive guide to our 23 production agents
34
+ - [agent-builder.md](./developers/agent-builder.md) - Specialized agent for creating new agents
35
+ - [Agent Directory Structure](./README.md#directory-structure) - Detailed overview of agent categories
36
+
37
+ ### Agent Discovery Patterns
38
+ - Recursively search `.claude/agents/cfn-dev-team` subdirectories
39
+ - Use Glob: `**/*.md` to find all agent files
40
+ - Validate against agent-template-validator
41
+ - Maintain agent registry via SQLite database
42
+
43
+ ---
44
+
45
+ ## Quick Start - Create Your First Agent
46
+
47
+ ### What You'll Learn
48
+ In 5 minutes, you'll create a custom agent that can perform specialized tasks in your workflow.
49
+
50
+ ### Prerequisites
51
+ ```bash
52
+ # Install claude-flow-novice
53
+ npm install claude-flow-novice
54
+
55
+ # Verify installation
56
+ npx claude-flow-novice --version
57
+ ```
58
+
59
+ ### Your First Agent (3 Steps)
60
+
61
+ **Step 1: Create the agent file**
62
+ ```bash
63
+ mkdir -p .claude/agents/custom
64
+ touch .claude/agents/custom/my-first-agent.md
65
+ ```
66
+
67
+ **Step 2: Add basic configuration**
68
+ ```markdown
69
+ ---
70
+ name: my-first-agent
71
+ description: |
72
+ MUST BE USED when performing [your specific task].
73
+ Keywords - [relevant, keywords, for, your, task]
74
+ tools: [Read, Write, Edit, Bash, TodoWrite]
75
+ model: haiku
76
+ type: specialist
77
+ ---
78
+
79
+ # My First Agent
80
+
81
+ You are a specialized agent that helps with [describe what your agent does].
82
+
83
+ ## Core Responsibilities
84
+ - [Responsibility 1]
85
+ - [Responsibility 2]
86
+ - [Responsibility 3]
87
+
88
+ ## Approach
89
+ [Describe how your agent should approach tasks]
90
+ ```
91
+
92
+ **Step 3: Test your agent**
93
+ ```bash
94
+ # Spawn your agent
95
+ npx claude-flow-novice agent-spawn my-first-agent --task-id test-1
96
+ ```
97
+
98
+ **That's it!** You've created a working agent.
99
+
100
+ ---
101
+
102
+ ## Understanding the Agent Directory
103
+
104
+ ### Directory Structure
105
+
106
+ ```
107
+ .claude/agents/
108
+ ├── CLAUDE.md # This guide
109
+ ├── core-agents/ # Production-ready core agents
110
+ │ ├── coder.md # Code implementation
111
+ │ ├── reviewer.md # Code review & quality
112
+ │ ├── tester.md # Testing & validation
113
+ │ └── coordinator.md # Multi-agent coordination
114
+ ├── development/ # Development-focused agents
115
+ │ ├── backend-dev.md
116
+ │ ├── react-frontend-engineer.md
117
+ │ └── devops-engineer.md
118
+ ├── security/ # Security-focused agents
119
+ │ └── security-specialist.md
120
+ ├── custom/ # YOUR CUSTOM AGENTS GO HERE
121
+ │ └── your-agent.md
122
+ └── templates/ # Reusable templates
123
+ ├── redis-coordination.md
124
+ ├── memory-operations.md
125
+ └── team-dynamics.md
126
+ ```
127
+
128
+ ### Where to Put Your Agents
129
+
130
+ **Option 1: Project-Specific** (Recommended for teams)
131
+ ```bash
132
+ # Lives in your project repo
133
+ <project-root>/.claude/agents/custom/
134
+ ```
135
+ - ✅ Version controlled with your code
136
+ - ✅ Shared across team
137
+ - ✅ Project-specific workflows
138
+
139
+ **Option 2: Personal Agents**
140
+ ```bash
141
+ # Lives in your home directory
142
+ ~/.claude/agents/
143
+ ```
144
+ - ✅ Available across all projects
145
+ - ✅ Personal productivity tools
146
+ - ⚠️ Not shared with team
147
+
148
+ ---
149
+
150
+ ## Agent Anatomy
151
+
152
+ Every agent has three main parts:
153
+
154
+ ### 1. Frontmatter (YAML Configuration)
155
+
156
+ ```yaml
157
+ ---
158
+ name: agent-name # Unique identifier (lowercase, hyphens)
159
+ description: | # What the agent does & when to use it
160
+ MUST BE USED when [use case].
161
+ Keywords - [searchable, terms]
162
+ tools: [Read, Write, Edit, Bash] # Available tools (Bash includes Redis CLI)
163
+ model: haiku # haiku | sonnet | opus
164
+ type: specialist # specialist | coordinator | swarm
165
+ capabilities: # Optional tags
166
+ - api-development
167
+ - database-design
168
+ acl_level: 1 # Data access level (1-5)
169
+ ---
170
+ ```
171
+
172
+ ### 2. Agent Body (Instructions)
173
+
174
+ ```markdown
175
+ # Agent Name
176
+
177
+ Brief description of what this agent does.
178
+
179
+ ## Core Responsibilities
180
+ - Primary duty 1
181
+ - Primary duty 2
182
+
183
+ ## Approach & Methodology
184
+ How the agent thinks about and solves problems.
185
+
186
+ ## Collaboration
187
+ How this agent works with other agents.
188
+
189
+ ## Success Metrics
190
+ How to measure if the agent succeeded.
191
+ ```
192
+
193
+ ### 3. Template References (Optional)
194
+
195
+ ```markdown
196
+ ## Redis Coordination
197
+ → See: `.claude/templates/redis-coordination.md`
198
+
199
+ ## Memory Operations
200
+ → See: `.claude/templates/memory-operations.md`
201
+ ```
202
+
203
+ ---
204
+
205
+ ## Step-by-Step Agent Creation
206
+
207
+ ### Step 1: Define Your Agent's Purpose
208
+
209
+ **Ask yourself:**
210
+ - What specific task will this agent perform?
211
+ - When should it be automatically triggered?
212
+ - What expertise does it need?
213
+ - How will it collaborate with other agents?
214
+
215
+ **Example:**
216
+ > "I need an agent that reviews database schema migrations for security issues and performance problems."
217
+
218
+ ### Step 2: Choose Your Template
219
+
220
+ We provide 3 templates based on task complexity:
221
+
222
+ | Template | Best For | Size | Example Use |
223
+ |----------|----------|------|-------------|
224
+ | **Simple** | Single, focused tasks | 100-200 lines | File formatter, linter |
225
+ | **Standard** | Multi-step workflows | 200-400 lines | API developer, reviewer |
226
+ | **Advanced** | Complex coordination | 400-700 lines | Architect, coordinator |
227
+
228
+ ### Step 3: Create Your Agent File
229
+
230
+ ```bash
231
+ # For a database migration reviewer
232
+ touch .claude/agents/custom/migration-reviewer.md
233
+ ```
234
+
235
+ ### Step 4: Fill in the Template
236
+
237
+ **Simple Template Example:**
238
+
239
+ ```markdown
240
+ ---
241
+ name: migration-reviewer
242
+ description: |
243
+ MUST BE USED when reviewing database migrations for security and performance.
244
+ Use PROACTIVELY for SQL schema changes, migrations, database updates.
245
+ Keywords - database, migration, schema, SQL, security, performance
246
+ tools: [Read, Grep, TodoWrite]
247
+ model: haiku
248
+ type: specialist
249
+ capabilities:
250
+ - database-security
251
+ - sql-review
252
+ - performance-analysis
253
+ acl_level: 3
254
+ ---
255
+
256
+ # Database Migration Reviewer
257
+
258
+ You are a specialized database expert focused on reviewing migration files for
259
+ security vulnerabilities and performance issues.
260
+
261
+ ## Core Responsibilities
262
+
263
+ 1. **Security Review**
264
+ - Check for SQL injection vulnerabilities
265
+ - Validate access control patterns
266
+ - Review encryption of sensitive data
267
+ - Ensure proper sanitization
268
+
269
+ 2. **Performance Analysis**
270
+ - Identify missing indexes
271
+ - Flag inefficient queries
272
+ - Check for N+1 query patterns
273
+ - Validate transaction boundaries
274
+
275
+ 3. **Best Practices**
276
+ - Ensure migrations are reversible
277
+ - Check for breaking changes
278
+ - Validate naming conventions
279
+ - Verify proper error handling
280
+
281
+ ## Review Process
282
+
283
+ 1. Read migration file
284
+ 2. Analyze SQL patterns
285
+ 3. Check against security checklist
286
+ 4. Evaluate performance implications
287
+ 5. Provide actionable feedback
288
+
289
+ ## Output Format
290
+
291
+ Provide a confidence score (0.0-1.0) and structured feedback:
292
+ - Critical issues (must fix)
293
+ - Warnings (should address)
294
+ - Suggestions (nice to have)
295
+ - Approved changes
296
+
297
+ ## Success Metrics
298
+ - Zero critical security issues
299
+ - No obvious performance bottlenecks
300
+ - Migrations are reversible
301
+ - Confidence score ≥ 0.85
302
+ ```
303
+
304
+ ### Step 5: Test Your Agent
305
+
306
+ ```bash
307
+ # Test with a sample task
308
+ npx claude-flow-novice agent-spawn migration-reviewer \
309
+ --task-id test-migration \
310
+ --prompt "Review the migration in db/migrations/001_add_users_table.sql"
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Ready-to-Use Templates
316
+
317
+ ### Template 1: Code Implementer
318
+
319
+ ```markdown
320
+ ---
321
+ name: my-implementer
322
+ description: |
323
+ MUST BE USED when implementing [specific type of code].
324
+ Keywords - implement, build, create, develop
325
+ tools: [Read, Write, Edit, Bash, TodoWrite]
326
+ model: haiku
327
+ type: specialist
328
+ acl_level: 1
329
+ ---
330
+
331
+ # [Type] Implementer
332
+
333
+ You implement [specific type of code] following best practices.
334
+
335
+ ## Core Responsibilities
336
+ - Write clean, maintainable code
337
+ - Follow TDD approach
338
+ - Implement features from specifications
339
+ - Optimize for readability
340
+
341
+ ## Implementation Workflow
342
+ 1. Understand requirements
343
+ 2. Write tests first
344
+ 3. Implement solution
345
+ 4. Refactor for quality
346
+ 5. Validate coverage
347
+
348
+ ## Success Criteria
349
+ - All tests pass
350
+ - Code coverage ≥ 80%
351
+ - Follows coding standards
352
+ - Confidence score ≥ 0.80
353
+ ```
354
+
355
+ ### Template 2: Code Reviewer
356
+
357
+ ```markdown
358
+ ---
359
+ name: my-reviewer
360
+ description: |
361
+ MUST BE USED for reviewing [specific type of code].
362
+ Keywords - review, validate, quality, security
363
+ tools: [Read, Grep, TodoWrite]
364
+ model: haiku
365
+ type: validator
366
+ acl_level: 3
367
+ ---
368
+
369
+ # [Type] Code Reviewer
370
+
371
+ You review [specific type of code] for quality, security, and best practices.
372
+
373
+ ## Review Criteria
374
+
375
+ ### Code Quality
376
+ - [ ] Clear variable names
377
+ - [ ] Proper error handling
378
+ - [ ] Minimal complexity
379
+ - [ ] Good documentation
380
+
381
+ ### Security
382
+ - [ ] No hardcoded secrets
383
+ - [ ] Proper input validation
384
+ - [ ] Safe API usage
385
+ - [ ] No XSS/injection risks
386
+
387
+ ### Performance
388
+ - [ ] Efficient algorithms
389
+ - [ ] No memory leaks
390
+ - [ ] Proper caching
391
+ - [ ] Optimized queries
392
+
393
+ ## Output Format
394
+ Provide confidence score and categorized feedback:
395
+ - 🔴 Critical (blocking issues)
396
+ - 🟡 Warnings (should fix)
397
+ - 🟢 Suggestions (improvements)
398
+
399
+ ## Success Metrics
400
+ - Confidence score ≥ 0.90
401
+ - Zero critical issues
402
+ - Actionable feedback provided
403
+ ```
404
+
405
+ ### Template 3: Specialist Agent
406
+
407
+ ```markdown
408
+ ---
409
+ name: my-specialist
410
+ description: |
411
+ MUST BE USED when [specialized task].
412
+ Use PROACTIVELY for [scenarios].
413
+ Keywords - [domain, specific, keywords]
414
+ tools: [Read, Write, Edit, Bash, Grep, Glob, TodoWrite]
415
+ model: sonnet
416
+ type: specialist
417
+ capabilities:
418
+ - [capability-1]
419
+ - [capability-2]
420
+ acl_level: 1
421
+ ---
422
+
423
+ # [Domain] Specialist
424
+
425
+ You are an expert in [domain] with deep knowledge of [specific expertise].
426
+
427
+ ## Expertise Areas
428
+ - [Area 1]: [Description]
429
+ - [Area 2]: [Description]
430
+ - [Area 3]: [Description]
431
+
432
+ ## Approach
433
+ [How you analyze and solve problems in this domain]
434
+
435
+ ## Tools & Techniques
436
+ - [Tool/Technique 1]
437
+ - [Tool/Technique 2]
438
+ - [Tool/Technique 3]
439
+
440
+ ## Collaboration
441
+ - **With Implementers**: Provide specifications and guidance
442
+ - **With Reviewers**: Share domain expertise
443
+ - **Solo**: Full end-to-end implementation
444
+
445
+ ## Success Metrics
446
+ - Domain-specific quality criteria
447
+ - Stakeholder satisfaction
448
+ - Technical accuracy
449
+ - Confidence score ≥ 0.85
450
+ ```
451
+
452
+ ---
453
+
454
+ ## Customization Guide
455
+
456
+ ### 1. Choosing the Right Model
457
+
458
+ | Model | Speed | Cost | Best For |
459
+ |-------|-------|------|----------|
460
+ | **haiku** | ⚡⚡⚡ | $ | Simple tasks, quick iterations |
461
+ | **sonnet** | ⚡⚡ | $$ | Balanced performance, most tasks |
462
+ | **opus** | ⚡ | $$$ | Complex reasoning, critical tasks |
463
+
464
+ **Recommendation:** Start with `haiku`, upgrade to `sonnet` if needed.
465
+
466
+ ### 2. Selecting Tools
467
+
468
+ Available tools:
469
+ ```yaml
470
+ # File Operations
471
+ tools: [Read, Write, Edit, MultiEdit]
472
+
473
+ # Search & Navigation
474
+ tools: [Grep, Glob]
475
+
476
+ # Execution
477
+ tools: [Bash]
478
+
479
+ # Coordination & Task Management
480
+ tools: [TodoWrite]
481
+
482
+ # Agent Spawning (Coordinators)
483
+ tools: [Bash] # For CLI spawning: npx claude-flow-novice agent-spawn
484
+ ```
485
+
486
+ **Note:** Agent coordination uses Redis pub/sub + CLI spawning, not MCP tools.
487
+
488
+ **Rule of Thumb:** Only include tools your agent will actually use. More tools = more complexity.
489
+
490
+ ### 3. Setting ACL Levels
491
+
492
+ | Level | Scope | Use When |
493
+ |-------|-------|----------|
494
+ | **1** | Private | Agent's own data only |
495
+ | **3** | Swarm | Shared across team of agents |
496
+ | **4** | Project | Strategic decisions, audit logs |
497
+ | **5** | System | Infrastructure only |
498
+
499
+ **Most agents use level 1 or 3.**
500
+
501
+ ### 4. Adding Capabilities (Tags)
502
+
503
+ ```yaml
504
+ capabilities:
505
+ - rust # Language expertise
506
+ - api-design # Domain knowledge
507
+ - security-review # Specialized skill
508
+ - performance-opt # Focus area
509
+ ```
510
+
511
+ These help with agent discovery and routing.
512
+
513
+ ### 5. Customizing Behavior
514
+
515
+ **Tone & Style:**
516
+ ```markdown
517
+ You are a [friendly/professional/technical] agent that [approach].
518
+
519
+ ## Communication Style
520
+ - Use [formal/casual] language
521
+ - Provide [detailed/concise] explanations
522
+ - Focus on [theory/practice]
523
+ ```
524
+
525
+ **Decision-Making:**
526
+ ```markdown
527
+ ## Decision Framework
528
+ When [situation], prioritize:
529
+ 1. [Criterion 1]
530
+ 2. [Criterion 2]
531
+ 3. [Criterion 3]
532
+ ```
533
+
534
+ **Error Handling:**
535
+ ```markdown
536
+ ## Error Handling Strategy
537
+ - For [error type]: [action]
538
+ - If [condition]: [fallback]
539
+ - Always: [safety measure]
540
+ ```
541
+
542
+ ---
543
+
544
+ ## Testing Your Agent
545
+
546
+ ### Manual Testing
547
+
548
+ ```bash
549
+ # Basic spawn test
550
+ npx claude-flow-novice agent-spawn my-agent --task-id test-1
551
+
552
+ # With specific prompt
553
+ npx claude-flow-novice agent-spawn my-agent \
554
+ --task-id test-2 \
555
+ --prompt "Specific task instructions"
556
+ ```
557
+
558
+ ### Integration Testing
559
+
560
+ Create a test task:
561
+ ```bash
562
+ # Create test directory
563
+ mkdir -p tests/agents
564
+
565
+ # Create test file
566
+ cat > tests/agents/test-my-agent.sh << 'EOF'
567
+ #!/bin/bash
568
+ set -e
569
+
570
+ echo "Testing my-agent..."
571
+
572
+ # Spawn agent
573
+ npx claude-flow-novice agent-spawn my-agent \
574
+ --task-id test-integration
575
+
576
+ # Verify output
577
+ # [Add your verification logic]
578
+
579
+ echo "✅ Test passed"
580
+ EOF
581
+
582
+ chmod +x tests/agents/test-my-agent.sh
583
+
584
+ # Run test
585
+ ./tests/agents/test-my-agent.sh
586
+ ```
587
+
588
+ ### Validation Checklist
589
+
590
+ Before deploying your agent:
591
+
592
+ - [ ] YAML frontmatter is valid
593
+ - [ ] Name is unique and descriptive
594
+ - [ ] Description includes use cases and keywords
595
+ - [ ] Tools list includes only needed tools
596
+ - [ ] Core responsibilities are clear
597
+ - [ ] Success metrics are defined
598
+ - [ ] Agent tested with sample tasks
599
+ - [ ] Documentation is complete
600
+
601
+ ---
602
+
603
+ ## Advanced Concepts
604
+
605
+ ### Multi-Agent Coordination
606
+
607
+ Agents can work together using Redis pub/sub and CLI spawning:
608
+
609
+ ```markdown
610
+ ## Redis Coordination
611
+ → See: `.claude/templates/redis-coordination.md`
612
+
613
+ ### Agent Spawning Pattern
614
+ ```bash
615
+ # Spawn agents via CLI (coordinators only)
616
+ npx claude-flow-novice agent-spawn backend-dev --task-id "${TASK_ID}"
617
+ npx claude-flow-novice agent-spawn reviewer --task-id "${TASK_ID}"
618
+ ```
619
+
620
+ ### Signaling Pattern
621
+ ```bash
622
+ # Signal completion
623
+ redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
624
+
625
+ # Wait for other agent (zero-token blocking)
626
+ redis-cli blpop "swarm:${TASK_ID}:other-agent:done" 30
627
+ ```
628
+ ```
629
+
630
+ ### Memory Operations
631
+
632
+ Agents can persist and share data:
633
+
634
+ ```markdown
635
+ ## Memory Operations
636
+ → See: `.claude/templates/memory-operations.md`
637
+
638
+ ### SQLite Integration
639
+ ```typescript
640
+ await sqlite.memoryAdapter.set(
641
+ `agent/${agentId}/data/${taskId}`,
642
+ { confidence: 0.85, status: 'complete' },
643
+ { aclLevel: 1, ttl: 2592000 }
644
+ );
645
+ ```
646
+ ```
647
+
648
+ ### CFN Loop Integration
649
+
650
+ For self-correcting workflows:
651
+
652
+ ```markdown
653
+ ## CFN Loop Mechanics
654
+ → See: `.claude/templates/cfn-loop-mechanics.md`
655
+
656
+ Agents participate in 3-loop validation:
657
+ - Loop 3: Implementation
658
+ - Loop 2: Validation
659
+ - Loop 4: Strategic decisions
660
+ ```
661
+
662
+ ### Lifecycle Hooks
663
+
664
+ ```yaml
665
+ lifecycle:
666
+ pre_task: |
667
+ # Runs before agent starts
668
+ echo "Initializing agent..."
669
+
670
+ post_task: |
671
+ # Runs after agent completes
672
+ echo "Agent completed with confidence: ${CONFIDENCE_SCORE}"
673
+ ```
674
+
675
+ ### Validation Hooks
676
+
677
+ ```yaml
678
+ validation_hooks:
679
+ - agent-template-validator # Validates agent structure
680
+ - cfn-loop-memory-validator # Validates memory operations
681
+ - test-coverage-validator # Validates test coverage
682
+ ```
683
+
684
+ ---
685
+
686
+ ## Troubleshooting
687
+
688
+ ### Agent Not Found
689
+
690
+ **Problem:** `Error: Agent 'my-agent' not found`
691
+
692
+ **Solutions:**
693
+ 1. Check file is in `.claude/agents/` directory
694
+ 2. Verify filename matches agent name: `my-agent.md`
695
+ 3. Ensure YAML frontmatter has `name: my-agent`
696
+
697
+ ### Invalid YAML
698
+
699
+ **Problem:** `Error: Invalid YAML frontmatter`
700
+
701
+ **Solutions:**
702
+ 1. Check YAML syntax with `---` delimiters
703
+ 2. Ensure proper indentation (2 spaces)
704
+ 3. Quote special characters in strings
705
+ 4. Validate at https://www.yamllint.com/
706
+
707
+ ### Agent Behavior Issues
708
+
709
+ **Problem:** Agent doesn't perform as expected
710
+
711
+ **Solutions:**
712
+ 1. Review and clarify core responsibilities
713
+ 2. Simplify instructions (less is often more)
714
+ 3. Add specific examples of desired behavior
715
+ 4. Test with varied prompts
716
+ 5. Check model choice (try upgrading haiku → sonnet)
717
+
718
+ ### Tools Not Working
719
+
720
+ **Problem:** `Error: Tool [X] not available`
721
+
722
+ **Solutions:**
723
+ 1. Verify tool is in frontmatter `tools` list
724
+ 2. Check spelling matches exactly
725
+ 3. For agent spawning, use Bash tool with CLI commands
726
+ 4. Review tool permissions
727
+
728
+ ### Memory/Coordination Issues
729
+
730
+ **Problem:** Agents can't share data
731
+
732
+ **Solutions:**
733
+ 1. Check Redis is running: `redis-cli ping`
734
+ 2. Verify ACL levels are compatible
735
+ 3. Ensure memory keys follow patterns
736
+ 4. Check SQLite database exists
737
+
738
+ ---
739
+
740
+ ## Example: Complete Custom Agent
741
+
742
+ Here's a real-world example - a Terraform reviewer agent:
743
+
744
+ ```markdown
745
+ ---
746
+ name: terraform-reviewer
747
+ description: |
748
+ MUST BE USED when reviewing Terraform infrastructure code.
749
+ Use PROACTIVELY for IaC review, security validation, cost optimization.
750
+ Keywords - terraform, infrastructure, IaC, cloud, AWS, security
751
+ tools: [Read, Grep, Glob, TodoWrite]
752
+ model: sonnet
753
+ type: specialist
754
+ capabilities:
755
+ - terraform
756
+ - infrastructure-as-code
757
+ - cloud-security
758
+ - cost-optimization
759
+ acl_level: 3
760
+ ---
761
+
762
+ # Terraform Infrastructure Reviewer
763
+
764
+ You are an infrastructure expert specializing in Terraform code review with
765
+ focus on security, best practices, and cost optimization.
766
+
767
+ ## Core Responsibilities
768
+
769
+ ### 1. Security Review
770
+ - Check for exposed secrets or credentials
771
+ - Validate IAM policies (principle of least privilege)
772
+ - Review security group rules
773
+ - Ensure encryption at rest and in transit
774
+ - Verify logging and monitoring
775
+
776
+ ### 2. Best Practices
777
+ - Validate resource naming conventions
778
+ - Check for proper tagging strategy
779
+ - Ensure state management best practices
780
+ - Review module structure and reusability
781
+ - Validate provider versioning
782
+
783
+ ### 3. Cost Optimization
784
+ - Identify over-provisioned resources
785
+ - Flag expensive resource types
786
+ - Suggest reserved instances where applicable
787
+ - Review data transfer patterns
788
+ - Validate auto-scaling configurations
789
+
790
+ ### 4. Compliance
791
+ - Check against company standards
792
+ - Validate regulatory requirements
793
+ - Ensure disaster recovery provisions
794
+ - Review backup strategies
795
+
796
+ ## Review Process
797
+
798
+ 1. **Parse Terraform Files**
799
+ - Read all `.tf` files in directory
800
+ - Identify resource types and configurations
801
+ - Map dependencies
802
+
803
+ 2. **Security Analysis**
804
+ - Run security checklist
805
+ - Flag critical issues
806
+ - Identify vulnerabilities
807
+
808
+ 3. **Cost Analysis**
809
+ - Estimate monthly costs
810
+ - Identify optimization opportunities
811
+ - Calculate potential savings
812
+
813
+ 4. **Compliance Check**
814
+ - Verify against standards
815
+ - Document exceptions
816
+ - Recommend remediation
817
+
818
+ 5. **Generate Report**
819
+ - Categorize findings by severity
820
+ - Provide specific recommendations
821
+ - Include confidence score
822
+
823
+ ## Output Format
824
+
825
+ ### Summary
826
+ - Overall confidence score (0.0-1.0)
827
+ - Total issues found by severity
828
+ - Estimated monthly cost
829
+ - Compliance status
830
+
831
+ ### Detailed Findings
832
+
833
+ **🔴 Critical Issues** (must fix before deployment)
834
+ - [Issue description]
835
+ - File: `path/to/file.tf:line`
836
+ - Recommendation: [specific fix]
837
+
838
+ **🟡 Warnings** (should address)
839
+ - [Issue description]
840
+ - Impact: [description]
841
+ - Suggestion: [improvement]
842
+
843
+ **🟢 Optimizations** (nice to have)
844
+ - [Opportunity description]
845
+ - Potential savings: [amount]
846
+ - Effort: [low/medium/high]
847
+
848
+ ## Success Metrics
849
+ - Security score ≥ 0.90
850
+ - Zero critical vulnerabilities
851
+ - Cost optimization opportunities identified
852
+ - Compliance requirements met
853
+ - Clear, actionable feedback
854
+
855
+ ## Collaboration
856
+ - **With DevOps**: Review infrastructure changes
857
+ - **With Security Team**: Validate security posture
858
+ - **With Finance**: Optimize cloud spend
859
+ - **Solo**: Complete IaC review and reporting
860
+ ```
861
+
862
+ **Usage:**
863
+ ```bash
864
+ npx claude-flow-novice agent-spawn terraform-reviewer \
865
+ --prompt "Review Terraform files in ./infrastructure"
866
+ ```
867
+
868
+ ---
869
+
870
+ ## Quick Reference
871
+
872
+ ### Common Agent Patterns
873
+
874
+ **Code Writer:**
875
+ ```yaml
876
+ tools: [Read, Write, Edit, Bash, TodoWrite]
877
+ model: haiku
878
+ type: specialist
879
+ acl_level: 1
880
+ ```
881
+
882
+ **Code Reviewer:**
883
+ ```yaml
884
+ tools: [Read, Grep, TodoWrite]
885
+ model: sonnet
886
+ type: validator
887
+ acl_level: 3
888
+ ```
889
+
890
+ **Coordinator:**
891
+ ```yaml
892
+ tools: [Read, Bash, TodoWrite] # Bash for Redis CLI + agent spawning
893
+ model: sonnet
894
+ type: coordinator
895
+ acl_level: 3
896
+ ```
897
+
898
+ ### File Naming Convention
899
+
900
+ ```
901
+ .claude/agents/
902
+ ├── [category]/
903
+ │ └── [agent-name].md # lowercase, hyphens, descriptive
904
+ ```
905
+
906
+ **Good:** `terraform-reviewer.md`, `api-security-validator.md`
907
+ **Bad:** `TerraformReviewer.md`, `agent1.md`, `myAgent.md`
908
+
909
+ ### Essential YAML Fields
910
+
911
+ **Minimum required:**
912
+ ```yaml
913
+ ---
914
+ name: agent-name
915
+ description: |
916
+ What the agent does and when to use it
917
+ tools: [Read, Write]
918
+ model: haiku
919
+ ---
920
+ ```
921
+
922
+ **Recommended:**
923
+ ```yaml
924
+ ---
925
+ name: agent-name
926
+ description: |
927
+ MUST BE USED when [use case]
928
+ Keywords - [keywords]
929
+ tools: [Read, Write, Edit, TodoWrite]
930
+ model: haiku
931
+ type: specialist
932
+ capabilities: [capability-tags]
933
+ acl_level: 1
934
+ ---
935
+ ```
936
+
937
+ ---
938
+
939
+ ## Resources
940
+
941
+ ### Template Files
942
+ - `.claude/templates/redis-coordination.md` - Multi-agent coordination
943
+ - `.claude/templates/memory-operations.md` - Data persistence
944
+ - `.claude/templates/team-dynamics.md` - Agent collaboration
945
+ - `.claude/templates/cfn-loop-mechanics.md` - Self-correcting workflows
946
+
947
+ ### Example Agents
948
+ - `.claude/agents/core-agents/coder.md` - Code implementation
949
+ - `.claude/agents/core-agents/reviewer.md` - Code review
950
+ - `.claude/agents/core-agents/tester.md` - Testing & validation
951
+ - `.claude/agents/development/backend-dev.md` - Backend development
952
+ - `.claude/agents/security/security-specialist.md` - Security analysis
953
+
954
+ ### Documentation
955
+ - `README.md` - Project overview
956
+ - `.claude/skills/` - Reusable skill modules
957
+ - `.claude/commands/` - Slash command definitions
958
+
959
+ ### Technical Deep-Dive
960
+
961
+ For advanced users who want to understand the theoretical foundations:
962
+ - [Format Selection Principles](./agent-principles/format-selection.md)
963
+ - [Agent Type Guidelines](./agent-principles/agent-type-guidelines.md)
964
+ - [Prompt Engineering Best Practices](./agent-principles/prompt-engineering.md)
965
+ - [Quality Metrics & Validation](./agent-principles/quality-metrics.md)
966
+
967
+ ---
968
+
969
+ ## Need Help?
970
+
971
+ ### Common Questions
972
+
973
+ **Q: How many agents should I create?**
974
+ A: Start with 1-3 focused agents. Add more as needed. Quality > quantity.
975
+
976
+ **Q: Should I modify core agents?**
977
+ A: No, create custom agents instead. Core agents may be updated in new releases.
978
+
979
+ **Q: Can agents call other agents?**
980
+ A: Yes! Coordinators spawn agents via CLI: `npx claude-flow-novice agent-spawn [agent-name]`
981
+
982
+ **Q: How do I share agents with my team?**
983
+ A: Put them in `.claude/agents/` and commit to git.
984
+
985
+ **Q: What's the difference between skills and agents?**
986
+ A: Skills are reusable behaviors (like templates). Agents are executable workers that use skills.
987
+
988
+ ### Getting Help
989
+
990
+ 1. Check existing agents for examples
991
+ 2. Review template files for patterns
992
+ 3. Test incrementally with simple tasks
993
+ 4. Start simple, add complexity gradually
994
+ 5. Open issues on GitHub for bugs
995
+
996
+ ---
997
+
998
+ ## What's Next?
999
+
1000
+ Now that you understand agent creation, explore:
1001
+
1002
+ 1. **Multi-Agent Workflows** - Coordinate multiple agents for complex tasks
1003
+ 2. **CFN Loop Integration** - Build self-correcting pipelines
1004
+ 3. **Custom Skills** - Create reusable behavior modules
1005
+ 4. **Web Portal** - Monitor agent execution in real-time
1006
+ 5. **Advanced Coordination** - Redis pub/sub, memory operations
1007
+
1008
+ **Ready to build something amazing? Start creating your first agent!**
1009
+
1010
+ ---
1011
+
1012
+ ## CFN Loop Completion Protocol (CRITICAL UPDATE)
1013
+
1014
+ **Date:** 2025-10-30
1015
+ **Status:** Waiting Mode Deprecated
1016
+
1017
+ ### Current Standard Protocol
1018
+
1019
+ All agents participating in CFN Loop workflows MUST follow this protocol:
1020
+
1021
+ **Step 1: Complete Work**
1022
+ Execute assigned task (implementation, validation, review, etc.)
1023
+
1024
+ **Step 2: Signal Completion**
1025
+ ```bash
1026
+ redis-cli lpush "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
1027
+ ```
1028
+
1029
+ **Step 3: Report Confidence Score and Exit**
1030
+ ```bash
1031
+ ./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh report \
1032
+ --task-id "$TASK_ID" \
1033
+ --agent-id "$AGENT_ID" \
1034
+ --confidence [0.0-1.0] \
1035
+ --iteration 1
1036
+ ```
1037
+
1038
+ **After reporting, exit cleanly. Do NOT enter waiting mode.**
1039
+
1040
+ ### Why This Matters
1041
+
1042
+ - Orchestrator collects confidence/consensus scores from Redis
1043
+ - Enables adaptive agent specialization for next iteration
1044
+ - Prevents orchestrator blocking on `wait $PID`
1045
+ - Coordinator spawns appropriate specialist based on feedback type
1046
+
1047
+ ### Deprecated Patterns (DO NOT USE)
1048
+
1049
+ ❌ **Step 4: Enter Waiting Mode** (REMOVED)
1050
+ ```bash
1051
+ # DEPRECATED - This will cause errors
1052
+ ./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh enter \
1053
+ --task-id "$TASK_ID" --agent-id "$AGENT_ID"
1054
+ ```
1055
+
1056
+ ❌ **Wake Agents for Iteration** (REMOVED)
1057
+ ```bash
1058
+ # DEPRECATED - Spawn fresh agents instead
1059
+ ./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh wake \
1060
+ --task-id "$TASK_ID" --agent-id "$AGENT_ID"
1061
+ ```
1062
+
1063
+ ### Correct Iteration Pattern
1064
+
1065
+ **Coordinators:** Spawn fresh agents for each iteration:
1066
+ ```bash
1067
+ # Iteration N+1
1068
+ for agent in "${agents[@]}"; do
1069
+ npx claude-flow-novice agent-spawn "$agent" \
1070
+ --task-id "$TASK_ID" \
1071
+ --context "Iteration $iteration: Address feedback [...]"
1072
+ done
1073
+ ```
1074
+
1075
+ ### Related Documentation
1076
+
1077
+ - **Bug Fix Details:** `docs/BUG_WAITING_MODE_FIX.md`
1078
+ - **Agent Lifecycle:** `.claude/agents/AGENT_LIFECYCLE.md`
1079
+ - **Redis Coordination:** `.claude/skills/cfn-redis-coordination/SKILL.md`
1080
+
1081
+ ---
1082
+
1083
+ **Document Version:** 4.1.0 (Waiting Mode Deprecation Update)
1084
+ **Last Updated:** 2025-10-30
1085
+ **Maintained By:** Claude Flow Novice Team
1086
+ **Feedback:** We'd love to hear how you're using agents! Share your creations.