$npx -y skills add sordi-ai/skill-everything --skill self-extension-workflowApply when executing the self-extension workflow. Six steps from a mistake to a merged rule, with CI gates and CODEOWNERS approval.
| 1 | # Self-extension workflow |
| 2 | *Exact prompt and procedure the agent executes after every mistake. The agent never pushes to `main` directly. Every self-extension is a PR.* |
| 3 | |
| 4 | > *Five agent steps plus a search-prerequisite, from mistake to merged rule. The agent never pushes to main. Every rule that lands is CODEOWNERS-approved. This page is the contract.* |
| 5 | |
| 6 | <!-- target: ~1100 tokens --> |
| 7 | |
| 8 | --- |
| 9 | |
| 10 | ## TRIGGER CONDITIONS |
| 11 | *Five conditions. Any one of them starts the workflow.* |
| 12 | |
| 13 | The agent starts this workflow when **any** of these is met: |
| 14 | |
| 15 | - A test fails and the agent wrote the faulty code. |
| 16 | - A code review comment corrects the agent. |
| 17 | - The agent realises during implementation that its first approach was wrong. |
| 18 | - A deployment problem occurs that the agent caused. |
| 19 | - The user explicitly says: "That was wrong" / "Remember this". |
| 20 | |
| 21 | --- |
| 22 | |
| 23 | ## STEP-BY-STEP PROCEDURE |
| 24 | *Five steps after the search-prerequisite. Every step is mandatory before the next one.* |
| 25 | |
| 26 | ### Step 0 — Search before write |
| 27 | *Mandatory. Duplicates in the error log destroy the signal.* |
| 28 | |
| 29 | Before creating a new error entry, search the existing error log: |
| 30 | |
| 31 | ```text |
| 32 | 1. Read skills/error-log/SKILL.md. |
| 33 | 2. Search for similar errors (same category + similar context). |
| 34 | 3. If a similar entry exists: |
| 35 | - Increment its `count` field by 1. |
| 36 | - Update `last_seen` to today. |
| 37 | - Supplement the context if needed. |
| 38 | - Do NOT create a new entry. |
| 39 | 4. Only if no similar entry exists, continue with Step 1. |
| 40 | ``` |
| 41 | |
| 42 | ### Step 1 — Analyse the error |
| 43 | *The agent answers six questions before writing anything.* |
| 44 | |
| 45 | ```text |
| 46 | 1. What exactly did I do? (concrete code/action) |
| 47 | 2. What should I have done instead? |
| 48 | 3. Why did I do it wrong? (false assumption, missing knowledge, carelessness) |
| 49 | 4. Which category applies? |
| 50 | - development: code error, wrong implementation |
| 51 | - git: commit/branch mistake |
| 52 | - deployment: deployment order, configuration |
| 53 | - security: security vulnerability |
| 54 | - performance: N+1, missing indexes, oversized datasets |
| 55 | - domain: wrong understanding of business rules |
| 56 | 5. How severe was the error? (critical/high/medium/low) |
| 57 | 6. Which target file does the rule belong in? |
| 58 | ``` |
| 59 | |
| 60 | ### Step 2 — Determine new error ID |
| 61 | *Take the next number after the latest entry.* |
| 62 | |
| 63 | ```bash |
| 64 | # Find last entry in error-log.md |
| 65 | grep "id: ERR-" skills/error-log/SKILL.md | tail -1 |
| 66 | # Take next number: ERR-2026-004 -> ERR-2026-005 |
| 67 | ``` |
| 68 | |
| 69 | ### Step 3 — Formulate the entry |
| 70 | *Action directive only. The CI verb allow-list rejects anything else.* |
| 71 | |
| 72 | Use the template at `skills/error-log/_entry-template.md`. The schema at [`schemas/error-entry.json`](../../schemas/error-entry.json) is enforced by CI. |
| 73 | |
| 74 | > [!WARNING] |
| 75 | > **CI GATE · verb allow-list** — `new_rule` must start with one of `Always`, `Never`, `Before`, `After`, `Prefer`, `Avoid`, `Use`, `Do`, `Ensure`. Anything else is rejected. |
| 76 | |
| 77 | Bad: `"SQL injection is dangerous"` |
| 78 | Good: `"Never concatenate user input directly into SQL queries. Always use prepared statements."` |
| 79 | |
| 80 | ### Step 4 — Determine target file |
| 81 | *One file per category. Domain rules go to a project file, not a global one.* |
| 82 | |
| 83 | | Error category | Target file | |
| 84 | |---|---| |
| 85 | | `development` | `skills/code-quality/SKILL.md` | |
| 86 | | `git` | `skills/git-conventions/SKILL.md` | |
| 87 | | `deployment` | `skills/review-deployment/SKILL.md` | |
| 88 | | `security` | `skills/code-quality/SKILL.md` (Security section) | |
| 89 | | `performance` | `skills/code-quality/SKILL.md` (Performance section) | |
| 90 | | `domain` | `skills/<project>/SKILL.md` | |
| 91 | |
| 92 | ### Step 5 — Insert the rule |
| 93 | *At the end of the matching section. Reference the ERR-ID.* |
| 94 | |
| 95 | 1. Open the target file. |
| 96 | 2. Find the matching category section. |
| 97 | 3. Add the new rule at the end of the section. |
| 98 | 4. Add reference: `Reference: ERR-YYYY-NNN`. |
| 99 | |
| 100 | ### Step 6 — Open a PR |
| 101 | *Never push to `main` directly. The label triggers the lint-rules workflow.* |
| 102 | |
| 103 | ```bash |
| 104 | git checkout -b learn/ERR-YYYY-NNN |
| 105 | git add skills/ |
| 106 | git diff --cached # MANDATORY human review step |
| 107 | git commit -m "learn(errors): ERR-YYYY-NNN — <short description> |
| 108 | |
| 109 | Co-Authored-By: <your real name> <your-email@example.com>" |
| 110 | git push -u origin learn/ERR-YYYY-NNN |
| 111 | gh pr create --label needs-rule-review \ |
| 112 | --title "learn(errors): ERR-YYYY-NNN" \ |
| 113 | --body "Auto-generated rule. Reviewer: confirm rule wording and target file. CI \`lint-rules\` must pass." |
| 114 | ``` |
| 115 | |
| 116 |  |
| 117 | |
| 118 | *Branch through CI gates and CODEOWNERS into a squash-merge on `main`.* |
| 119 | |
| 120 | **Why a PR (not a direct commit).** *Four layers of gating.* |
| 121 | |
| 122 | | Layer | What it gates | Where | |
| 123 | |---|---|---| |
| 124 | | `lint-rules` | Schema + ve |