Skip to content

Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.

feat(commands): Add /reflect command for session knowledge capture

Jez45eaa6177578
diff --git a/commands/README.md b/commands/README.md
index c74b614f..8e91e861 100644
--- a/commands/README.md
+++ b/commands/README.md
@@ -1,6 +1,6 @@
# Claude Code Slash Commands
-Eight slash commands for automating project exploration, planning, session workflow, skill creation, and release safety with Claude Code.
+Nine slash commands for automating project exploration, planning, session workflow, knowledge capture, skill creation, and release safety with Claude Code.
## ⚠️ New Installation Method
@@ -31,6 +31,7 @@ cp skills/project-workflow/commands/wrap-session.md ~/.claude/commands/
cp skills/project-workflow/commands/continue-session.md ~/.claude/commands/
cp skills/project-workflow/commands/workflow.md ~/.claude/commands/
cp skills/project-workflow/commands/release.md ~/.claude/commands/
+cp commands/reflect.md ~/.claude/commands/
```
Commands are immediately available in Claude Code after copying.
@@ -149,6 +150,49 @@ Commands are immediately available in Claude Code after copying.
---
+### Knowledge Capture Commands
+
+#### `/reflect`
+
+**Purpose**: Self-reflection to capture operational knowledge before it's lost to context clearing
+
+**Usage**: Type `/reflect` before compacting context, after completing significant work, or when valuable learnings have accumulated
+
+**What it does**:
+1. Self-analyzes current conversation for operational knowledge
+2. Identifies workflows, patterns, tool sequences, corrections, discoveries
+3. Identifies **automation opportunities** - recurring processes worth scripting
+4. Categorizes each learning by appropriate destination
+5. Routes to: ~/.claude/CLAUDE.md (universal), ./CLAUDE.md (project), skills, docs/learnings.md, or SESSION.md
+6. Suggests creating scripts/commands for repeatable processes
+7. Presents findings with proposed destinations
+8. Applies updates and creates automation after user confirmation
+
+**Knowledge types captured**:
+- **Workflows**: Multi-step processes that achieved outcomes
+- **Patterns**: Reusable approaches to common problems
+- **Tool Sequences**: Effective tool combinations and order of operations
+- **Corrections**: What didn't work → what did work
+- **Discoveries**: New capabilities or undocumented behaviors
+- **Automation Opportunities**: Recurring processes worth scripting (suggests shell scripts, npm scripts, slash commands)
+
+**Time savings**: Preserves 5-15 minutes of operational learning per session (otherwise lost on context clear)
+
+**When to use**:
+- Before `/compact` or context clearing
+- After completing a significant task successfully
+- When you've discovered an effective workflow
+- Anytime important process knowledge has accumulated
+
+**When to skip**:
+- Session was purely routine (no new learnings)
+- All knowledge is already in commits/docs
+- Quick Q&A session with no process insights
+
+**Output**: Categorized learnings with routing suggestions, optional file updates
+
+---
+
### Helper Commands
#### `/workflow`
@@ -291,7 +335,7 @@ These commands work together and integrate with planning/session skills:
1. Rough idea → /explore-idea → [Creates PROJECT_BRIEF.md] → Decision
2. If proceeding → /plan-project → [Reads brief, creates IMPLEMENTATION_PHASES.md + SESSION.md]
3. Start Phase 1 → Work on phases
-4. Context full → /wrap-session → [Updates SESSION.md, git checkpoint]
+4. Context full → /reflect → [Captures learnings] → /wrap-session → [git checkpoint]
5. New session → /continue-session → [Loads context, continues from "Next Action"]
6. Need feature → /plan-feature → [Adds phases to existing plan]
7. Repeat wrap → resume cycle
@@ -306,6 +350,7 @@ Clear requirements → /plan-project → Work → /wrap-session → /continue-se
**Helper workflows**:
```
Need guidance? → /workflow → [Interactive guide to commands]
+Capture learnings? → /reflect → [Extracts operational knowledge → routes to docs]
Release project? → /release → [Safety checks + GitHub release]
```
@@ -350,6 +395,17 @@ Release project? → /release → [Safety checks + GitHub release]
- ✅ Detects uncommitted changes
- ✅ Optional "Next Action" file opening
+**`/reflect`**:
+- ✅ Self-analyzes conversation for operational knowledge
+- ✅ Categorizes: workflows, patterns, tool sequences, corrections, discoveries
+- ✅ Identifies automation opportunities (recurring processes)
+- ✅ Smart routing to appropriate destinations
+- ✅ Routes to: CLAUDE.md (global/project), skills, docs/learnings.md, SESSION.md
+- ✅ Suggests scripts/commands for repeatable processes
+- ✅ Shows proposed changes before applying
+- ✅ Matches existing file styles when inserting
+- ✅ Prevents duplicate knowledge entries
+
**`/workflow`**:
- ✅ Interactive guidance based on user context
- ✅ Shows decision trees (which command to use)
@@ -374,16 +430,17 @@ Release project? → /release → [Safety checks + GitHub release]
## Total Time Savings
-**35-55 minutes per project lifecycle**:
+**40-70 minutes per project lifecycle**:
- Exploration: 10-15 minutes (explore-idea)
- Planning: 5-7 minutes (plan-project)
- Feature additions: 7-10 minutes each (plan-feature)
- Session cycles: 3-5 minutes each (wrap + resume)
+- Knowledge capture: 5-15 minutes per session (reflect)
- Release safety: 10-15 minutes (release)
- Workflow navigation: Instant (workflow)
---
-**Version**: 4.0.0
-**Last Updated**: 2025-11-07
+**Version**: 5.0.0
+**Last Updated**: 2025-12-12
**Author**: Jeremy Dawes | Jezweb
diff --git a/commands/reflect.md b/commands/reflect.md
new file mode 100644
index 00000000..826c0131
--- /dev/null
+++ b/commands/reflect.md
@@ -0,0 +1,272 @@
+You are performing a self-reflection on the current conversation to capture operational knowledge that would otherwise be lost when context clears.
+
+## Purpose
+
+Extract **operational knowledge** from this session - workflows discovered, patterns learned, tool sequences, and nuanced approaches that don't belong in commits, planning docs, or progress tracking but would be valuable for future Claude Code sessions.
+
+**Key Insight**: This captures "how we work" not "what we built" or "what we decided".
+
+## Command Usage
+
+`/reflect [optional: specific-topic]`
+
+If a topic is provided, focus reflection on that area. Otherwise, reflect on the entire session.
+
+## When to Use
+
+- Before context compaction or clearing
+- After completing significant work or achieving a task
+- When valuable learnings have accumulated
+- Anytime important operational knowledge is at risk of being lost
+
+## What This Captures (vs Other Tools)
+
+| Knowledge Type | Existing Home | /reflect Captures? |
+|----------------|---------------|-------------------|
+| Code changes | Git commits | No - already saved |
+| Architecture decisions | Planning docs | No - already saved |
+| Progress/next steps | SESSION.md | No - already saved |
+| Feature specs | /brief → docs/ | No - use /brief |
+| **Workflows discovered** | ??? | **YES** |
+| **Effective sequences** | ??? | **YES** |
+| **Tool patterns** | ??? | **YES** |
+| **Nuanced approaches** | ??? | **YES** |
+| **Corrections (what worked vs didn't)** | ??? | **YES** |
+
+## Process
+
+### Phase 1: Self-Analysis
+
+Review the current conversation and identify:
+
+1. **Workflows Discovered**
+ - Multi-step processes that achieved outcomes
+ - Sequences that can be reused
+ - "The way to do X is: step 1 → step 2 → step 3"
+
+2. **Patterns Learned**
+ - Reusable approaches to common problems
+ - Best practices discovered through iteration
+ - "When facing X, do Y because Z"
+
+3. **Tool Sequences**
+ - Effective tool combinations
+ - Order of operations that worked well
+ - "Use A then B then C for this type of task"
+
+4. **Corrections**
+ - Things that didn't work → what did work
+ - Mistakes to avoid
+ - "Don't do X, instead do Y"
+
+5. **Discoveries**
+ - New capabilities or features found
+ - Undocumented behaviors
+ - "Turns out you can do X by..."
+
+### Phase 2: Categorize by Destination
+
+Route each learning to the most appropriate destination:
+
+| Knowledge Type | Destination | Criteria |
+|----------------|-------------|----------|
+| Universal workflow | `~/.claude/CLAUDE.md` | Applies across ALL projects |
+| Project-specific | `./CLAUDE.md` | Only relevant to THIS project |
+| Skill improvement | `~/.claude/skills/X/SKILL.md` | Improves a specific skill |
+| Complex process | `docs/learnings.md` | Multi-step, worth documenting |
+| Session context | `SESSION.md` | Temporary, this session only |
+| **Repeatable process** | **Script or command** | **Will do this again, automate it** |
+
+**Routing Heuristics**:
+- If it would help ANY future project → Global CLAUDE.md
+- If it's about a specific technology with a skill → That skill
+- If it's complex enough to need its own section → docs/learnings.md
+- If it's project-specific nuance → Project CLAUDE.md
+- If it's just context for next session → SESSION.md
+- **If we'll do this again → Suggest script, command, or structured workflow**
+
+### Phase 2b: Identify Automation Opportunities
+
+Beyond documentation, look for processes worth **operationalizing**:
+
+**Signs a process should become a script/command:**
+- We did 5+ steps manually that could be automated
+- We'll need to do this again (recurring task)
+- The sequence is error-prone or easy to forget
+- Multiple commands need to run in specific order
+- There's setup/teardown that's always the same
+
+**Automation options to suggest:**
+1. **Shell script** (`scripts/do-thing.sh`) - For CLI sequences
+2. **Slash command** (`commands/thing.md`) - For Claude Code workflows
+3. **npm script** (`package.json`) - For project-specific dev tasks
+4. **Makefile target** - For build/deploy sequences
+5. **Skill template** - If it's a reusable pattern across projects
+
+**When suggesting automation:**
+```markdown
+### Automation Opportunity
+
+**Process**: [What we did repeatedly]
+**Frequency**: [How often this happens]
+**Complexity**: [Number of steps, error potential]
+
+**Suggestion**: Create [script/command/etc]
+**Location**: [Where it would live]
+**Benefit**: [Time saved, errors prevented]
+
+Create this automation? [Y/n]
+```
+
+### Phase 3: Present Findings
+
+Show the user what was found in this format:
+
+```markdown
+## Session Reflection
+
+### Workflows Discovered
+1. **[Name]**: [Description]
+ → Proposed destination: [file path]
+
+### Patterns Learned
+1. **[Name]**: [Description]
+ → Proposed destination: [file path]
+
+### Tool Sequences
+1. **[Tools involved]**: [When to use this sequence]
+ → Proposed destination: [file path]
+
+### Corrections Made
+1. **[What didn't work → What worked]**
+ → Proposed destination: [file path]
+
+### Discoveries
+1. **[What was found]**: [Why it matters]
+ → Proposed destination: [file path]
+
+### Automation Opportunities
+1. **[Process name]**: [What we did manually]
+ - Steps: ~[N] steps
+ - Frequency: [How often we'd do this]
+ → Suggestion: Create [script/command/npm script] at [location]
+
+---
+
+**Proposed Updates:**
+- [ ] [File 1]: Add [brief description]
+- [ ] [File 2]: Update [brief description]
+- [ ] Create docs/learnings.md with [topics]
+
+**Proposed Automation:**
+- [ ] Create [scripts/thing.sh]: [Brief description]
+- [ ] Add npm script "[name]": [Brief description]
+- [ ] Create slash command [/name]: [Brief description]
+
+Proceed? [Y/n/edit]
+```
+
+**If nothing significant found**: Report "No significant operational knowledge identified in this session that isn't already captured elsewhere." and ask if user wants to highlight something specific.
+
+### Phase 4: Apply Updates (with confirmation)
+
+After user confirms:
+
+1. Read each target file
+2. Find appropriate location for insertion
+3. Add the knowledge in a format matching the file's style
+4. For new files (like docs/learnings.md), create with proper structure
+5. Show diff/summary of what was added
+
+## Output Formats by Destination
+
+### For ~/.claude/CLAUDE.md (Global)
+Add to appropriate existing section or create new section:
+```markdown
+## [Section Name]
+
+**[Pattern/Workflow Name]**: [Description]
+- Step 1: ...
+- Step 2: ...
+- Why: [Reasoning]
+```
+
+### For Skill Files
+Add to troubleshooting, patterns, or relevant section:
+```markdown
+### [Pattern/Tip Name]
+
+[Description of what works]
+
+**Why**: [Explanation]
+```
+
+### For docs/learnings.md (New or Append)
+```markdown
+# Project Learnings
+
+## [Date]: [Topic]
+
+**Context**: [What we were doing]
+
+**Learning**: [What we discovered]
+
+**Application**: [When/how to use this]
+
+---
+```
+
+### For SESSION.md
+Add to "Notes" or "Context" section:
+```markdown
+**Session Note**: [Brief learning that's relevant to next session]
+```
+
+## Examples
+
+### Example 1: Skill Development Workflow
+**Discovered**: "When creating skills, the effective sequence is: check existing patterns → copy template → fill SKILL.md → test install → verify discovery"
+
+**Routing**: Add to `~/.claude/CLAUDE.md` under Skill Usage Protocol (universal workflow)
+
+### Example 2: Debugging Approach
+**Discovered**: "Wrangler D1 issues: always check migrations ran on BOTH local AND remote before debugging code"
+
+**Routing**: Add to `~/.claude/skills/cloudflare-d1/SKILL.md` troubleshooting section
+
+### Example 3: Tool Sequence
+**Discovered**: "For context management: /wrap-session first, then compact, then /continue-session loads just what's needed"
+
+**Routing**: Add to `~/.claude/CLAUDE.md` Session Handoff Protocol section
+
+### Example 4: Project-Specific Pattern
+**Discovered**: "In this project, auth tokens are validated in middleware before reaching handlers"
+
+**Routing**: Add to `./CLAUDE.md` (project-specific)
+
+### Example 5: Automation Opportunity
+**Discovered**: "Every time we add a new skill, we: copy template, fill SKILL.md, update README, run install script, run check-metadata, test discovery"
+
+**Routing**: Suggest creating `/create-skill` slash command or `scripts/new-skill.sh`
+
+### Example 6: Recurring Manual Process
+**Discovered**: "Before releases we always: run gitleaks, check for SESSION.md, verify .gitignore, run npm audit"
+
+**Routing**: Suggest creating `scripts/pre-release-check.sh` or `/release` command
+
+## Important Guidelines
+
+- **Extract from ACTUAL conversation** - don't invent learnings
+- **Focus on reusable knowledge** - avoid one-off facts
+- **Preserve the "why"** - context makes learnings actionable
+- **Match file style** - new content should look native
+- **Be concise** - learnings should be scannable
+- **Don't duplicate** - check if knowledge already exists before adding
+- **Confirm before writing** - always get user approval
+
+## Integration with Other Commands
+
+- **After /wrap-session**: Good time to /reflect before clearing context
+- **Before /continue-session**: Previous session's /reflect makes resumption smoother
+- **With /brief**: /brief captures feature specs, /reflect captures process knowledge
+- **Independent**: Can be used anytime during a session