diff --git a/skill-template/README.md b/skill-template/README.md new file mode 100644 index 0000000..ba45400 --- /dev/null +++ b/skill-template/README.md @@ -0,0 +1,15 @@ +This folder is the main skill tempalte and guide for all my skill building. I will use skills from others to help maintain this and improve it. The tempalte is ratchet-based...md + +I am finding it very helpful to clone repos from others to have on file for analysis in building skills and processes for software development. I clone them into C:\projects\repos. THis way, I can point AI to this folder to help with analysis when improving skills and the template. + +to clone a repo: (example) + +git clone https://github.com/garrytan/gstack.git + +To update existing repos: + +for repo in /mnt/c/projects/repos/*/.git; do + dir="$(dirname "$repo")" + echo "Updating $dir" + git -C "$dir" pull +done diff --git a/skill-template/personas.md b/skill-template/personas.md new file mode 100644 index 0000000..a7be008 --- /dev/null +++ b/skill-template/personas.md @@ -0,0 +1,19 @@ +# Description + +As AI may run sub-agents, this document defines the personas for those sub-agents. Set up clear path where AI agents orchestrate other AI agents. This is where it is done. + +# Sub-Agent Personas + +Each of these "owns" a portion of the docs, and reviews against their own documentation, including suggesting where their own docs need to be adapted. + +## Designer + +## Architect + +## Domain Expert + +## Code Expert + +## Performance Expert + +## Human Advocate diff --git a/skill-template/ratchet-based-skill-framework.md b/skill-template/ratchet-based-skill-framework.md new file mode 100644 index 0000000..694a20d --- /dev/null +++ b/skill-template/ratchet-based-skill-framework.md @@ -0,0 +1,1193 @@ +# Ratchet-Based Skill Framework + +The core lesson is simple: + +> A skill should not just tell an agent what to do. A skill should make the agent better at doing the work every time it runs. + +That means every skill should include a ratchet loop: + +1. Execute the workflow. +2. Test and validate the output aggressively. +3. Identify what broke, what was ambiguous, or what the agent tried to shortcut. +4. Convert that lesson into a durable artifact: a test, validator, eval case, anti-pattern, schema rule, routing example, or skill instruction. +5. Re-run the workflow so the same failure becomes harder to repeat. + +The skill is the operating procedure. The tests and validators are the memory. The ratchet is the loop between them. + +## The Big Idea + +The important insight is not merely "use AI to write tests." The deeper point is that AI changes the economics of verification. + +Humans avoid exhaustive testing because it is tedious, repetitive, and expensive in attention. Edge cases are especially painful because each one may be rare, but together they define whether a system is reliable. + +AI agents are different. They do not get bored writing the fourteenth edge-case test. They can generate test cases, run scripts, inspect failures, refine code, update instructions, and repeat. That means the bottleneck moves from "can a human bear to test this thoroughly?" to "have we clearly defined what correctness means?" + +For skill development, this is the key move: + +> Every important behavior should become a contract, and every contract should have a validation surface. + +A contract can be tested with code, checked with a schema, verified by examples, enforced through a STOP gate, or evaluated by another model. The form depends on the work. The principle is the same. + +## Learnings + +Skills pattern is useful because it treats skills as operational recipes, not passive documentation. + +A strong skill says: + +- when this situation happens +- what workflow to follow +- what guarantees must hold +- what tools to use +- what good output looks like +- what must never happen +- how to validate that the work is actually done + +The best structure is: + +```text +skills/ + RESOLVER.md + manifest.json + conventions/ + quality.md + output-rules.md + identity-policy.md + some-skill/ + SKILL.md +``` + +The split matters: + +- `RESOLVER.md` decides which skill should run. +- `SKILL.md` defines how to perform the work. +- `conventions/` stores shared rules. +- `manifest.json` gives a machine-readable inventory. +- routing examples test whether the resolver chooses correctly. +- conformance tests verify that skills obey their contracts. + +This is the foundation. The ratchet adds a stronger testing and learning loop. + +## Ratchet-Based Skill Anatomy + +Use this template when creating or rewriting skills. + +```md +--- +name: skill-name +description: What this skill does and the specific situations where Codex should use it. +--- + +# Skill Name + +## Contract + +This skill guarantees: + +- ... +- ... +- ... + +## Inputs + +The skill expects: + +- ... + +## Outputs + +The skill produces: + +- ... + +## Skill Shape + +Choose the narrowest shape that fits: + +- `service`: one bounded workflow with clear inputs and outputs +- `system`: multiple services, personas, or phases coordinated together +- `pattern`: reusable coordination structure, such as worker-critic or fan-out +- `responsibility`: standing goal that must remain true over time +- `test`: fixture-driven validation of a skill, system, or output + +## Requires + +This skill requires: + +- ... + +## Ensures + +Before finishing, this skill ensures: + +- ... + +## Capabilities + +Required host capabilities: + +- CLI tools: +- MCP/connectors: +- browser access: +- filesystem access: +- network access: +- subagent support: +- image/document/spreadsheet support: + +If a required capability is unavailable, fail closed or ask the user. Do not silently fake the workflow. + +## State Scope + +Declare what persists: + +- `none`: no state survives the run +- `run`: only this execution keeps scratch state +- `project`: project-level memory/state may be updated +- `user`: cross-project user memory/state may be updated + +Persistent writes must be named explicitly. + +## Host Primitive Adapter + +Map abstract workflow needs to available host actions: + +- spawn subagent: +- ask user: +- read/write files: +- run shell command: +- use browser: +- use connector: +- create durable report: + +If the host cannot provide a required primitive, stop and explain the missing primitive. + +## Workflow + +### Phase 1: ... + +### Phase 2: ... + +### Phase 3: ... + +## Validation + +Before finishing, verify: + +- ... +- ... +- ... + +## Run Receipt + +For serious skills, leave a durable receipt containing: + +- inputs used +- outputs produced +- validations run +- failures found +- fixes applied +- ratchet artifacts added +- unresolved risks +- follow-up recommendations + +## Edge Cases + +Actively test: + +- ... +- ... +- ... + +## Ratchet Rules + +When the skill discovers a recurring mistake, ambiguous case, failed validation, or agent shortcut, convert the lesson into at least one durable artifact: + +- a regression test +- a schema rule +- a validator check +- a routing example +- an eval case +- an anti-pattern +- a STOP gate +- a convention update + +Do not merely fix the current instance. Make the same class of failure harder to repeat. + +## Anti-Patterns + +Do not: + +- ... +- ... +- ... + +## Final Report + +Report: + +- what was produced +- what was validated +- what failed and was fixed +- what ratchet artifact was added or updated +``` + +## The Ratchet Loop + +Every serious skill should follow this operating loop: + +```text +Run the skill + -> produce output + -> validate output + -> stress edge cases + -> find failures + -> diagnose why they happened + -> update code, process, tests, or skill instructions + -> re-run validation + -> preserve the new lesson as a ratchet artifact +``` + +The important discipline is to never let a failure remain only in human memory. + +Bad: + +> "Remember that this script breaks on empty metadata." + +Good: + +> Add an empty-metadata fixture, update the validator, and add an anti-pattern to the skill. + +Bad: + +> "The agent sometimes invents relationships." + +Good: + +> Add a relationship provenance rule, a validator that rejects unsupported relationships, and an edge-case test with tempting but ungrounded relationship language. + +## Coordination Patterns + +When a skill needs more than one role, do not improvise the collaboration pattern each time. Pick a reusable structure and name it in the skill. + +Useful patterns: + +- `worker-critic`: one agent produces, another critiques, repeat until accepted +- `fan-out`: multiple agents explore independently, parent synthesizes +- `pipeline`: output of one role feeds the next +- `guard`: run a workflow only if preconditions pass +- `fallback-chain`: try safer or cheaper options before expensive ones +- `reviewer-panel`: personas review from different risk lenses +- `map-reduce`: split a large corpus across workers, then aggregate +- `race`: run several approaches and keep the first acceptable result + +Patterns should declare their slots, expected handoffs, invariants, and stopping condition. Personas can then fill the slots without each skill rewriting the coordination rules from scratch. + +## Testing And Validation Surfaces + +A skill can be tested at several levels. Use more than one when the work is important. + +### 1. Schema Validation + +Use when outputs are structured. + +Examples: + +- JSON chunks match the project schema. +- required fields are present. +- enum values are valid. +- relationship types are allowed. +- confidence values are within accepted ranges. + +### 2. Invariant Checks + +Use when certain rules must always hold. + +Examples: + +- `knowledge_id` remains stable across minor edits. +- content hashes match the source text. +- every relationship target resolves. +- every claim has provenance. +- private content is not emitted into public outputs. + +### 3. Golden Fixtures + +Use when known inputs should produce known outputs. + +Examples: + +- a simple source page +- a page with contradictory claims +- a page with quoted beliefs +- a page with no useful entities +- a page with private/pricing/policy content + +The point is not that the full output must be identical every time. The point is that important properties should remain true. + +### 4. Edge-Case Suites + +Use AI to generate exhaustive cases the human would not want to write manually. + +Examples: + +- empty input +- malformed input +- duplicate entities +- near-duplicate chunks +- ambiguous pronouns +- quoted claims +- conflicting dates +- missing source URLs +- circular relationships +- deprecated chunks +- access-rule conflicts + +### 5. Behavioral Tests + +Use when the skill must enforce agent behavior, not just file output. + +Examples: + +- the agent must ask before destructive changes. +- the agent must not skip validation. +- the agent must report uncertainty. +- the agent must not treat inferred assertions as facts. +- the agent must stop when required inputs are missing. + +This can be enforced through STOP gates, final-report requirements, subagent forward tests, or terminal/browser/API harnesses. + +### 6. Routing Tests + +Use when multiple skills exist. + +Examples: + +- "generate chunks" routes to chunk generation. +- "validate my knowledge build" routes to validation. +- "publish the site" routes to publish. +- "extract relationships" routes to relationship extraction. + +Store routing examples in a machine-readable file when possible, such as `routing-eval.jsonl`. + +### 7. Evaluation Cases + +Use when quality is partly judgment-based. + +Examples: + +- is this chunk useful for retrieval? +- is this Q&A faithful to the source? +- did the relationship extraction avoid hallucination? +- did the generated summary preserve nuance? + +For subjective outputs, use rubric-based evals. The ratchet is the recorded baseline: future changes should not score worse. + +## Skill Sections To Add Going Forward + +For your future skills, these sections should become standard. + +### Skill Shape + +Classify the skill before writing it. This prevents every skill from becoming a giant all-purpose prompt. + +```md +## Skill Shape + +Choose the narrowest shape: + +- `service`: one bounded workflow with clear inputs and outputs +- `system`: multiple services, personas, or phases coordinated together +- `pattern`: reusable coordination structure, such as worker-critic or fan-out +- `responsibility`: standing goal that must remain true over time +- `test`: fixture-driven validation of a skill, system, or output +``` + +Use `service` by default. Use `system` only when coordination is part of the work. Use `responsibility` when the skill protects an ongoing condition rather than producing a one-time artifact. + +### Contract + +Define what the skill guarantees. + +Example: + +```md +## Contract + +This skill guarantees: + +- every chunk has stable identity fields +- every factual claim has provenance +- generated Q&A is grounded in source material +- uncertain enrichments are stored as proposed assertions, not facts +- validation is run before final output +``` + +### Requires And Ensures + +Use contract language that is easy for agents to extract and easy for humans to review. + +```md +## Requires + +The skill must have: + +- `input_name`: what the caller or upstream workflow must provide +- `tool_name`: required tool, permission, connector, or local file + +## Ensures + +The skill guarantees: + +- `output_name`: concrete output or postcondition +- each produced artifact passes the declared validation surface +``` + +`Requires` is the handoff protocol. `Ensures` is the promise. If either side is vague, the skill will drift. + +### Capabilities + +Declare host capabilities explicitly. + +```md +## Capabilities + +Required capabilities: + +- CLI tools: +- MCP/connectors: +- browser access: +- filesystem access: +- network access: +- subagent support: +- image/document/spreadsheet support: + +If a required capability is unavailable, fail closed or ask the user. Do not silently fake the workflow. +``` + +Capabilities are not the same as inputs. Inputs are data the workflow consumes. Capabilities are powers the host must provide. + +### State Scope + +Declare what survives the run. + +```md +## State Scope + +- `none`: no state survives the run +- `run`: only this execution keeps scratch state +- `project`: project-level memory/state may be updated +- `user`: cross-project user memory/state may be updated + +Persistent writes: + +- ... +``` + +This prevents accidental memory pollution and makes durable skill behavior reviewable. + +### Host Primitive Adapter + +Every skill that depends on the environment should map abstract needs to concrete host actions. + +```md +## Host Primitive Adapter + +- spawn subagent: +- ask user: +- read/write files: +- run shell command: +- use browser: +- use connector: +- create durable report: + +If the host cannot provide a required primitive, stop and explain the missing primitive. +``` + +This makes skills more portable across Codex, Claude, and future agent hosts. + +### Validation + +Define how the agent proves the contract was met. + +Example: + +```md +## Validation + +Before finishing: + +1. Validate output against the schema. +2. Check ID stability and content hashes. +3. Verify relationship targets resolve. +4. Confirm provenance exists for every claim. +5. Run edge-case fixtures when the skill or script changed. +6. Report failures and fixes. +``` + +### Edge Cases + +Make edge cases explicit so the agent does not only test the happy path. + +Example: + +```md +## Edge Cases + +Test against: + +- empty source content +- duplicate headings +- ambiguous entities +- quoted beliefs +- unsupported relationship claims +- private content +- deprecated or superseded chunks +``` + +### Ratchet Rules + +Force learning to become durable. + +Example: + +```md +## Ratchet Rules + +If validation fails, do not only patch the output. Identify the class of failure and update at least one of: + +- the skill instructions +- a validator +- a regression fixture +- a schema rule +- an anti-pattern +- a routing example +- a shared convention + +Then re-run validation. +``` + +### Run Receipt + +For serious skills, require an inspectable receipt. + +```md +## Run Receipt + +Record: + +- inputs used +- outputs produced +- validations run +- failures found +- fixes applied +- ratchet artifacts added +- unresolved risks +- follow-up recommendations +``` + +The receipt can be a Markdown report, JSON artifact, test log, run directory, or final-response block. The key is that future agents can inspect what happened without reconstructing it from memory. + +### Responsibilities + +Use responsibility mode when the skill protects an ongoing condition, not just a one-time output. + +```md +## Responsibility + +This responsibility keeps true: + +- goal: +- continuity: +- criteria: +- constraints: +- fulfillment: +``` + +Definitions: + +- `goal`: what must remain true +- `continuity`: how time, recurrence, or events qualify the obligation +- `criteria`: what counts as healthy +- `constraints`: what must stay bounded or prohibited +- `fulfillment`: what workflow restores health + +Examples: + +- Skill docs remain fresh with generated templates. +- All skills keep validation and ratchet sections. +- Cloned reference repos are periodically pulled and summarized. +- Knowledge-build outputs remain schema-valid. + +### Triggers + +For repeatable workflows, define when the skill should run. + +```md +## Triggers + +Run this skill when: + +- user asks: +- file changes: +- scheduled review: +- new repo is cloned: +- validation fails: +- release/shipping gate occurs: +``` + +Triggers make automations and recurring reviews less ad hoc. + +### Anti-Patterns + +Name the shortcuts the agent is likely to take. + +Example: + +```md +## Anti-Patterns + +Do not: + +- copy the full CIS envelope into every simple chunk +- invent relationships without provenance +- change stable IDs after minor wording edits +- promote inferred assertions into facts +- skip validation because the output "looks right" +- treat a clean script run as proof that semantic quality is good +``` + +## Recommended Skill System For Your Work + +For your CIS and knowledge-structuring work, a system could look like: + +```text +skills/ + RESOLVER.md + manifest.json + routing-eval.jsonl + conventions/ + cis-field-selection.md + identity-versioning.md + relationship-ontology.md + assertion-ledger.md + output-json.md + validation-ratchet.md + publishing.md + author-content-structuring/ + SKILL.md + cis-subset-selection/ + SKILL.md + chunk-json-generation/ + SKILL.md + qa-generation/ + SKILL.md + relationship-extraction/ + SKILL.md + ai-index-generation/ + SKILL.md + publish-static-site/ + SKILL.md + validate-knowledge-build/ + SKILL.md +``` + +The most important new skill is: + +```text +validate-knowledge-build/ + SKILL.md +``` + +That skill is the ratchet engine for the whole system. + +It should check: + +- every chunk has required IDs +- every content hash matches +- every relationship target resolves +- every selected CIS field is allowed by the project schema +- every generated Q&A maps back to source material +- every assertion has provenance and confidence +- uncertain enrichment is marked as proposed, not fact +- paid/private/public access rules are respected +- deprecated chunks have supersession lineage +- every `ai-index` entry points to a real file +- routing examples still select the right skills + +## Skill Development Workflow + +Use this workflow when building or improving a skill. + +### Phase 1: Define The Contract + +Ask: + +- What must this skill always guarantee? +- What would count as a dangerous failure? +- What should never be left to human memory? + +Write the contract before optimizing the workflow. + +### Phase 2: Define The Happy Path + +Write the normal workflow in clear phases. + +Each phase should have: + +- a purpose +- expected inputs +- expected outputs +- completion criteria + +### Phase 3: Generate Edge Cases + +Ask the agent to generate adversarial and boring edge cases. + +Use categories like: + +- missing data +- malformed data +- duplicate data +- contradictory data +- ambiguous language +- privacy-sensitive content +- quoted or attributed claims +- large inputs +- tiny inputs +- stale or deprecated content + +### Phase 4: Build Validators + +Turn the contract into checks. + +Use deterministic validation whenever possible: + +- schema validation +- ID checks +- hash checks +- link checks +- access-rule checks +- relationship-resolution checks + +Use rubric/eval validation where deterministic checks are not enough: + +- faithfulness +- usefulness +- judgment quality +- source grounding +- nuance preservation + +### Phase 5: Forward-Test The Skill + +Run the skill on realistic tasks. + +For important skills, use fresh-agent forward tests: + +- give the tester only the skill and realistic input +- do not leak the expected answer +- inspect whether the skill caused the right behavior +- record where the tester struggled + +### Phase 6: Ratchet The Lessons + +For every failure, decide where the lesson belongs: + +- Skill instruction: if the agent misunderstood the workflow. +- Anti-pattern: if the agent took a predictable shortcut. +- Validator: if the failure can be detected deterministically. +- Fixture: if the failure needs a concrete regression example. +- Eval rubric: if the failure is qualitative. +- Convention: if the lesson applies across multiple skills. +- Resolver/routing eval: if the wrong skill was selected. + +### Phase 7: Re-Run Validation + +Do not stop after editing the skill. + +Re-run the relevant tests, validators, or forward test. The ratchet only works if the new rule actually catches or prevents the failure. + +## The Practical Standard + +For future skills, use this standard: + +> No serious skill is complete until it defines its contract, edge cases, validation method, anti-patterns, and ratchet rule. + +For code-generating or output-generating skills, the stronger standard is: + +> The skill must produce or invoke tests that try to break its own output. + +This is the main learning from Garry Tan's article applied to your work. + +AI should not only create the artifact. AI should attack the artifact, find where it breaks, explain why, and improve the skill so the next run starts from a higher floor. + +## Minimal Checklist For Any New Skill + +Before calling a skill done, confirm: + +- the trigger description is clear +- the skill shape is explicit +- the contract is explicit +- requires and ensures are named +- the workflow is phased +- expected outputs are named +- capabilities are declared +- state scope is declared +- required host primitives are mapped +- validation is required +- edge cases are listed +- anti-patterns are listed +- ratchet rules are present +- serious skills produce a run receipt +- recurring workflows define responsibilities and triggers +- shared conventions are referenced instead of duplicated +- any scripts have been run at least once +- any structured outputs have schema checks +- any important failure produced a durable regression artifact + +## The One-Sentence Version + +Build skills as execution contracts with built-in verification, then use every failure to permanently raise the floor. + +## More Learnings + + +>Do not treat skills as Markdown prompts, but as software artifacts with CI, E2E tests, evals, freshness checks, and behavioral contracts. + +This is the practical version of the ratchet. The skill itself gets tested. The output gets tested. The agent behavior caused by the skill gets tested. + +### 1. Skills are generated artifacts, not hand-maintained blobs + +Many skills have both: + +```text +SKILL.md.tmpl +SKILL.md +``` + +The template is the source of truth. The generated `SKILL.md` is what the agent actually reads. Tests that generated files are fresh, unresolved placeholders are gone, and generated variants exist for the supported agent hosts. + +Learning for us: + +- If a skill has repeated shared sections, generate them. +- If a skill is generated, test freshness. +- If a shared convention changes, regenerate all affected skills. +- Do not rely on humans remembering to copy changes across skills. + +### 2. Validation is tiered by cost + +Use a tiered validation model: + +```text +Tier 1: Static validation +Tier 2: Real agent E2E runs +Tier 3: LLM-as-judge quality evals +``` + +This is excellent because not every validation needs to be expensive. + +Learning for us: + +- Run cheap deterministic checks every time. +- Run realistic workflow tests before important changes. +- Use LLM judges only when quality is subjective. +- Do not make the expensive eval the first line of defense. + +### 3. The skill files themselves are tested + +Test things like: + +- valid browser commands in skill examples +- valid command flags +- no unresolved template placeholders +- required trigger phrases +- documentation inventory consistency +- no private maintainer paths leaked into skills +- cross-skill path consistency +- generated Codex/Claude variants exist +- expected sections are present + +Learning for us: + +> A skill should have a test suite for the skill instructions themselves. + +This is a major upgrade to the framework. We should not only test the thing the skill produces. We should test whether the skill document still contains the instructions, gates, triggers, examples, and validation sections that make the skill work. + +### 4. The coverage audit is the strongest ratchet pattern + +Test coverage audit does not merely ask, "Did tests run?" + +It asks the agent to map: + +- changed code paths +- user flows +- conditionals +- error handlers +- empty states +- boundary cases +- integration points +- E2E-worthy flows +- eval-worthy LLM behavior + +Then it marks gaps and generates tests for them. + +Learning for us: + +> Coverage is not just line coverage. Coverage is behavioral surface coverage. + +For CIS, knowledge, and skill work, this means we should map: + +- workflow paths +- data paths +- user-facing paths +- transformation paths +- validation paths +- failure paths +- ambiguous interpretation paths + +Each path should either be tested, validated, explicitly accepted as uncovered, or turned into an eval case. + +### 5. Test agent behavior, not just code + +One test exists because an agent previously skipped the interactive review flow and dumped all findings at once. The regression test checks whether the agent actually fires an interactive question before finishing. + +That is extremely important. + +The tested behavior was not "does a function return the right value?" + +It was: + +> Did the agent follow the behavioral contract of the skill? + +Learning for us: + +Some skills need behavioral tests. Examples: + +- Did the agent ask before destructive actions? +- Did the agent validate before finishing? +- Did the agent avoid promoting uncertain assertions to facts? +- Did the agent stop at a required gate? +- Did the agent use the right skill instead of answering directly? +- Did the agent create a regression artifact after finding a failure? + +### 6. Skillify is a model skill-building workflow + +`/skillify` flow is especially relevant. It codifies a browser scraping prototype into a permanent skill only after: + +1. confirming there was a real prior prototype +2. capturing a fixture +3. generating `script.ts` +4. generating `script.test.ts` +5. staging the skill in a temporary directory +6. running the test +7. asking for approval +8. committing or discarding atomically + +Learning for us: + +> A new skill should be staged, tested, and approved before it becomes part of the permanent skill library. + +This is stronger than "write a skill and try it later." The skill creation workflow itself should have gates. + +### 7. QA and Ship make the ratchet operational + +`/qa` does not just find bugs. It fixes them, re-tests them, classifies the fix, and then creates regression tests when appropriate. + +`/ship` audits coverage, generates tests for gaps, blocks or asks before shipping below thresholds, and writes a reusable test plan artifact. + +Learning for us: + +Every important workflow should leave behind a reusable testing artifact: + +- test plan +- validation report +- coverage diagram +- failed-case fixture +- regression example +- eval baseline +- quality score + +The artifact becomes memory for the next skill invocation. + +## Additions To The Skill Template + +Going forward, add these sections to serious skills. + +### Test Surface + +Define what can be tested for this skill: + +```md +## Test Surface + +This skill can be tested through: + +- Static checks: +- Schema checks: +- Invariant checks: +- Fixture tests: +- Behavioral/E2E tests: +- LLM-as-judge evals: +- Routing tests: +- Freshness checks: +``` + +Examples: + +- Static checks: required sections exist, no unresolved placeholders, valid command examples. +- Schema checks: JSON output conforms to schema. +- Invariant checks: IDs remain stable, relationship targets resolve. +- Fixture tests: known input produces valid output properties. +- Behavioral/E2E tests: agent asks before proceeding, runs validation, stops at gates. +- LLM-as-judge evals: output is faithful, useful, complete, or clear. +- Routing tests: user request selects the correct skill. +- Freshness checks: generated files match templates. + +### Coverage And Edge-Case Audit + +For code-generating, data-generating, or workflow-heavy skills: + +```md +## Coverage And Edge-Case Audit + +Before finishing, map: + +- code paths or workflow paths +- user-facing flows +- failure modes +- edge cases +- existing tests or validators +- uncovered gaps + +Mark each gap as: + +- [UNIT] +- [E2E] +- [EVAL] +- [SCHEMA] +- [MANUAL] + +For every uncovered gap, either: + +1. create a test or validator, +2. add it to the test plan, +3. mark it intentionally uncovered with rationale, +4. or ask the user before proceeding. +``` + +### Regression Rule + +```md +## Regression Rule + +If this skill discovers that something previously worked and now breaks, create a regression artifact immediately. + +Do not merely fix the current output. + +Acceptable regression artifacts: + +- test fixture +- unit or integration test +- validation rule +- routing example +- eval case +- anti-pattern +- STOP gate +- shared convention update +``` + +### Validation Tiers + +```md +## Validation Tiers + +Tier 1: Fast deterministic checks run every time. + +Examples: +- schema validation +- required-section checks +- command syntax checks +- invariant checks +- placeholder checks + +Tier 2: Realistic workflow or agent E2E tests run before important changes. + +Examples: +- run the skill on a fixture +- spawn a fresh agent with the skill +- verify that required files are created +- verify that required gates are hit + +Tier 3: LLM-as-judge or cross-model evals run when quality is subjective. + +Examples: +- faithfulness scoring +- usefulness scoring +- clarity scoring +- cross-model disagreement review +- baseline regression checks +``` + +### Skill Freshness And Inventory + +```md +## Skill Freshness And Inventory + +If this skill is generated from templates, verify: + +- generated files are fresh +- placeholders are resolved +- command examples still match real commands +- docs mention the skill +- routing examples still select the skill +- no private/local-only paths leaked into the skill +- shared conventions are referenced instead of duplicated +``` + +## Three Levels Of Skill Quality + +Add an important distinction. We should judge future skills on three levels: + +### 1. Artifact Quality + +Did the generated thing work? + +Examples: + +- code compiles +- JSON validates +- chunks are well-formed +- relationships resolve +- browser flow succeeds +- document renders + +### 2. Process Quality + +Did the agent follow the intended workflow? + +Examples: + +- asked before destructive changes +- ran validation before final output +- checked edge cases +- used the browser when required +- stopped at STOP gates +- produced the required final report + +### 3. Ratchet Quality + +Did any failure become durable memory? + +Examples: + +- added a regression test +- added a fixture +- added an anti-pattern +- updated a validator +- updated a routing example +- updated a convention +- added an eval baseline + +This third level is the main Garry Tan learning. The skill is not done when the output works once. The skill is done when the next agent is less likely to repeat the same mistake. + +## Updated One-Sentence Version + +Build skills as tested execution contracts: validate the artifact, validate the agent behavior, and turn every failure into a durable guardrail that raises the floor for the next run.