Learning to rule or skill

From event4u-app/agent-config · View interactive version

Learning to rule or skill is an AI agent skill from the GitHub repository event4u-app/agent-config. Use when a repeated learning, mistake, or successful pattern should be turned into a new rule or skill. Also use after completing a task to capture learnings from the work.

How to use this skill

Skill file

learning-to-rule-or-skill

When to use

Use this skill when:

CODE0) surfaced

a repeated phase pattern via

CODE0

— the pattern's count ≥ 2 already satisfies the repetition gate

## Seeds section (CODE1

§ 6). An accepted intake shape: the block carries name, kind, target

template, one-line description and the Extends instead? answer, so step 4's

overlap search starts from a stated candidate — it does not skip that

search, and a seed missing its Extends instead? line is incomplete intake,

not a shortcut. The repetition gate is met by the anchored ADOPT/ADAPT verdict

behind the seed, not a recurrence count — a mechanism confirmed once against a

named own-repo defect is not the one-off case the gate filters.

Do not use this skill when:

Goal

Preconditions

Decision matrix

| If the learning is... | Then... | Action |

|---|---|---|

| A consumer convention a config or check can carry (formatter, linter, CI step) | Config / check | Propose the config diff; never encode it as a rule |

| An always-true constraint ("never X", "always Y") | Rule | Create/update rule |

| A repeatable workflow with steps and validation | Skill | Create/update skill |

| A coding convention or reference material | Guideline | Create/update guideline |

| A reusable fix/refactor recipe for a specific problem (problem → before → after → verification) | Pattern | Create/update src/patterns/<slug>.md (see CODE1) |

| Baseline model knowledge or standard tool usage | Nothing | Do not create anything |

| A refinement of existing guidance | Update | Extend the existing file |

Decision hints

Procedure

0. Promotion Gate (mandatory)

Before proceeding, the learning MUST pass all gates:

| Gate | Question |

|---|---|

| Repetition | Occurred 2+ times OR clearly generalizable? |

| Impact | Improves correctness, reliability, or consistency? |

| Failure pattern | Prevents a real, observed failure? |

| Non-duplication | No existing rule/skill/guideline/command covers this? Verify via § 4 search protocol — a negative grep alone is not proof. |

| Scope fit | Fits rule, skill, or guideline? |

| Minimal | Update existing preferred over creation? |

| Weakens its own judge (passes only on no) | Does the change weaken anything that judges it — a test, a gate, a threshold, this review? The standard is quoted rather than paraphrased: the implementer never silently weakens an assertion, deletes, skips or xfails a failing test, lowers a threshold, or changes fixture semantics to fit the code. Does this change do any of those? |

If ANY gate fails → stop. Do not create or update anything.

Memory-entry rejection criteria live in /memory:add (see § "When to skip").

1. State the learning clearly

Write as a concrete sentence.

Good:

Bad:

2. Identify the pattern type

Classify by type:

Tag with feedback category (for tracking/aggregation):

3. Decide the target

Choose one:

4. Check for overlap — search protocol (mandatory)

A zero-hit grep is not proof of no overlap. Knowledge here spans **five

surfaces** — skills/, rules/, docs/guidelines/, commands/,

src/patterns/; skip one and recall drops. Run all steps before declaring "no

overlap":

Step 1 — list all five surfaces. Directory taxonomy is free evidence:

ls src/skills/ \
   src/rules/ \
   docs/guidelines/ \
   dist/agent-src/commands/ \
   src/patterns/

Sub-directories (docs/guidelines/php/patterns/, docs/guidelines/agent-infra/,

…) carry taxonomies a flat scan misses. Always descend one level.

Step 2 — grep with both vocabularies. Search solution-words and

problem-words. Solution-only grep is confirmation bias — the existing

artifact may name the symptom, not the cure.

| Vocabulary | Example for "agents miss Strategy pattern, write switch chains" |

|---|---|

| Solution-words | strategy, registry, polymorph, interface |

| Problem-words | discriminator, enum.*match, switch.*on, if.*else.*chain |

grep -rl -E "<solution-words>|<problem-words>" src/ docs/guidelines/

Step 3 — taxonomy scan. For a topic with a likely sub-folder

(patterns/, php/, laravel/, agent-infra/), ls that folder

before reading any file. The filename often answers the overlap question.

Step 4 — sample, do not just list. On any keyword overlap from

steps 2–3, open and skim the 3 nearest matches — § headings, the

"When to use" / "Overview" block, the examples. Filenames are not enough;

semantic overlap hides behind unrelated keywords.

Only after all four steps return clean → declare "no overlap", proceed.

Cite in the proposal: "Reviewed before drafting: <files skimmed>" —

the audit trail § 0's Non-duplication gate verifies against.

→ When the parent task is "create a new artifact", artifact-drafting-protocol

Phase B (Research) requires this same protocol — single source of truth.

5. Draft the content

If rule:

If skill:

6. Validate usefulness

7. Keep only the smallest effective change

Prefer:

