$npx -y skills add Kulaxyz/self-learning-skills --skill self-learningCapture a hard-won "golden path" from the current session as a reusable Agent Skill, so future sessions start already knowing it. Use it (1) right after non-trivial debugging, after working out a multi-step operational workflow, or after rediscovering project facts you didn't kno
| 1 | # Self-learning: harvest golden paths into skills |
| 2 | |
| 3 | This skill turns something you just figured out the hard way into a reusable |
| 4 | Agent Skill, so the next session — yours or a teammate's — starts already |
| 5 | knowing the proven route instead of rediscovering it from scratch. |
| 6 | |
| 7 | It is a *meta-skill*: it doesn't do the work, it captures **how** work got done. |
| 8 | It's tool-neutral — it works with any agent that reads the Agent Skills format |
| 9 | (e.g. Claude Code and Codex, which both load `SKILL.md` skills natively). Where a |
| 10 | step differs by tool, the generic version comes first and any tool-specific |
| 11 | detail is only an example. |
| 12 | |
| 13 | ## Recognize the moment |
| 14 | |
| 15 | Watch for these signals during normal work. Any one of them is a cue to harvest: |
| 16 | |
| 17 | - A task only worked **after several attempts**, wrong turns, or a correction |
| 18 | from the user. The successful path is worth more than the failures around it. |
| 19 | - You discovered **project-specific facts the agent didn't know up front**: |
| 20 | where creds/env vars live, which selector or backend talks to a service, a |
| 21 | non-obvious command, a required sequence, a gotcha that defies the obvious |
| 22 | assumption. |
| 23 | - It's an **operational workflow likely to recur**: reach the dev/prod DB, |
| 24 | deploy, run migrations, seed data, verify a change live, run one specific |
| 25 | test path, rotate a key, tail the right logs. |
| 26 | - The user **signals it explicitly**: "remember this", "save this as a skill", |
| 27 | "don't make me re-explain this next time". |
| 28 | |
| 29 | **Act on the cue immediately — don't ask for permission first**, whether the |
| 30 | user requested it or you noticed it yourself. Harvest the skill, then tell the |
| 31 | user what you captured and where (step 5). They can always edit or delete it. |
| 32 | |
| 33 | ### Skill, memory, or skip? |
| 34 | |
| 35 | Not every lesson deserves a whole skill — triage first, so you don't bloat the |
| 36 | skills list with one-liners: |
| 37 | |
| 38 | - **A multi-step, reusable procedure or workflow** (how to deploy, reach the DB, |
| 39 | run the migration dance, verify live) → harvest it as a **skill** using the |
| 40 | procedure below. |
| 41 | - **A single standalone fact or one-line correction** (an env var name, a path, |
| 42 | one gotcha) → if your harness has a lightweight memory/notes facility (e.g. a |
| 43 | `MEMORY.md` index), record it **there** instead; a whole skill is overkill for |
| 44 | a one-liner. With no such facility, make a small skill. |
| 45 | - **A genuinely one-off thing** unlikely to recur → skip it. |
| 46 | |
| 47 | When you do harvest, capture the **failures too**, not just the win: the |
| 48 | approaches you ruled out and *why* often save more time next session than the |
| 49 | golden path itself. |
| 50 | |
| 51 | ### Promotion rule: don't enshrine guesses |
| 52 | |
| 53 | A skill is authoritative — the next session trusts it without re-deriving it — |
| 54 | so hold promotion to a high bar. Only write a skill when **all three** hold: |
| 55 | |
| 56 | 1. **A passing check.** The path was actually verified — a test passed, the |
| 57 | command exited clean, the repro reproduced, the build went green. Record what |
| 58 | the check was. "Seemed to work" is not a passing check. |
| 59 | 2. **A named failure pattern.** You can name the failure this path avoids or |
| 60 | diagnoses (e.g. "stale build cache → phantom type errors"), not a vague |
| 61 | "sometimes it breaks". |
| 62 | 3. **At least one ruled-out dead-end.** A concrete approach you tried and |
| 63 | eliminated, with the reason. |
| 64 | |
| 65 | If any is missing, it isn't a skill yet — leave a tentative note in memory |
| 66 | (marked unverified) or skip it. This keeps confident guesses out of the skill |
| 67 | set. |
| 68 | |
| 69 | ## Harvest procedure |
| 70 | |
| 71 | - [ ] 1. **Apply the promotion rule** (above). Passing check + named failure |
| 72 | pattern + one ruled-out dead-end — or it isn't a skill: note it in memory |
| 73 | or skip. Don't proceed on a confident guess. |
| 74 | - [ ] 2. **Choose scope and name yourself** using the heuristics below — don't |
| 75 | stop to ask. Default to project scope; pick a clear, specific `name`. |
| 76 | - [ ] 3. **Dedupe.** Look for an existing skill to UPDATE rather than duplicate. |
| 77 | List your agent's skills directories — the project |