scottfalconer

self-learning-skills

35
1
# Install this skill:
npx skills add scottfalconer/self-learning-skills

Or install specific skill: npx add-skill https://github.com/scottfalconer/self-learning-skills

# Description

Memory sidecar for agent work: recall before tasks, record learnings after tasks, review recommendations, optional backport bundles.

# SKILL.md


name: self-learning-skills
description: "Memory sidecar for agent work: recall before tasks, record learnings after tasks, review recommendations, optional backport bundles."


Self-learning sidecar

Use this skill to recall prior shortcuts before you start work, and to record durable “aha” moments + recommendations after you finish.

Critical rule: if no learnings exist (cold start), say so and proceed with standard tools — do not invent memories.

CLI path (important)

This skill ships an optional helper CLI at <SKILL_DIR>/scripts/self_learning.py (where <SKILL_DIR> is the directory that contains this SKILL.md).

  • Codex default: ${CODEX_HOME:-$HOME/.codex}/skills/self-learning-skills
  • In the commands below, replace <SKILL_DIR> with your install path.

1) PRE-RUN: Recall (before starting work)

When to use: Before any non-trivial task.

Action:
1. Locate the project store: <repo-root>/.agent-skills/self-learning/v1/users/<user>/
2. Read <project_store>/INDEX.md (quick skim).
3. If you need targeted recall, run:
- python3 <SKILL_DIR>/scripts/self_learning.py list --query "<keywords>"
- Optional filters: --skill <name>, --tag skill:<name>
4. Summarize 3–7 directly actionable bullets relevant to the current task (titles + IDs only; no long dumps).

2) POST-RUN: Record (after finishing work)

When to use: You discovered something durable (schema, fix, command sequence, constraint, etc.).

Action:
1. Capture 1–5 Aha Cards (durable, reusable, specific, non-sensitive). Format: references/FORMAT.md.
- Ensure every Aha Card and Recommendation has primary_skill (use unknown if unsure).
- Set scope to project (repo/run-specific) or portable (generally reusable; a backport candidate).
- If you rediscovered the same learning, treat it as reinforcement (signal) rather than duplicating the full card.
2. Capture 1–5 concrete recommendations (what to change and where).
3. Persist:
- python3 <SKILL_DIR>/scripts/self_learning.py record --json payload.json (or stdin)
4. If you used an existing Aha Card or Recommendation, mark it as used:
- python3 <SKILL_DIR>/scripts/self_learning.py use --aha aha_...[,aha_...] [--rec rec_...[,rec_...]]
- Or include used_aha_ids / used_rec_ids (or used: {aha_ids, rec_ids}) in the record payload to auto-append usage signals.

Output requirement: print a short summary + top 3 items, then point to “view more” (INDEX.md / review --format json). Do not dump long JSON by default.

3) REVIEW: Dashboard / Next actions

When to use: “What’s still open?”, “What’s stale?”, “What should we backport?”, “Most useful learnings this week?”

Action:
- python3 <SKILL_DIR>/scripts/self_learning.py review --days 7
- Full JSON: add --format json
- Filters: --skill <name>, --scope project|portable, --status proposed,accepted,in_progress, --query "<keywords>"

4) MAINTENANCE / Governance

  • Repair store hygiene (append-only): python3 <SKILL_DIR>/scripts/self_learning.py repair --apply
  • Update recommendation status/scope: python3 <SKILL_DIR>/scripts/self_learning.py rec-status --id rec_... --status done --scope portable --note "..."
  • Optional backport bundle (explicit + auditable): python3 <SKILL_DIR>/scripts/self_learning.py export-backport --skill-path <skill-dir> --ids <aha_ids> [--make-diff] [--apply]
  • Inspect backport markers in a skill: python3 <SKILL_DIR>/scripts/self_learning.py backport-inspect --skill-path <skill-dir>

Docs

  • Setup/background: README.md
  • Integration templates (no hooks): references/INTEGRATION.md
  • Rubric/format/portability: references/RUBRIC.md, references/FORMAT.md, references/PORTABILITY.md

# README.md

self-learning-skills

A simple system to help AI agents learn from their experiences.


I built self-learning-skills because I noticed my agents often spent time poking around and guessing at things I had already solved in previous runs. I used to manually copy-paste those fixes into future prompts or backport them into my skills.

This repo streamlines that workflow. It acts as a sidecar memory that:

  • Stops the guessing: Records "Aha moments" locally so the agent doesn't start from zero next time.
  • Graduates knowledge: Includes a CLI workflow to Backport proven memories into permanent improvements in your actual skills or docs.
  • It works with Claude Code, GitHub Copilot, and Codex and any other system that implements the https://agentskills.io specification.

⚡ Quick Start

1) Install (pick the right skills folder for your agent)

Copy this entire directory into your agent’s skills directory as self-learning-skills/.

Common locations:

  • GitHub Copilot Agent: .github/skills/self-learning-skills/
  • Claude Code (project): .claude/skills/self-learning-skills/
  • Codex (repo): .codex/skills/self-learning-skills/

Note: The memory store is separate from the code.
By default, it lives under .agent-skills/ in your repo root (see references/PORTABILITY.md for project vs global options).


2) Initialize (one time per repo)

Run this from your repository root to create the storage structure and ignore it from version control.

Replace <SKILL_DIR> with the install path from step (1), e.g. .github/skills/self-learning-skills.
If you're running this repo directly, <SKILL_DIR> is .