8. Write the proposal (if scope ≠ nothing)

The output of this skill is a curated proposal under

agents/proposals/<proposal_id>.md, using the template at

.augment/templates/agents/proposal.example.md (shipped by the

package). This is the input to the five-stage pipeline

(capture → classify → propose → gate → upstream); see

CODE0.

Mandatory fields the draft MUST fill:

(contributed upstream via upstream-contribute)

agents/memory/intake/signals-<YYYY-MM>.jsonl#<id>

incident, review-comment, test-failure, or audit-log line ids

per CODE0);

entries that all resolve to the same PR or the same audit-log

run_id are rejected by the gate (independence floor)

evaluation date

Run ./agent-config proposal:check agents/proposals/<id>.md

before handing to upstream-contribute. The

gate is hard: non-zero exit = the proposal does not move

to stage gated.

9. Degrade the source to a pointer (when promoted from a knowledge page)

If the learning came from an agents/knowledge/procedures/skill-candidates.md

entry or any other agents/knowledge/ page (§ "Knowledge-candidate

learnings" below), promotion is not complete until the source is

degraded to a pointer — preventing double-maintenance between page and

artifact:

./scripts-run src/scripts/degrade_to_pointer \
    --source "agents/knowledge/procedures/skill-candidates.md#<topic>" \
    --artifact "<promoted-artifact-path>" \
    --date "<YYYY-MM-DD>"

This rewrites the source entry to `Promoted to <artifact> on <date>; see

<path>. and regenerates agents/knowledge/INDEX.md`. Skip it only when

the source was NOT a knowledge page (a direct user request, an audit-log

pattern, a one-off observation).

Output format

For the decision step (what this skill prints to the user):

  1. Learning summary
  2. Decision: rule, skill, update, or no action
  3. Rationale in one to three lines
  4. If decision ≠ "no action": path of the written proposal

(agents/proposals/<proposal_id>.md) and gate status

(./agent-config proposal:check exit 0 = ready for review)

The proposal file itself follows

proposal.example.md verbatim — all ten sections, YAML frontmatter

complete, draft body in §4.

Core rules

Gotchas

Do NOT

Auto-trigger keywords

Anti-patterns

Examples

Learning: "Nested triple backticks broke markdown copyability twice this week."

Decision: Update existing markdown rule + add markdown-safe skill if none exists.

Learning: "Route checks keep failing when done via text parsing."

Decision: Create focused skill for Laravel route inspection via JSON and jq.

Learning: "I forgot to run PHPStan once."

Decision: No action — one-off, already covered by verify-before-complete rule.

Learning: "We re-invented a per-format PDF extractor in three different

analysis skills."

Decision: Update the affected skills to dispatch to

CODE0 instead of writing new

extractors. Non-text ingestion (PDF / DOCX / XLSX / PPTX / image /

audio) goes through the upstream markitdown-mcp server first; only

write a custom extractor if markitdown cannot handle the format and

the gap is documented in its skill body.

Audit-derived learnings (optional source)

When the input is a pattern surfaced by

CODE0

mining agents/runtime/state/audit/<YYYY-MM>.jsonl

(CODE0):

  1. Treat the script's pattern record as the State the learning

step input (§1) — pattern.summary is the one-sentence

statement, pattern.line_ids is the evidence.

  1. The repetition gate is already satisfied for count ≥ 2. Skip

to §3 (decide the target) — overlap check (§4) and proposal

draft (§8) remain mandatory.

  1. Independence floor still applies: two line ids from the same

run_id count as one piece of evidence. The mining script

already de-duplicates by run_id; the gate trusts that output.

  1. Audit-derived proposals MUST set

source_learning: agents/runtime/state/audit/<YYYY-MM>.jsonl#<line_ids>

and link the mining-script run id, so the human reviewer can

reproduce the pattern from the raw audit log.

Knowledge-candidate learnings (optional source)

When the input is an entry from agents/knowledge/procedures/skill-candidates.md

that reached candidate status (≥ 3 mentions across distinct sessions —

see update_skill_candidates.ts and the

CODE0 recurrence

step):

  1. Treat the candidate's topic as the State the learning step

input (§1). The repetition gate (§0) is already satisfied by the

≥ 3-mention threshold — skip straight to §3 (decide the target).

Overlap check (§4) and proposal draft (§8) remain mandatory.

  1. **Ground the draft in the original session logs, never the

consolidated summary alone.** The entry's Sessions: list names

the session ids the topic recurred in — read them in the host's

transcript view, or reconstruct them from the retained continuity

records, before drafting. A skill written from the counter summary

alone tends to be plausible but wrong; the transcripts carry the

detail the summary dropped.

  1. Set source_learning to the knowledge-candidate entry

(agents/knowledge/procedures/skill-candidates.md#<topic>).

  1. §9 (degrade the source) is mandatory for this source type —

the whole point of the candidate counter is that it stops counting

once promoted.

Environment notes

Prefer updating existing rule/skill when possible.

Create new files only when the learning introduces a clearly distinct pattern.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.