Cheat sheets

Agent Skills: Discovery, Invocation, Routing

Write, install, discover, invoke and route SKILL.md packages. Validators, catalogs, router and installer projects.

  • Tasks and commands
  • Annotated code
  • Diagrams
  • Comparisons
  • Defaults and numbers
  • Troubleshooting
  • Questions and tips

Source

Skill lifecycle#

1Discoveryfinds packages in configured locations.2Validationrejects malformed or unsafe packages before thecatalog.3Catalogingexposes only name and description.4Selectiondecides if the skill is relevant to the request.5Activationloads the body into model-visible context.6Disclosurereads references or assets only when a branchneeds them.7Executionuses host tools under host permission andisolation rules.8Verificationchecks the artifact apart from the model'sclaim.

Install, invoke, remove#

CommandWhat it does
npx skills add rohitg00/ai-engineering-from-scratch --skill skill-contract-reviewer --full-depthInstalls the nested bundle with references, script and asset
/skill-contract-reviewer <request>Explicit invocation in a host with /skill-name syntax
/skillsPicks a skill by name in the Codex interface
python3 <SKILL_ROOT>/scripts/check_skill.py <TARGET_ROOT>/my-first-skillRuns the bundled validator. Show argv, cwd and exit code
npx skills remove skill-contract-reviewerRemoves the bundle. Use the same host and scope
python3 scripts/install_skills.py /tmp/aiefs-skills --phase 13 --type skillCopies Phase 13 bundles and writes manifest.json
python3 -m unittest discover -s code/tests -vRuns a lesson test suite

Project runs and grading#

TaskCode
Create a learner workspacepython3 scripts/project_test.py skill-router --init learning-artifacts/skill-router
Grade one stagepython3 scripts/project_test.py skill-router --stage 1 --path learning-artifacts/skill-router
Route the sample requestnode learning-artifacts/skill-router/cli.ts projects/skill-router/examples/skills projects/skill-router/examples/request.json
Dry run an installnode learning-artifacts/skill-installer/cli.ts inspect projects/skill-installer/examples/orchard-release.json codex
Install for realcli.ts install bundle.json agent root expected-source-digest
Build the validatorrustc --edition=2021 learning-artifacts/skill-validator/cli.rs -o learning-artifacts/skill-validator/validator
Validate and load in 2000 charactersvalidator projects/skill-validator/examples/orchard-release 2000 --activate references/restore.md
Check a reference solutionpython3 scripts/project_test.py skill-validator --all --solution --strict

Writing rules#

  • name must match the parent directory.
  • Description: one clause for the capability, one for the trigger boundary.
  • Add a negative boundary when two skills share words. Test near misses.
  • Filter by eligibility first. Then rank. Abstain when no score is strong enough.
  • Do not interpolate raw arguments into shell commands.
  • Name a dependency skill and a fallback. Stop when it is unavailable.

Questions#

Skill or hook?
A hook when every event must run. A skill for model judgment.
Skill or MCP tool?
A tool for a typed external capability. A skill for procedure.
Does an explicit name bypass policy?
No. It still passes every gate.
Does the router run the skill?
No. It emits plans and explanations only.
Does a successful install prove activation?
No. The agent must discover it.

Validate, catalog, disclose, route (lessons)#

report = validate_skill_text(text, directory_name, allowed_runtime_extensions=())
select_primitives(task)code, skill, hook, subagent, tool
candidates = (*discover_scope(Scope("project", project_root)),
*discover_scope(Scope("user", user_root)))immediate children only
catalog = build_catalog(candidates, precedence=("project", "user"),
budget=CatalogBudget(max_entries=10, max_catalog_chars=2_000))
body = load_skill_body(selected, candidates)level 2
reference = load_reference(selected, "references/format.md")level 3
validate_reference(skill_directory, reference)blocks traversal and escape
route_request(skills, request, adapter)eligibility before ranking
build_invocation_matrix(policy)human by model view

Router and installer (projects)#

const skills = await loadCatalog(root);SKILL.md plus routing.json
rank(skills, query, files);keyword 2, path 3
plan(skills, selected, allowed);dependencies first
route(skills, query, files, allowed, margin = 1);ready, no-match, ambiguous, blocked
safePath(name);rejects .., absolute, C:, backslash
const files = translate(bundle, agent);new quoted header, same body
const expected = digest(bundle.files);SHA-256 of sorted pairs
await install(root, bundle, agent, expectedDigest);staged rename with backup

Human and model invocation#

FactorSharedHuman-onlyModel-onlyDisabled
Human can invokeYesYesNoNo
Model can invokeYesNoYesNo
One host fieldDefaultdisable-model-invocation: trueuser-invocable: falseNot defined
ExampleTest planningPublish preparationInternal style guideDeprecated package

Limits and defaults#

SettingDefaultNote
name length64Lowercase words joined by hyphens
description length1024Says what and when
compatibility length500Optional core field
max_description_chars240CatalogBudget per entry
max_catalog_chars8_000CatalogBudget total
max_chars12_000Body and reference loads
model_threshold0.2Implicit selection floor
Router margin1Smaller score gap is ambiguous

Failures and fixes#

SymptomCauseFix
no-matchNo keyword or path scoredAdd keywords or paths in routing.json
ambiguousTop two scores differ by less than marginMake the trigger boundaries distinct
blocked with permission deniedSkill or a dependency needs more permissionsAllow it or pick another route
unsupported YAML syntaxTag, alias, multiline or flow valueUse a plain or double-quoted scalar
integrity mismatchBundle digest differs from the expected digestRun inspect, compare source_digest
modified installationA tracked file changed since installMove the edit into the source bundle
Skill unavailable after installHost did not rescan its catalogStart a new session or rescan, then retry
Model never picks the skillVague description or budget cut itCheck the discovery log and catalog size