python3 <SKILL_DIR>/scripts/self_learning.py init
  • Creates: .agent-skills/self-learning/v1/users/<user>/
  • Protects: Adds .agent-skills/ to .gitignore so you don't commit local memory (use --no-gitignore to skip).
  • User: <user> is a stable identifier for your local learning stream (see references/PORTABILITY.md).

3) Integrate (The Policy)

Agents do not automatically "know" to use this skill. You must give them a policy.

Copy & paste the block below into your project's main instruction file (e.g., AGENTS.md, CLAUDE.md, or .github/copilot-instructions.md).

Self-Learning Policy:

  • Before starting work: Review prior learnings in .agent-skills/self-learning/v1/users/<user>/INDEX.md (or run the review command) and apply them to avoid repeating mistakes.
  • After finishing work: If you discovered a reusable pattern, fixed a tricky bug, or have a recommendation for next time, record 1–5 "Aha Cards" (and any Recommendations) using the record command.

See AGENTS.md for advanced configuration.


🛠 Operational Commands (Cheat Sheet)

Run these from your repository root:

Dashboard (Review)

python3 <SKILL_DIR>/scripts/self_learning.py review --days 7
python3 <SKILL_DIR>/scripts/self_learning.py review --days 30 --scope portable

Find a Memory (Recall)

python3 <SKILL_DIR>/scripts/self_learning.py list --query "pagination"

Record a Memory (Post-Run)

python3 <SKILL_DIR>/scripts/self_learning.py record --json payload.json

Payload shape examples: references/FORMAT.md

Repair / Normalize Indexes

python3 <SKILL_DIR>/scripts/self_learning.py repair --apply

Recommendation Lifecycle

python3 <SKILL_DIR>/scripts/self_learning.py rec-status --id rec_... --status in_progress --note "working on it"
python3 <SKILL_DIR>/scripts/self_learning.py rec-status --id rec_... --status proposed --scope portable --note "Generalized; candidate for reuse/backport"

🚀 The Backporting Workflow: "Graduating" Knowledge

Backporting is how you take a proven "Aha Card" and turn it into a permanent improvement in another skill or documentation file.

The Concept

  1. Discovery: The agent learns something reusable and records an Aha Card.
  2. Generalize: Rewrite it so it doesn’t depend on this repo (set scope: "portable" and remove project-only context).
  3. Validate: You decide it belongs in a real skill, not just local memory.
  4. Backport: You export an auditable bundle (optionally applying it).
  5. Result: The target skill is permanently improved.

How to Backport

1) Identify Aha Card IDs

python3 <SKILL_DIR>/scripts/self_learning.py review --days 7
python3 <SKILL_DIR>/scripts/self_learning.py review --days 30 --scope portable

2a) Generate a backport bundle + diff (Dry Run — No Changes)

python3 <SKILL_DIR>/scripts/self_learning.py export-backport \
  --skill-path <path-to-target-skill> \
  --ids aha_123,aha_456 \
  --make-diff

2b) Apply the backport (Writes Changes)

python3 <SKILL_DIR>/scripts/self_learning.py export-backport \
  --skill-path <path-to-target-skill> \
  --ids aha_123,aha_456 \
  --apply

Inspect a target skill for backport markers

python3 <SKILL_DIR>/scripts/self_learning.py backport-inspect --skill-path <path-to-target-skill>

📂 Directory Structure

self-learning-skills/
├── SKILL.md
├── AGENTS.md
├── README.md
├── scripts/
│   └── self_learning.py
└── references/
    ├── FORMAT.md
    ├── RUBRIC.md
    ├── INTEGRATION.md
    └── PORTABILITY.md

🧠 Storage Model

All data is stored in append-only JSONL files within .agent-skills/self-learning/v1/users/<user>/.

  • Key Files:

  • aha_cards.jsonl: Durable, reusable knowledge.

  • recommendations.jsonl: Improvements for the next run.
  • backports.jsonl: A log of knowledge "graduated" to code.
  • INDEX.md: Human-readable dashboard (safe to delete/rebuild).

🏷 Scoping: project vs portable

Each Aha Card and Recommendation can include a scope field. This answers:

“Does this read like a reusable developer tip/trick, or does it require this repo’s context?”

  • project: specific to the current repo/run (default if omitted)
  • portable: generally reusable; a good candidate for backporting into a skill or docs

Important: scope is about content. Store location (project-local vs global) and the promote/backport lifecycle are covered in references/PORTABILITY.md.

Practical workflows:

  • Record something reusable by setting "scope": "portable" in your record payload (see references/FORMAT.md).
  • Review only portable items: python3 <SKILL_DIR>/scripts/self_learning.py review --scope portable --days 30
  • Reclassify an existing recommendation: python3 <SKILL_DIR>/scripts/self_learning.py rec-status --id rec_... --status proposed --scope portable --note "...".

Portable-writing checklist (avoid leaking full project context):

  • Replace repo/environment-specific values with placeholders (<repo-root>, <ENV>, <SERVICE>, <PROJECT_KEY>).
  • Prefer shapes/templates/invariants over raw payload dumps.
  • Avoid absolute paths in steps/evidence (they will be wrong after backporting).

Tip: use shareable: true only for content that’s safe to persist and potentially backport; never store secrets or sensitive payloads.


Privacy / Safety

Avoid storing secrets or sensitive payloads in the memory store.


License

MIT

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.