{"id":"compound-learnings","name":"compound-learnings","summary":"セッションでの学習を恒久的な能力(スキル、ルール、エージェント)に変換する。「セットアップを改善する」「セッションから学ぶ」「複合学習」「どのパターンをスキルにすべきか」と尋ねられたときに使います。","body":"# Compound Learnings\n\nTransform ephemeral session learnings into permanent, compounding capabilities.\n\n## When to Use\n\n- \"What should I learn from recent sessions?\"\n- \"Improve my setup based on recent work\"\n- \"Turn learnings into skills/rules\"\n- \"What patterns should become permanent?\"\n- \"Compound my learnings\"\n\n## Process\n\n### Step 1: Gather Learnings\n\n```bash\n# List learnings (most recent first)\nls -t $CLAUDE_PROJECT_DIR/.claude/cache/learnings/*.md | head -20\n\n# Count total\nls $CLAUDE_PROJECT_DIR/.claude/cache/learnings/*.md | wc -l\n```\n\nRead the most recent 5-10 files (or specify a date range).\n\n### Step 2: Extract Patterns (Structured)\n\nFor each learnings file, extract entries from these specific sections:\n\n| Section Header | What to Extract |\n|----------------|-----------------|\n| `## Patterns` or `Reusable techniques` | Direct candidates for rules |\n| `**Takeaway:**` or `**Actionable takeaway:**` | Decision heuristics |\n| `## What Worked` | Success patterns |\n| `## What Failed` | Anti-patterns (invert to rules) |\n| `## Key Decisions` | Design principles |\n\nBuild a frequency table as you go:\n\n```markdown\n| Pattern | Sessions | Category |\n|---------|----------|----------|\n| \"Check artifacts before editing\" | abc, def, ghi | debugging |\n| \"Pass IDs explicitly\" | abc, def, ghi, jkl | reliability |\n```\n\n### Step 2b: Consolidate Similar Patterns\n\nBefore counting, merge patterns that express the same principle:\n\n**Example consolidation:**\n- \"Artifact-first debugging\"\n- \"Verify hook output by inspecting files\"\n- \"Filesystem-first debugging\"\n→ All express: **\"Observe outputs before editing code\"**\n\nUse the most general formulation. Update the frequency table.\n\n### Step 3: Detect Meta-Patterns\n\n**Critical step:** Look at what the learnings cluster around.\n\nIf >50% of patterns relate to one topic (e.g., \"hooks\", \"tracing\", \"async\"):\n→ That topic may need a **dedicated skill** rather than multiple rules\n→ One skill compounds better than five rules\n\nAsk yourself: *\"Is there a skill that would make all these rules unnecessary?\"*\n\n### Step 4: Categorize (Decision Tree)\n\nFor each pattern, determine artifact type:\n\n```\nIs it a sequence of commands/steps?\n  → YES → SKILL (executable > declarative)\n  → NO ↓\n\nShould it run automatically on an event (SessionEnd, PostToolUse, etc.)?\n  → YES → HOOK (automatic > manual)\n  → NO ↓\n\nIs it \"when X, do Y\" or \"never do X\"?\n  → YES → RULE\n  → NO ↓\n\nDoes it enhance an existing agent workflow?\n  → YES → AGENT UPDATE\n  → NO → Skip (not worth capturing)\n```\n\n**Artifact Type Examples:**\n\n| Pattern | Type | Why |\n|---------|------|-----|\n| \"Run linting before commit\" | Hook (PreToolUse) | Automatic gate |\n| \"Extract learnings on session end\" | Hook (SessionEnd) | Automatic trigger |\n| \"Debug hooks step by step\" | Skill | Manual sequence |\n| \"Always pass IDs explicitly\" | Rule | Heuristic |\n\n### Step 5: Apply Signal Thresholds\n\n| Occurrences | Action |\n|-------------|--------|\n| 1 | Note but skip (unless critical failure) |\n| 2 | Consider - present to user |\n| 3+ | Strong signal - recommend creation |\n| 4+ | Definitely create |\n\n### Step 6: Propose Artifacts\n\nPresent each proposal in this format:\n\n```markdown\n---\n\n## Pattern: [Generalized Name]\n\n**Signal:** [N] sessions ([list session IDs])\n\n**Category:** [debugging / reliability / workflow / etc.]\n\n**Artifact Type:** Rule / Skill / Agent Update\n\n**Rationale:** [Why this artifact type, why worth creating]\n\n**Draft Content:**\n\\`\\`\\`markdown\n[Actual content that would be written to file]\n\\`\\`\\`\n\n**File:** `.claude/rules/[name].md` or `.claude/skills/[name]/SKILL.md`\n\n---\n```\n\nUse `AskUserQuestion` to get approval for each artifact (or batch approval).\n\n### Step 7: Create Approved Artifacts\n\n#### For Rules:\n```bash\n# Write to rules directory\ncat > $CLAUDE_PROJECT_DIR/.claude/rules/<name>.md << 'EOF'\n# Rule Name\n\n[Context: why this rule exists, based on N sessions]\n\n## Pattern\n[The reusable principle]\n\n## DO\n- [Concrete action]\n\n## DON'T\n- [Anti-pattern]\n\n## Source Sessions\n- [session-id-1]: [what happened]\n- [session-id-2]: [what happened]\nEOF\n```\n\n#### For Skills:\nCreate `.claude/skills/<name>/SKILL.md` with:\n- Frontmatter (name, description, allowed-tools)\n- When to Use\n- Step-by-step instructions (executable)\n- Examples from the learnings\n\nAdd triggers to `skill-rules.json` if appropriate.\n\n#### For Hooks:\nCreate shell wrapper + TypeScript handler:\n\n```bash\n# Shell wrapper\ncat > $CLAUDE_PROJECT_DIR/.claude/hooks/<name>.sh << 'EOF'\n#!/bin/bash\nset -e\ncd \"$CLAUDE_PROJECT_DIR/.claude/hooks\"\ncat | node dist/<name>.mjs\nEOF\nchmod +x $CLAUDE_PROJECT_DIR/.claude/hooks/<name>.sh\n```\n\nThen create `src/<name>.ts`, build with esbuild, and register in `settings.json`:\n\n```json\n{\n  \"hooks\": {\n    \"EventName\": [{\n      \"hooks\": [{\n        \"type\": \"command\",\n        \"command\": \"$CLAUDE_PROJECT_DIR/.claude/hooks/<name>.sh\"\n      }]\n    }]\n  }\n}\n```\n\n#### For Agent Updates:\nEdit existing agent in `.claude/agents/<name>.md` to add the learned capability.\n\n### Step 8: Summary Report\n\n```markdown\n## Compounding Complete\n\n**Learnings Analyzed:** [N] sessions\n**Patterns Found:** [M]\n**Artifacts Created:** [K]\n\n### Created:\n- Rule: `explicit-identity.md` - Pass IDs explicitly across boundaries\n- Skill: `debug-hooks` - Hook debugging workflow\n\n### Skipped (insufficient signal):\n- \"Pattern X\" (1 occurrence)\n\n**Your setup is now permanently improved.**\n```\n\n## Quality Checks\n\nBefore creating any artifact:\n\n1. **Is it general enough?** Would it apply in other projects?\n2. **Is it specific enough?** Does it give concrete guidance?\n3. **Does it already exist?** Check `.claude/rules/` and `.claude/skills/` first\n4. **Is it the right type?** Sequences → skills, heuristics → rules\n\n## Files Reference\n\n- Learnings: `.claude/cache/learnings/*.md`\n- Skills: `.claude/skills/<name>/SKILL.md`\n- Rules: `.claude/rules/<name>.md`\n- Hooks: `.claude/hooks/<name>.sh` + `src/<name>.ts` + `dist/<name>.mjs`\n- Agents: `.claude/agents/<name>.md`\n- Skill triggers: `.claude/skills/skill-rules.json`\n- Hook registration: `.claude/settings.json` → `hooks` section","author":"@parcadei","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/parcadei/Continuous-Claude-v3/tree/main/.claude/skills/compound-learnings","license":"MIT","category":"design","lang":"en","tokens":1598,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[],"requires":{"mcp":[],"tools":["Read","Glob","Grep","Write","Edit","Bash","AskUserQuestion"]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}