@@ -179,19 +179,49 @@ find .claude/docs -name "*.md" -type f 2>/dev/null
179179find ~ /.claude/docs -name " *.md" -type f 2> /dev/null
180180```
181181
182- ** Step 2: Grep to list all .md files **
182+ ** Step 2: Read frontmatter of each learning to filter **
183183
184- ``` bash
185- # Get list of all learning files
186- ls -la docs/solutions/** /* .md 2> /dev/null
184+ Each learning file has YAML frontmatter with metadata. Read the first ~ 20 lines of each file to get:
185+
186+ ``` yaml
187+ ---
188+ title : " N+1 Query Fix for Briefs"
189+ category : performance-issues
190+ tags : [activerecord, n-plus-one, includes, eager-loading]
191+ module : Briefs
192+ symptom : " Slow page load, multiple queries in logs"
193+ root_cause : " Missing includes on association"
194+ ---
195+ ```
196+
197+ ** For each .md file, quickly scan its frontmatter:**
187198
188- # Or use find with full paths
189- find docs/solutions -name " *.md" -exec echo {} \;
199+ ``` bash
200+ # Read first 20 lines of each learning (frontmatter + summary)
201+ head -20 docs/solutions/** /* .md
190202```
191203
192- ** Step 3: For EACH .md file found, spawn a sub-agent**
204+ ** Step 3: Filter - only spawn sub-agents for LIKELY relevant learnings**
205+
206+ Compare each learning's frontmatter against the plan:
207+ - ` tags: ` - Do any tags match technologies/patterns in the plan?
208+ - ` category: ` - Is this category relevant? (e.g., skip deployment-issues if plan is UI-only)
209+ - ` module: ` - Does the plan touch this module?
210+ - ` symptom: ` / ` root_cause: ` - Could this problem occur with the plan?
193211
194- For EVERY markdown file discovered:
212+ ** SKIP learnings that are clearly not applicable:**
213+ - Plan is frontend-only → skip ` database-migrations/ ` learnings
214+ - Plan is Python → skip ` rails-specific/ ` learnings
215+ - Plan has no auth → skip ` authentication-issues/ ` learnings
216+
217+ ** SPAWN sub-agents for learnings that MIGHT apply:**
218+ - Any tag overlap with plan technologies
219+ - Same category as plan domain
220+ - Similar patterns or concerns
221+
222+ ** Step 4: Spawn sub-agents for filtered learnings**
223+
224+ For each learning that passes the filter:
195225
196226```
197227Task general-purpose: "
@@ -200,40 +230,39 @@ LEARNING FILE: [full path to .md file]
2002301. Read this learning file completely
2012312. This learning documents a previously solved problem
202232
203- Check if this learning applies to ANY part of this plan:
233+ Check if this learning applies to this plan:
204234
205235---
206236[full plan content]
207237---
208238
209- If the learning IS relevant:
239+ If relevant:
210240- Explain specifically how it applies
211- - Quote the key insight or solution from the learning
212- - Suggest exactly where/how to incorporate it into the plan
241+ - Quote the key insight or solution
242+ - Suggest where/how to incorporate it
213243
214- If NOT relevant:
215- - Say 'Not applicable: [brief reason]'
244+ If NOT relevant after deeper analysis :
245+ - Say 'Not applicable: [reason]'
216246"
217247```
218248
219- ** CRITICAL: Spawn ALL sub-agents in PARALLEL**
220- - Find 10 learning files? Spawn 10 sub-agents
221- - Find 50 learning files? Spawn 50 sub-agents
222- - 1 sub-agent per .md file, all running simultaneously
223-
224- ** Example:**
249+ ** Example filtering:**
225250```
226- # If find returns:
227- docs/solutions/performance-issues/n-plus-one-queries.md
228- docs/solutions/debugging-patterns/turbo-stream-debugging.md
229- docs/solutions/configuration-fixes/redis-connection-pool.md
230-
231- # Spawn 3 parallel sub-agents:
232- Task general-purpose: "LEARNING FILE: docs/solutions/performance-issues/n-plus-one-queries.md ..."
233- Task general-purpose: "LEARNING FILE: docs/solutions/debugging-patterns/turbo-stream-debugging.md ..."
234- Task general-purpose: "LEARNING FILE: docs/solutions/configuration-fixes/redis-connection-pool.md ..."
251+ # Found 15 learning files, plan is about "Rails API caching"
252+
253+ # SPAWN (likely relevant):
254+ docs/solutions/performance-issues/n-plus-one-queries.md # tags: [activerecord] ✓
255+ docs/solutions/performance-issues/redis-cache-stampede.md # tags: [caching, redis] ✓
256+ docs/solutions/configuration-fixes/redis-connection-pool.md # tags: [redis] ✓
257+
258+ # SKIP (clearly not applicable):
259+ docs/solutions/deployment-issues/heroku-memory-quota.md # not about caching
260+ docs/solutions/frontend-issues/stimulus-race-condition.md # plan is API, not frontend
261+ docs/solutions/authentication-issues/jwt-expiry.md # plan has no auth
235262```
236263
264+ ** Spawn sub-agents in PARALLEL for all filtered learnings.**
265+
237266** These learnings are institutional knowledge - applying them prevents repeating past mistakes.**
238267
239268### 4. Launch Per-Section Research Agents
0 commit comments