Loading...
Loading...
Analyze recent conversation context and capture learnings to project knowledge files (for project-specific insights) or skills/commands/subagents (for cross-project patterns). Use when the user asks to "capture this learning", "update the docs with this", "remember this for next time", "document this issue", "add this to CLAUDE.md", "save this knowledge", or "update project knowledge". Also triggers after resolving build/setup issues, discovering non-obvious patterns, or completing debugging sessions with valuable insights.
npx skill4agent add petekp/claude-code-setup capture-learningWhen running `npm install` on Node 20+, the `--legacy-peer-deps` flag
is required due to React 18 peer dependency conflicts.Had some issues with npm install, fixed it eventually.| Scope | Characteristics | Capture Target |
|---|---|---|
| Project-specific | Involves this codebase's architecture, conventions, dependencies, or local setup | Project knowledge files ( |
| General | Applies across all projects—language patterns, framework best practices, tool usage, API quirks | Skills, commands, or subagents |
| Learning | Scope | Target |
|---|---|---|
"This repo uses | Project-specific | |
"SwiftUI | General | |
"Run | Project-specific | |
"React Server Components can't use | General | |
"The CI pipeline requires | Project-specific | |
"Playwright's | General | |
.claude/# Primary targets (most common)
.claude/CLAUDE.md # Main project instructions
./CLAUDE.md # Root-level alternative
# Secondary targets
.claude/docs/*.md # Reference documentation
.claude/docs/**/*.md # Nested docs
# Tertiary (check but don't modify without explicit request)
.claude/plans/*.md # Planning docs (usually ephemeral)CLAUDE.md.claude/.claude/docs/troubleshooting.md.claude/docs/setup.md| Learning Type | Target Section | Example |
|---|---|---|
| Build/dependency issues | | npm flags, version requirements |
| Environment setup | | env vars, tool versions |
| Code patterns | | naming, architecture decisions |
| Known issues | | quirks, workarounds |
| Debugging insights | | how to diagnose specific problems |
### [Short descriptive title]
**Problem:** [What went wrong]
**Cause:** [Why it happened]
**Solution:** [How to fix/prevent]### [Pattern name]
[Brief description of when/why to use this pattern]
```code
[Example if applicable]
**Structure for quick tips:**
```markdown
- [Concise actionable tip]I'll add this to `.claude/CLAUDE.md` under "## Troubleshooting":
### Node 20 Peer Dependency Fix
**Problem:** `npm install` fails with peer dependency conflicts
**Cause:** React 18 has strict peer deps incompatible with some packages
**Solution:** Run `npm install --legacy-peer-deps`
Should I apply this update?# Check for .claude directory
ls -la .claude/ 2>/dev/null
# Find all markdown files in .claude
find .claude -name "*.md" -type f 2>/dev/null
# Check root for CLAUDE.md
ls CLAUDE.md 2>/dev/nulltroubleshooting.mdsetup.mdpatterns.md.claude/docs/.claude/plans/.claude/CLAUDE.md./CLAUDE.md.claude/CLAUDE.md.claude/docs/troubleshooting.md### TypeScript Version Requirement
**Problem:** Build fails with "Cannot find module 'typescript'"
**Cause:** Project requires TypeScript 5.3+ but system has 5.0
**Solution:**
```bash
npm install typescript@^5.3.0 --save-dev
### Example 2: Environment Setup
**Context:** Session discovered required environment variables.
**Captured learning:**
```markdown
### Required Environment Variables
The following must be set in `.env.local`:
- `DATABASE_URL` - PostgreSQL connection string
- `NEXTAUTH_SECRET` - Generate with `openssl rand -base64 32`
- `NEXTAUTH_URL` - Set to `http://localhost:3000` for development### Error Handling Pattern
All API routes use the `ApiError` class for consistent error responses:
```typescript
throw new ApiError(404, "Resource not found");
## Edge Cases
### Multiple Learnings
If the session contains multiple distinct learnings:
1. List them for the user
2. Ask which to capture (or all)
3. Process each separately with confirmation
### Conflicting Information
If new learning contradicts existing documentation:
1. Show both versions
2. Ask user which is correct
3. Update or replace as directed
### Sensitive Information
Never capture:
- API keys, tokens, or secrets
- Passwords or credentials
- Personal information
- Internal URLs that shouldn't be documented
If a learning involves secrets, document the *pattern* without the actual values.
## Quick Reference
**Trigger phrases:** "capture this", "remember this", "update docs", "document this", "add to CLAUDE.md", "save this knowledge"
**First question:** Is this project-specific or general?
**Project-specific targets:** `.claude/CLAUDE.md` (primary), `.claude/docs/*.md` (secondary)
**General targets:** Skills (`~/.claude/skills/`), commands (`~/.claude/commands/`), subagents (plugin agents)
**Always confirm:** Show exact changes before writing
**Format:** Problem → Cause → Solution (for issues), Description → Example (for patterns)
## Additional Resources
### Reference Files
- **[references/section-templates.md](references/section-templates.md)** - Complete templates for common documentation sections (Troubleshooting, Build & Setup, Environment, Patterns, Known Issues, Debugging). Consult when creating new sections or structuring complex learnings.