We need to improve the Reflect feature in the app. Take a look at the implementation and understand how it is built and what insights it generates, including the session insights API. I am mainly looking at effective patterns part of it. Internalize the details and we will discuss next
Assistant
Let me explore the Reflect feature implementation thoroughly.
Assistant
I've thoroughly explored the Reflect feature. Here's a comprehensive summary:
★ Insight ─────────────────────────────────────Reflect is a two-stage architecture: First, per-session facets are extracted during sync (friction points, effective patterns, outcomes, workflow patterns). Then, cross-session synthesis aggregates these facets and sends pre-computed counts to an LLM for narrative generation — the LLM never sees raw session data during synthesis, only aggregated statistics. This is a smart cost/privacy optimization.
─────────────────────────────────────────────────
Working Style — Distribution data (outcomes, workflows, session characters) → personality tagline + narrative
Effective Patterns Specifically
Extraction: During session analysis, the LLM identifies techniques that worked well, stored as { description: string, confidence: 0-100 } in session_facets.effective_patterns (JSON array).
Aggregation (server/src/routes/shared-aggregation.ts): SQL groups by exact description match, counts frequency, averages confidence. Only patterns with 2+ occurrences make it into synthesis.
Display (dashboard):
Insights tab — Top 8 patterns with frequency badges (e.g., "7x"), plus merged into the friction-wins narrative as topWins
Artifacts tab — "Pattern Ingredients" showing all 2+ occurrence patterns
Key limitation: Aggregation uses exact string matching on descriptions, meaning semantically identical patterns with different wording are counted separately.
Friction categories get a sophisticated normalization pipeline (friction-normalize.ts) with canonical categories, alias matching, Levenshtein distance, and substring matching. Effective patterns have no normalization — they rely on raw LLM output matching exactly, which likely fragments the data.
I've internalized the full implementation. What aspects of the effective patterns would you like to discuss or improve?
User
yes, that's exactly what i was getting at. Look at the screenshot. There is clearly so much gap and improvement opportunity here for normalizing effective patterns. Ask @"llm-expert (agent)" and @"technical-architect (agent)" to chalk out a plan to address this
User
[Image: image/png]
Assistant
The screenshot makes the problem crystal clear — every effective pattern shows "1x" because they're all unique strings despite describing semantically similar behaviors (e.g., "broke down a large feature into a structured plan" vs "decomposing the problem by spawning specialized agents to generate focused recommendations"). These should be clustering together like friction categories do.
Let me get both experts working on this in parallel.
Assistant
Both experts have converged on the same core approach. Here's the synthesized plan:
★ Insight ─────────────────────────────────────Why friction normalization works but patterns don't: Friction uses short kebab-case category fields ("wrong-approach", "api-misunderstanding") that survive exact-match grouping. Patterns use full sentence description fields — Levenshtein distance is useless on 20-word sentences. The fix mirrors friction's architecture: add a categorical identity layer on top of the rich description.
─────────────────────────────────────────────────
// Before (current)
{ "description": "Broke down a large feature into a multi-step plan", "confidence": 85 }
// After
{ "category": "structured-planning", "description": "Broke down a large feature into a multi-step plan", "confidence": 85 }
10 Canonical Categories
Category
Covers
structured-planning
Task breakdown, phased plans, decomposition before implementation
agent-delegation
Delegating to specialized agents, orchestration
verification-workflow
Build/test/commit verification loops
self-correction
Root cause diagnosis, error analysis, course correction
version-control-discipline
Clean commits, branching, PR workflow
incremental-implementation
Small steps, iterative building
context-gathering
Reading existing code/docs before changes
type-driven-development
User
any category around capturing user's debugging skills and domain expertise?
Assistant
Good catch. Looking at the current 10, there's a gap:
self-correction covers the AI catching its own mistakes — but not systematic debugging methodology (e.g., "bisected the issue by comparing implementation code with test code to spot an API signature change")
Nothing covers applying domain/framework expertise that short-circuits trial-and-error (e.g., "recognized the Tailwind v4 migration pattern and applied the correct @custom-variant syntax immediately")
I'd suggest two additions:
Category
Covers
Distinct From
systematic-debugging
Binary search debugging, log-based diagnosis, reproduction isolation, stack trace reading, comparing expected vs actual
self-correction (which is about catching your own errors, not methodical diagnosis)
domain-expertise
Applying framework knowledge, library-specific patterns, architecture familiarity, business logic awareness that avoids trial-and-error
context-gathering (which is about reading docs/code; this is about already knowing the answer)
This would also let self-correction stay focused on course-correction behavior (recognizing you're going down the wrong path and pivoting), while systematic-debugging captures the investigation methodology.
So the revised list would be 12 canonical categories:
12 is still well within the range that LLMs can reliably classify against. Does this look right, or would you merge/rename any of these?
User
yes. plan the implementation design - let @"llm-expert (agent)" and @"technical-architect (agent)" do their work in respective area but @"technical-architect (agent)" take the ownership on designing the whole solution and run a review with @"devtools-cofounder (agent)" . After a consensus is reached, let the development implementation ceremony begin
Assistant
Launching all three experts in parallel — LLM expert on prompt design, TA on full solution architecture, and devtools-cofounder on product validation.
Assistant
Excellent — all three experts have weighed in. The devtools-cofounder raised a sharp challenge to the taxonomy. Let me synthesize the consensus and the one open decision for you.
★ Insight ─────────────────────────────────────The cofounder's core argument: Friction has 15 categories because there are many ways to fail. Effective patterns are more convergent — fewer ways to succeed. 12 categories risks thin clusters and tool-specific dead categories (e.g., agent-delegation is invisible to Cursor/Copilot users). The friction bar chart already proves that fewer, denser categories create more credible signals.
─────────────────────────────────────────────────
Consensus Points (All 3 Agree)
Extraction-time classification — LLM assigns category during facet extraction
Mirror friction's architecture — canonical list + deterministic normalizer + alias map
Hybrid display — category heading + description sub-items (cap at 3 with "+N more")
No schema migration — JSON column is flexible enough
No forced backfill — old data falls back to description grouping
Single PR — all layers tightly coupled (~250 lines)
Keep list format, NOT bar chart — visually distinct from friction (positive vs negative framing)
The Open Decision: 8 vs 12 Categories
The TA and LLM expert designed for 12 categories. The cofounder argues for 8, merging or dropping 4:
Types-first is a subset of applying domain knowledge
test-driven-development → verification-workflow
Tests-first vs tests-after is a subtle distinction LLMs will fumble
documentation-practice → drop
Too thin — rarely surfaces as top-3 pattern
version-control-discipline → drop
Hygiene, not a technique
Cofounder's proposed 8:
User
No, the reflect feature hasn't been released yet. so it is only my local machine that has this new insights format and patterns generated. So, we don't have to keep the backward compatibility. In fact, just like how we planned for session insights without updated format, we will show a flag in session insights and reflections page as well if there are session insights that are not having the latest format, so the users can run insights again which generates proper formatted data with all new required fields.
and yes, apply filter for both frictions and effective patterns for only use 50% above confidence items.
Also, i am thinking one more change now. update the above 2 items into the design and document it so we do not loose and then i will talk about my other requirement related to this
Assistant
Got it — clean break, no backward compat. Let me document the updated design with both changes.
Assistant
★ Insight ─────────────────────────────────────Two key design shifts from your input:
Clean break vs backward compat — Since Reflect isn't released, we avoid the complexity of COALESCE fallbacks, optional fields, and dual-format handling. category is now required, not optional. This simplifies every layer.
Outdated format banner — Instead of silently degrading, we surface the gap to users and give them agency to fix it. This is the same UX pattern tools like VS Code use when workspace settings are outdated.
─────────────────────────────────────────────────
The design is documented at docs/plans/2026-03-09-effective-pattern-normalization.md with both updates:
No backward compat — category is required, outdated sessions get a re-analyze banner on both Session Insights and Patterns pages
50%+ confidence filter — Applied at aggregation time for both friction and effective patterns
What's your other requirement?
User
it is related to the same feature. I am thinking aloud and need inputs from other agents like @"llm-expert (agent)" @"technical-architect (agent)" and @"devtools-cofounder (agent)" as well here. The overall requirement of us building this app is to have some space for the user to analyze their ai sessions and generate insights. and a overall reflections to talk summarize and format the disparate insights into structured categories for frictions and patterns.
but the expection or goal of the user from this activity is to improve their AI sessions. So, our insights generate per session level. reflections generate for a time window (30d default?) and then we should we able to build on this to further analyze whether friction points from last reflections are gone in the next iteration -- meaning, the user has overcome the friction points and has succesfully progressed them into a effective patterns which is like the real goal of the app.
What are your and other agents thoughts on this?
Assistant
This is a really compelling product insight — the current Reflect feature is essentially a snapshot, but the real value is in showing progression over time. Let me get all three experts thinking about this.
Assistant
All three experts are strongly aligned — this is the right direction. Let me synthesize.
★ Insight ─────────────────────────────────────The product arc completion: Code Insights currently has two layers — "What happened?" (sessions) and "What keeps happening?" (reflections). The proposed third layer answers "Am I getting better?" — transforming the tool from a reporting tool into a learning tool. The cofounder nailed it: the difference between a single blood test and a health trend chart.
─────────────────────────────────────────────────
Expert Consensus
All 3 Agree On
This is the right product direction — completes the product arc, unique competitive positioning (nobody else does cross-tool longitudinal AI session effectiveness tracking)
Deterministic code flags candidate transformations (friction down + related pattern up). LLM confirms/rejects and narrates. Cost: 2000-3000 tokens total per progress call ($0.005-0.01).
Assistant
Now let me append the progress tracking section to the design doc.
Assistant
Design doc updated at docs/plans/2026-03-09-effective-pattern-normalization.md with both features documented.
The three open questions that need your input before we can proceed:
Snapshot comparison — Re-aggregate fresh from session_facets (Option A: always accurate, no new table) vs compare stored historical snapshots (Option B: needs Schema V6, but faster and enables multi-period trends later)?
Trigger — Should progress auto-compute when generating a new reflection (piggyback), or be a separate "View Progress" button?
Scope — Ship pattern normalization + progress tracking together as one feature, or pattern normalization first then progress as a follow-up?
User
I am thinking we should make the reflections on specific time interval. Like weekly one reflection. Given our users are power ai tool users, we can expect at least 2-3 sessions a day which would be around 20 sessions a week. So, we can generate reflections for every week. If the user did not generate it, we show that this week's reflectin session is missing and then once generated and show them. Over 3-4 weeks we will present an option to identify the progress in friction areas.
This way, we can do snapshot level comparision. I do not see a real value in re-looking at facets, unless you see more accurate or effective results in that approach. Let's ask @"llm-expert (agent)" as well on their thoughts for this.
Since we will restrict reflect feature on weekly basis, we can leave it for manual user trigger and flag the weeks that they haven't generated reflections yet.
We will ship pattern normalization, making the Reflect feature complete and ready for release. Progress tracking is the next feature we will work on and release in coming weeks. I am bringing it up to you so we can design our solution in proper future proof and extendible manner
Assistant
Great decisions — weekly cadence creates a natural rhythm and makes snapshot comparison meaningful. Let me get the LLM expert's take on the snapshot vs re-aggregation question.
Assistant
LLM expert confirms: Option A (stored snapshots) is the right call.
★ Insight ─────────────────────────────────────Why snapshots > re-aggregation for progress: The progress narrative should compare "what the user was told in Week 3" vs "what they were told in Week 4." Re-aggregating from raw facets could produce numbers that don't match what the user remembers seeing — making the narrative feel disconnected. Snapshots are the user's experience of each week, and that's what progress should track.
─────────────────────────────────────────────────
The expert also suggested a nice future-proofing idea: a snapshot_stale flag that gets set when sessions in that week's range are re-analyzed, with a subtle UI indicator prompting the user to regenerate. Zero cost now, keeps the door open.
Finalized Decisions
Decision
Answer
Reflection cadence
Weekly (~20 sessions expected)
Comparison approach
Snapshot vs snapshot (not re-aggregation)
Trigger
Manual — flag missing weeks in UI
Shipping strategy
Pattern normalization first (completes Reflect for release), Progress tracking follows
Design approach
Future-proof and extensible for progress tracking
Let me update the design doc with these final decisions.
Assistant
Now let me update the open decisions section since they're all resolved.
Assistant
Design doc fully updated. Here's a summary of what's locked in:
★ Insight ─────────────────────────────────────Weekly cadence creates natural snapshot history: By switching from arbitrary periods (7d|30d|90d) to ISO weeks (2026-W10), each week becomes a distinct row in reflect_snapshots — no upsert overwrites, history accumulates naturally. This is the key architectural change that makes progress tracking "just work" later without a separate history table.
─────────────────────────────────────────────────
Pattern normalization must future-proof for progress by:
Using ISO week period keys (not 7d|30d|90d)
Category-based aggregation (prerequisite for weekly diffs)
Optionally adding a snapshot_stale column for later use
The design doc is at docs/plans/2026-03-09-effective-pattern-normalization.md with everything captured. What's the other requirement you wanted to discuss?
User
re-interate the implementation high level steps for this pattern normalization and steps remaining for making the reflect feature ready for release
Assistant
Let me re-read the full design doc to make sure I capture everything accurately.
Assistant
Now let me also check what the current Reflect feature state is — what already works and what's missing for release.
Assistant
Good — now I have a clear picture of what exists and what needs to change. Here's the complete breakdown:
★ Insight ─────────────────────────────────────The Reflect feature is 80% built. CLI, dashboard, API, and snapshot caching all work. What's missing is the quality layer (pattern normalization, confidence filtering) and the cadence shift (arbitrary periods → weekly). Pattern normalization is the biggest implementation effort; the weekly model is mostly a period-handling change.
─────────────────────────────────────────────────
Update effective patterns SQL: extract category, description, confidence from JSON
Add WHERE confidence >= 50 filter for effective patterns
Investigate friction confidence filter (friction uses not numeric confidence — may need to check if we should add confidence to friction or convert severity)
User
yes, commit this plan doc first and then kick off the implementation with start-feature command and full ceremony
Assistant
Plan committed. Now kicking off the full ceremony.
User
/start-feature — Auto-Setup Feature Development Team
Feature: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md
You are setting up a hybrid agent team for feature development. The PM agent leads the team and owns the ceremony. Your job is minimal setup, then hand control to PM.
Step 1: Create Git Worktree
Slugify the feature description into a branch name:
Take Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md, lowercase it, replace spaces/special chars with hyphens, truncate to 50 chars
Prefix with feature/ (e.g., "add demo mode onboarding" -> feature/add-demo-mode-onboarding)
bash
# Example (adapt the slug from Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md):
BRANCH_NAME="feature/<slugified-arguments>"
git fetch origin
git worktree add ../code-insights-${BRANCH_NAME#feature/} -b ${BRANCH_NAME} origin/main
If the worktree or branch already exists, inform the user and ask how to proceed.
Run pnpm install in the worktree:
bash
cd ../code-insights-${BRANCH_NAME#feature/} && pnpm install
Step 2: Create Named Team
Create the team using TeamCreate. Use the slugified branch name (without feature/ prefix) as the team name:
Assistant
Setting up the feature team. Let me create the worktree and team first.
Assistant
Good. Now let me create the team and spawn the PM agent.
Assistant
Team created. Now spawning the PM agent to lead the ceremony.
Assistant
★ Insight ─────────────────────────────────────The team ceremony in action: The PM agent is now autonomously reading the design doc, creating a GitHub Issue, building the task dependency graph, and preparing the handoff. It will message me back with SPAWN_REQUESTs when it needs the TA, LLM Expert, and Dev agents. I'll spawn each agent as requested — this is the "orchestrator as agent factory" pattern where only the main session can create new agents, preventing recursive spawning.
─────────────────────────────────────────────────
The feature team is live:
Component
Status
Worktree
../code-insights-reflect-pattern-normalization-weekly/ on branch feature/reflect-pattern-normalization-weekly
Team
feat-reflect-pattern-normalization-weekly
PM Agent
Spawned, reading design doc and setting up ceremony
I'm now in supervisor mode — waiting for the PM to complete scoping and send SPAWN_REQUESTs for the TA, LLM Expert, and Dev agents. I'll relay any questions or updates as they come in.
User
Important Rules
NEVER merge the PR — founder-only
Only the orchestrator spawns agents — sub-agents CANNOT use the Task tool to spawn teammates. PM must send SPAWN_REQUEST messages to the orchestrator.
PM handles scoping and coordination — it creates task graphs, GitHub Issues, and prepares handoff context
Orchestrator is the agent factory — spawns TA and Dev agents when PM requests them
All dev work happens in the worktree
Task dependencies enforce ceremony order — agents can't skip steps
TA is optional for internal-only changes — PM decides based on scope
User
Step 5: Cleanup (After PR Merge)
After the founder merges the PR:
Send shutdown requests to all teammates (pm-agent, ta-agent, dev-agent)
After spawning agents, your role is active supervisor:
PM handles scoping and task graph — orchestrator handles all agent spawning
Spawn agents when PM sends SPAWN_REQUEST messages
Intervene when:
PM messages you asking for user clarification -> relay to user
An agent is stuck or reports a blocker -> help unblock
PM requests /start-review -> run the review command on the PR
When PM reports "ready for merge" -> inform the user
User
Step 4: Orchestrator Spawns Agents on PM Request
After PM completes its handoff and sends a SPAWN_REQUEST message, the orchestrator spawns the requested agent:
For TA (if PM requests it):
code
Task {
name: "ta-agent",
subagent_type: "technical-architect",
team_name: "feat-<slugified-arguments>",
prompt: "You are the TA for feature team feat-<slugified-arguments>. Feature: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md. Check TaskList for your assigned tasks. Use SendMessage to communicate with pm-agent and later dev-agent. Mark tasks in_progress when starting, completed when done.",
mode: "bypassPermissions"
}
Assign the TA task to ta-agent.
For LLM Expert (if PM requests it):
code
Task {
name: "llm-expert-agent",
subagent_type: "llm-expert",
team_name: "feat-<slugified-arguments>",
prompt: "You are the LLM Expert for feature team feat-<slugified-arguments>. Feature: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md. Check TaskList for your assigned tasks. Design the prompt architecture, token budget, model recommendation, and output schema for the LLM aspects of this feature. Use SendMessage to communicate with pm-agent and ta-agent. Mark tasks in_progress when starting, completed when done.",
mode: "bypassPermissions"
}
User
Step 3: Spawn PM Agent
The PM agent handles scoping, GitHub Issues, and task graph creation. It does NOT spawn other agents — only the orchestrator can spawn agents.
code
User
Step 2: Create Named Team
Create the team using TeamCreate. Use the slugified branch name (without feature/ prefix) as the team name:
code
TeamCreate {
team_name: "feat-<slugified-arguments>",
description: "Feature team: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md"
}
User
Step 1: Create Git Worktree
Slugify the feature description into a branch name:
Take Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md, lowercase it, replace spaces/special chars with hyphens, truncate to 50 chars
Prefix with feature/ (e.g., "add demo mode onboarding" -> feature/add-demo-mode-onboarding)
bash
# Example (adapt the slug from Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md):
BRANCH_NAME="feature/<slugified-arguments>"
git fetch origin
git worktree add ../code-insights-${BRANCH_NAME#feature/} -b ${BRANCH_NAME} origin/main
If the worktree or branch already exists, inform the user and ask how to proceed.
Run pnpm install in the worktree:
bash
cd ../code-insights-${BRANCH_NAME#feature/} && pnpm install
NEW — Mirror friction-normalize.ts: alias map, Levenshtein, substring matching
server/src/routes/shared-aggregation.ts
Group by COALESCE(category, description), normalize, merge, return descriptions[] array
server/src/llm/reflect-prompts.ts
Update prompt generators to use category + descriptions[]
dashboard/src/pages/PatternsPage.tsx
Show category as heading, descriptions as sub-items, frequency badges
server/src/routes/reflect.ts
No structural changes (shape flows through from aggregation)
What's NOT needed
No schema migration — effective_patterns is already a JSON text column
No backfill — Old data falls back to description grouping; ages out of 30d window naturally. Existing reflect backfill command will use updated prompts when run.
No new endpoints — Existing API shapes evolve in place
Implementation Order
Prompts (canonical list + classification guidance)
Pattern normalizer (new file)
Aggregation query + normalization
Reflect prompt generators
Dashboard display
Build & verify end-to-end
Key Agreement Between Experts
Both independently arrived at:
10 categories (not 15+ — fewer ways to succeed than fail)
No forced backfill — graceful fallback for legacy data
~180 extra prompt tokens — negligible cost increase
The LLM expert also provided concrete prompt text and the classification guidance block. The TA provided the exact SQL with COALESCE fallback and the full alias map.
What do you think? Any categories you'd adjust or anything you'd change before we proceed to implementation?
Apply confidence threshold (hide patterns below 50) for quality control
Don't show empty categories — only display what has data
Sort by frequency descending (strongest habit first)
My take: The cofounder's pruning is well-reasoned. 8 denser categories > 12 sparse ones, especially with 5 source tools. effective-tooling is a smart generalization of agent-delegation. The dropped categories (documentation-practice, version-control-discipline) genuinely feel like hygiene rather than "techniques that worked well."
What's your call — go with 8, stick with 12, or adjust further? Once you decide, I'll kick off /start-feature with the full ceremony.
2. Historical Snapshot Storage
Current reflect_snapshots has PRIMARY KEY (period, project_id) with upsert — overwrites previous. For progress comparison, we need history.
TA recommends: Schema V6 — new reflect_history table (or modify upsert to archive before overwriting). The cofounder agrees.
TA's approach differs slightly — re-aggregate from session_facets for two adjacent windows rather than comparing stored snapshots. This is always fresh and needs no new storage. Both approaches work.
3. What the User Sees
On the Patterns page (when a previous snapshot exists):
"New challenges this period" (harder problems, not worse developer)
Friction resolved entirely
"Resolved friction" with checkmark
Friction returned
"Recurring challenge" (neutral)
No change
Don't call it out — absence of progress language is sufficient
Open Questions for You
Snapshot comparison approach: Re-aggregate fresh from session_facets for two windows (TA's approach — always accurate, no storage needed) vs compare stored snapshots (LLM expert's approach — faster, but requires history table)?
Trigger: Should progress auto-compute during reflect generation (when previous exists), or be a separate "View Progress" action?
Scope: Should this progress concept be part of the current pattern-normalization PR, or a follow-up feature?
Let me update the design document with this new requirement.
severity
Post-query: normalize categories, merge by key, collect descriptions[]
Want me to kick off /start-feature with these steps, or do you want to adjust anything first?
code
TeamCreate {
team_name: "feat-<slugified-arguments>",
description: "Feature team: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md"
}
Step 3: Spawn PM Agent
The PM agent handles scoping, GitHub Issues, and task graph creation. It does NOT spawn other agents — only the orchestrator can spawn agents.
code
Task {
name: "pm-agent",
subagent_type: "product-manager",
team_name: "feat-<slugified-arguments>",
prompt: "You are the PM for this feature team.
FEATURE REQUEST: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md
WORKTREE: ../code-insights-<slugified-arguments>/
BRANCH: feature/<slugified-arguments>
TEAM: feat-<slugified-arguments>
Your responsibilities are scoping, GitHub Issues, task graph, and handoff preparation.
IMPORTANT: You CANNOT spawn agents. Only the orchestrator can. When you need an agent spawned, message the orchestrator with the request.
Follow this protocol:
1. SCOPE: Read docs in docs/ and CLAUDE.md to understand what this feature involves. Check for existing design docs in docs/plans/. Check docs/architecture/ for architecture context. If the scope is unclear, message the orchestrator for clarification.
2. ISSUES: Search for an existing GitHub Issue that matches this feature. If one exists, use it. If not, create one with proper description, acceptance criteria, and T-shirt size. Record the issue number.
3. TASK GRAPH: Create the ceremony tasks using TaskCreate, then set dependencies with TaskUpdate:
- Task: 'TA: Review architecture alignment' (no dependencies) -- SKIP if internal-only (new components, UI, styling)
- Task: 'LLM Expert: Design prompt architecture' (no dependencies) -- SKIP if feature doesn't involve LLM calls
- Task: 'PM: Prepare handoff context in GitHub Issue' (no dependencies, you do this yourself)
- Task: 'Dev: Read handoff and design docs, prepare questions' (blockedBy: TA + LLM Expert if applicable + PM handoff)
- Task: 'Dev + TA: Reach consensus on implementation approach' (blockedBy: above) -- SKIP if internal-only
- Task: 'Dev: Implement feature in worktree' (blockedBy: above)
- Task: 'Dev: Create PR and run CI checks' (blockedBy: above)
- Task: 'Review: Triple-layer code review' (blockedBy: above)
- Task: 'Post review summary to GitHub PR' (blockedBy: above)
4. DO YOUR OWN TASK: Work on your handoff task -- prepare context in the GitHub Issue (description, acceptance criteria, relevant doc paths, implementation guidance).
5. REQUEST AGENT SPAWNS: When your handoff task is done, message the orchestrator:
- If TA is needed: 'SPAWN_REQUEST: ta-agent — [brief context]'
- When dev prerequisites are met: 'SPAWN_REQUEST: dev-agent — [brief context including issue number and key details]'
The orchestrator will spawn the agents and assign tasks.
SKIP TA if the feature is internal-only (new components, UI fixes, styling, LLM provider additions). In that case, mark the TA task as completed with note 'Skipped -- internal-only change'.
If the feature involves LLM calls (prompts, model selection, token budgets, structured output):
- 'SPAWN_REQUEST: llm-expert-agent — [brief context about the LLM aspect]'
The LLM Expert will design the prompt architecture, token budget, and model recommendation before dev implements.
SKIP LLM Expert if the feature doesn't touch LLM code. Mark the task as completed with note 'Skipped -- no LLM impact'.
6. MONITOR: Check TaskList periodically. When Dev creates a PR, message the orchestrator to trigger /start-review on the PR number.
7. REPORT: When review is posted, message the orchestrator: 'PR #XX for Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md is ready for founder review and merge.'
IMPORTANT RULES:
- NEVER merge PRs -- founder-only
- NEVER try to spawn agents -- message the orchestrator instead
- All dev work happens in the worktree
- If you need user clarification, message the orchestrator who will ask the user
- You can message existing teammates directly via SendMessage for routine coordination
- Task dependencies enforce ceremony order -- don't skip steps
- CI gate for this project: pnpm build (no test framework yet)",
mode: "bypassPermissions"
}
Step 4: Orchestrator Spawns Agents on PM Request
After PM completes its handoff and sends a SPAWN_REQUEST message, the orchestrator spawns the requested agent:
For TA (if PM requests it):
code
Task {
name: "ta-agent",
subagent_type: "technical-architect",
team_name: "feat-<slugified-arguments>",
prompt: "You are the TA for feature team feat-<slugified-arguments>. Feature: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md. Check TaskList for your assigned tasks. Use SendMessage to communicate with pm-agent and later dev-agent. Mark tasks in_progress when starting, completed when done.",
mode: "bypassPermissions"
}
Assign the TA task to ta-agent.
For LLM Expert (if PM requests it):
code
Task {
name: "llm-expert-agent",
subagent_type: "llm-expert",
team_name: "feat-<slugified-arguments>",
prompt: "You are the LLM Expert for feature team feat-<slugified-arguments>. Feature: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md. Check TaskList for your assigned tasks. Design the prompt architecture, token budget, model recommendation, and output schema for the LLM aspects of this feature. Use SendMessage to communicate with pm-agent and ta-agent. Mark tasks in_progress when starting, completed when done.",
mode: "bypassPermissions"
}
Assign the LLM Expert task to llm-expert-agent.
For Dev (when PM requests it):
code
Task {
name: "dev-agent",
subagent_type: "engineer",
team_name: "feat-<slugified-arguments>",
prompt: "You are the Dev for feature team feat-<slugified-arguments>. Feature: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md. Worktree: ../code-insights-<slugified-arguments>/. All code work happens in the worktree. Check TaskList for your tasks. Use SendMessage to communicate with pm-agent. Mark tasks in_progress/completed. CI gate: pnpm build must pass.",
mode: "bypassPermissions"
}
Assign the next unblocked dev task to dev-agent.
Step 5: Supervise
After spawning agents, your role is active supervisor:
PM handles scoping and task graph — orchestrator handles all agent spawning
Spawn agents when PM sends SPAWN_REQUEST messages
Intervene when:
PM messages you asking for user clarification -> relay to user
An agent is stuck or reports a blocker -> help unblock
PM requests /start-review -> run the review command on the PR
When PM reports "ready for merge" -> inform the user
Step 5: Cleanup (After PR Merge)
After the founder merges the PR:
Send shutdown requests to all teammates (pm-agent, ta-agent, dev-agent)
Only the orchestrator spawns agents — sub-agents CANNOT use the Task tool to spawn teammates. PM must send SPAWN_REQUEST messages to the orchestrator.
PM handles scoping and coordination — it creates task graphs, GitHub Issues, and prepares handoff context
Orchestrator is the agent factory — spawns TA and Dev agents when PM requests them
All dev work happens in the worktree
Task dependencies enforce ceremony order — agents can't skip steps
TA is optional for internal-only changes — PM decides based on scope
Assign the LLM Expert task to llm-expert-agent.
For Dev (when PM requests it):
code
Task {
name: "dev-agent",
subagent_type: "engineer",
team_name: "feat-<slugified-arguments>",
prompt: "You are the Dev for feature team feat-<slugified-arguments>. Feature: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md. Worktree: ../code-insights-<slugified-arguments>/. All code work happens in the worktree. Check TaskList for your tasks. Use SendMessage to communicate with pm-agent. Mark tasks in_progress/completed. CI gate: pnpm build must pass.",
mode: "bypassPermissions"
}
Assign the next unblocked dev task to dev-agent.
Task {
name: "pm-agent",
subagent_type: "product-manager",
team_name: "feat-<slugified-arguments>",
prompt: "You are the PM for this feature team.
FEATURE REQUEST: Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md
WORKTREE: ../code-insights-<slugified-arguments>/
BRANCH: feature/<slugified-arguments>
TEAM: feat-<slugified-arguments>
Your responsibilities are scoping, GitHub Issues, task graph, and handoff preparation.
IMPORTANT: You CANNOT spawn agents. Only the orchestrator can. When you need an agent spawned, message the orchestrator with the request.
Follow this protocol:
1. SCOPE: Read docs in docs/ and CLAUDE.md to understand what this feature involves. Check for existing design docs in docs/plans/. Check docs/architecture/ for architecture context. If the scope is unclear, message the orchestrator for clarification.
2. ISSUES: Search for an existing GitHub Issue that matches this feature. If one exists, use it. If not, create one with proper description, acceptance criteria, and T-shirt size. Record the issue number.
3. TASK GRAPH: Create the ceremony tasks using TaskCreate, then set dependencies with TaskUpdate:
- Task: 'TA: Review architecture alignment' (no dependencies) -- SKIP if internal-only (new components, UI, styling)
- Task: 'LLM Expert: Design prompt architecture' (no dependencies) -- SKIP if feature doesn't involve LLM calls
- Task: 'PM: Prepare handoff context in GitHub Issue' (no dependencies, you do this yourself)
- Task: 'Dev: Read handoff and design docs, prepare questions' (blockedBy: TA + LLM Expert if applicable + PM handoff)
- Task: 'Dev + TA: Reach consensus on implementation approach' (blockedBy: above) -- SKIP if internal-only
- Task: 'Dev: Implement feature in worktree' (blockedBy: above)
- Task: 'Dev: Create PR and run CI checks' (blockedBy: above)
- Task: 'Review: Triple-layer code review' (blockedBy: above)
- Task: 'Post review summary to GitHub PR' (blockedBy: above)
4. DO YOUR OWN TASK: Work on your handoff task -- prepare context in the GitHub Issue (description, acceptance criteria, relevant doc paths, implementation guidance).
5. REQUEST AGENT SPAWNS: When your handoff task is done, message the orchestrator:
- If TA is needed: 'SPAWN_REQUEST: ta-agent — [brief context]'
- When dev prerequisites are met: 'SPAWN_REQUEST: dev-agent — [brief context including issue number and key details]'
The orchestrator will spawn the agents and assign tasks.
SKIP TA if the feature is internal-only (new components, UI fixes, styling, LLM provider additions). In that case, mark the TA task as completed with note 'Skipped -- internal-only change'.
If the feature involves LLM calls (prompts, model selection, token budgets, structured output):
- 'SPAWN_REQUEST: llm-expert-agent — [brief context about the LLM aspect]'
The LLM Expert will design the prompt architecture, token budget, and model recommendation before dev implements.
SKIP LLM Expert if the feature doesn't touch LLM code. Mark the task as completed with note 'Skipped -- no LLM impact'.
6. MONITOR: Check TaskList periodically. When Dev creates a PR, message the orchestrator to trigger /start-review on the PR number.
7. REPORT: When review is posted, message the orchestrator: 'PR #XX for Reflect Feature Enhancement: Pattern Normalization + Weekly Model — Add category-based classification to effective patterns (8 canonical categories), confidence filtering (50%+), outdated format detection with re-analysis banners, and weekly reflection cadence. Design plan at docs/plans/2026-03-09-effective-pattern-normalization.md is ready for founder review and merge.'
IMPORTANT RULES:
- NEVER merge PRs -- founder-only
- NEVER try to spawn agents -- message the orchestrator instead
- All dev work happens in the worktree
- If you need user clarification, message the orchestrator who will ask the user
- You can message existing teammates directly via SendMessage for routine coordination
- Task dependencies enforce ceremony order -- don't skip steps
- CI gate for this project: pnpm build (no test framework yet)",
mode: "bypassPermissions"
}