$npx -y skills add evan043/claude-cli-advanced-starter-pack --skill rag-agent-creatorCreate RAG-enhanced Claude Code agents with structured knowledge bases, retrieval strategies, and domain expertise
| 1 | # RAG Agent Creator Skill |
| 2 | |
| 3 | Expert-level RAG (Retrieval-Augmented Generation) agent creation for Claude Code CLI. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | This skill is automatically invoked when: |
| 8 | |
| 9 | - Creating agents that need domain-specific expertise |
| 10 | - Setting up knowledge bases for agent reference |
| 11 | - Designing retrieval strategies for agent context |
| 12 | - Building multi-source knowledge systems |
| 13 | |
| 14 | ## What is RAG for Claude Code? |
| 15 | |
| 16 | RAG (Retrieval-Augmented Generation) agents combine: |
| 17 | |
| 18 | 1. **Retrieval** - Find relevant context from knowledge base |
| 19 | 2. **Augmentation** - Inject context into agent prompt |
| 20 | 3. **Generation** - Agent produces informed responses |
| 21 | |
| 22 | ### When to Add RAG Capabilities |
| 23 | |
| 24 | Add RAG when your agent needs: |
| 25 | |
| 26 | - **Domain-specific expertise** - Specialized knowledge |
| 27 | - **Large knowledge base** - Multiple docs, patterns, examples |
| 28 | - **Consistent retrieval** - Predictable keyword-to-file mappings |
| 29 | - **Protocol-based workflows** - Documented procedures |
| 30 | |
| 31 | ## RAG Directory Structure |
| 32 | |
| 33 | ``` |
| 34 | .claude/skills/{agent-name}/ |
| 35 | skill.md # Main skill definition |
| 36 | context/ # Knowledge base |
| 37 | README.md # Knowledge index |
| 38 | PROTOCOL.md # Agent protocols (optional) |
| 39 | architecture/ # Architecture docs |
| 40 | patterns/ # Code/workflow patterns |
| 41 | examples/ # Example implementations |
| 42 | rag/ # RAG-specific config |
| 43 | README.md # Retrieval strategy |
| 44 | RETRIEVAL_MATRIX.md # Keyword mappings |
| 45 | workflows/ |
| 46 | README.md |
| 47 | rag-orchestrator-agent.md # RAG coordination |
| 48 | rag-implementation-agent.md # RAG implementation |
| 49 | ``` |
| 50 | |
| 51 | ## Knowledge Base Design |
| 52 | |
| 53 | ### Key Principles |
| 54 | |
| 55 | 1. **Atomic Files** - One concept per file for precise retrieval |
| 56 | 2. **Clear Naming** - Descriptive names (e.g., `basetab-pattern.md`) |
| 57 | 3. **Indexed** - Maintain README.md with file descriptions |
| 58 | 4. **Cross-Referenced** - Link related documents |
| 59 | |
| 60 | ### Example Knowledge Organization |
| 61 | |
| 62 | ``` |
| 63 | context/ |
| 64 | README.md # Index: lists all files |
| 65 | PROTOCOL.md # Core rules for agent |
| 66 | |
| 67 | architecture/ |
| 68 | README.md # Architecture overview |
| 69 | database-schema.md # Database structure |
| 70 | api-design.md # API patterns |
| 71 | |
| 72 | patterns/ |
| 73 | README.md # Pattern index |
| 74 | error-handling.md # Error patterns |
| 75 | validation.md # Input validation |
| 76 | caching.md # Cache strategies |
| 77 | |
| 78 | examples/ |
| 79 | README.md # Example index |
| 80 | feature-implementation.md # Complete feature |
| 81 | api-endpoint.md # API example |
| 82 | test-suite.md # Testing example |
| 83 | ``` |
| 84 | |
| 85 | ## Retrieval Patterns |
| 86 | |
| 87 | ### Pattern 1: Keyword Matching |
| 88 | |
| 89 | Map keywords to specific knowledge files: |
| 90 | |
| 91 | ```markdown |
| 92 | ## Retrieval Matrix |
| 93 | |
| 94 | | Keyword Pattern | Files to Load | Priority | |
| 95 | |-----------------|---------------|----------| |
| 96 | | "authentication" | `patterns/auth.md`, `examples/auth.md` | High | |
| 97 | | "database" | `architecture/database.md`, `patterns/repository.md` | Medium | |
| 98 | | "testing" | `patterns/testing.md`, `examples/test-example.md` | High | |
| 99 | | "error" | `patterns/error-handling.md` | Medium | |
| 100 | ``` |
| 101 | |
| 102 | ### Pattern 2: Hierarchical Retrieval |
| 103 | |
| 104 | Start specific, broaden if needed: |
| 105 | |
| 106 | 1. Load specific pattern file (e.g., `patterns/auth.md`) |
| 107 | 2. If insufficient, load architecture file (e.g., `architecture/security.md`) |
| 108 | 3. If still needed, load examples (e.g., `examples/auth-implementation.md`) |
| 109 | |
| 110 | ### Pattern 3: Category-Based |
| 111 | |
| 112 | Group knowledge by domain: |
| 113 | |
| 114 | ```markdown |
| 115 | ## Categories |
| 116 | |
| 117 | ### Backend |
| 118 | - `architecture/api-design.md` |
| 119 | - `patterns/repository.md` |
| 120 | - `patterns/service-layer.md` |
| 121 | |
| 122 | ### Frontend |
| 123 | - `architecture/component-structure.md` |
| 124 | - `patterns/state-management.md` |
| 125 | - `patterns/form-handling.md` |
| 126 | |
| 127 | ### Testing |
| 128 | - `patterns/unit-testing.md` |
| 129 | - `patterns/e2e-testing.md` |
| 130 | - `examples/test-suite.md` |
| 131 | ``` |
| 132 | |
| 133 | ### Pattern 4: Priority-Based |
| 134 | |
| 135 | Load based on task importance: |
| 136 | |
| 137 | ```markdown |
| 138 | ## Priority Levels |
| 139 | |
| 140 | ### Always Load (P1) |
| 141 | - `PROTOCOL.md` - Core rules |
| 142 | - `architecture/README.md` - Overview |
| 143 | |
| 144 | ### Load for Implementation (P2) |
| 145 | - Relevant `patterns/*.md` |
| 146 | - Relevant `architecture/*.md` |
| 147 | |
| 148 | ### Load for Examples (P3) |
| 149 | - `examples/*.md` - When needed |
| 150 | ``` |
| 151 | |
| 152 | ## Creating a RAG Agent |
| 153 | |
| 154 | ### Step 1: Define Knowledge Domain |
| 155 | |
| 156 | What expertise does this agent need? |
| 157 | |
| 158 | ```markdown |
| 159 | ## Domain: E-commerce Backend |
| 160 | |
| 161 | ### Topics Covered |
| 162 | - Product management |
| 163 | - Order processing |
| 164 | - Inventory tracking |
| 165 | - Payment integration |
| 166 | - User authentication |
| 167 | ``` |
| 168 | |
| 169 | ### Step 2: Create Knowledge Structure |
| 170 | |
| 171 | ```bash |
| 172 | mkdir -p .claude/skills/my-agent/context/{architecture,patterns,examples,rag} |
| 173 | ``` |
| 174 | |
| 175 | ### Step 3: Write Knowledge Files |
| 176 | |
| 177 | Each file should be self-contained: |
| 178 | |
| 179 | ```markdown |
| 180 | # Pattern: Repository |
| 181 | |
| 182 | ## Purpose |
| 183 | Encapsulate data access logic. |
| 184 | |
| 185 | ## Implementation |
| 186 | [Code examples] |
| 187 | |
| 188 | ## When to Use |
| 189 | [Scenarios] |
| 190 | |
| 191 | ## Anti |