From 0182c682b93926830fd8396a9d719738fa0e4ba2 Mon Sep 17 00:00:00 2001 From: Lukasz Boryn Date: Tue, 9 Jun 2026 06:56:27 +0200 Subject: [PATCH] feat(skills): add add-copilot-project-skill engineering skill Scaffolds a project-specific, Copilot-consumed skill set authored in the Claude Code SKILLS structure: single-sourced from the repo's docs, leaf + parent skills with guided handoff, and a mechanical validator checkpoint. Topic files cover layout/surfaces, validator design, and stub templates. --- .../add-copilot-project-skill/SKILL.md | 64 ++++++++++++++ .../layout-and-surfaces.md | 59 +++++++++++++ .../project-validator.md | 61 ++++++++++++++ .../skill-templates.md | 83 +++++++++++++++++++ 4 files changed, 267 insertions(+) create mode 100644 skills/engineering/add-copilot-project-skill/SKILL.md create mode 100644 skills/engineering/add-copilot-project-skill/layout-and-surfaces.md create mode 100644 skills/engineering/add-copilot-project-skill/project-validator.md create mode 100644 skills/engineering/add-copilot-project-skill/skill-templates.md diff --git a/skills/engineering/add-copilot-project-skill/SKILL.md b/skills/engineering/add-copilot-project-skill/SKILL.md new file mode 100644 index 0000000..52fc6e4 --- /dev/null +++ b/skills/engineering/add-copilot-project-skill/SKILL.md @@ -0,0 +1,64 @@ +--- +name: add-copilot-project-skill +description: Scaffold a project-specific skill set that guides contributors through a repo's repeatable, error-prone extension tasks — consumed by GitHub Copilot, authored in the Claude Code SKILLS structure, single-sourced from the repo's own docs, and backed by a mechanical validator. Tuned for config-driven pipelines (e.g. R `{targets}` projects). Use when the user says "add copilot project skills", "turn our onboarding/extension workflow into skills", "guide contributors to add datasets/modules/targets/chapters", "make a Copilot skill set for this repo", "/add-copilot-project-skill". +--- + +# add-copilot-project-skill + +Build a set of *project* skills that live in the repo and lower the error rate +on its recurring extension tasks (add a data source, a module, a pipeline node, +a report section). The skills are authored once in the **Claude Code SKILLS +structure** and surfaced to **GitHub Copilot** via prompt files — one body, two +front doors, no drift. + +## When to use +- A repo has a repeatable, multi-step extension task with silent failure modes + (something declared but not registered; a name that must match in two places). +- The team uses GitHub Copilot and wants guided, in-repo workflows. +- The user wants Claude Code SKILLS conventions but Copilot as the consumer. + +## Process +1. **Interview the repo, not just the user.** Read the existing contributor + docs, the task runner (`justfile`/`make`), and the directories a contributor + edits. Identify, with the user: + - the 3–6 **extension tasks** worth a skill each (the *artifacts*); + - which tasks compose into a larger one (the *modalities/parents*); + - the **silent failure modes** — invariants that, if violated, fail late or + never (these become the validator). See [project-validator.md](project-validator.md). +2. **Build the validator first** — everything else leans on it. A standalone + script (`scripts/validate_extension.*`, wired as `just validate`) that checks + the invariants, scoped to changed files, tuned to pass clean on the main + branch. Details + the AST-parsing and severity rules in + [project-validator.md](project-validator.md). +3. **Write the always-on conventions** — `AGENTS.md` and + `.github/copilot-instructions.md` carry the house style so every suggestion + inherits it without a skill being invoked. Templates in + [skill-templates.md](skill-templates.md). +4. **Author the leaf skills** (one per artifact task) and **parent skills** (one + per composite/modality). Each is a thin, conversation-style stub: interview + first, point at **live repo files** as the example (zero drift), end at the + validator, then **hand off to the next skill by name and pause** — Copilot + cannot auto-invoke a sub-prompt, so never auto-chain. Layout, the + Claude↔Copilot mapping, and the handoff rule are in + [layout-and-surfaces.md](layout-and-surfaces.md). +5. **Mirror each skill to `.github/prompts/.prompt.md`** — a stub that + points back to its canonical `SKILL.md` so the two cannot drift. +6. **Verify**: run `just validate` on a clean tree (expect zero errors); confirm + every path a skill cites actually exists; deliberately break one invariant + and confirm the validator catches it, then revert. + +## Output / done criteria +- `skills//SKILL.md` (canonical) + `.github/prompts/.prompt.md` + (mirror) for each task; `AGENTS.md` + `.github/copilot-instructions.md`; + a working `scripts/validate_extension.*` wired as `just validate`. +- Validator passes clean on the main branch and fires on an injected break. +- Skills reference live files, interview first, and hand off explicitly. + +## Guardrails +- **Single-source.** The procedure lives in the repo's `docs/`; `SKILL.md` and + `.prompt.md` are stubs that link to it. Never copy a procedure into both. +- **No auto-chaining.** Parents guide; they don't silently run children. +- **Validator must pass clean first.** Tune severities to the existing tree, or + contributors learn to ignore it. Don't invent invariants the repo doesn't hold. +- This skill produces *another repo's* skills — keep its own SKILL.md generic; + the worked specifics belong in the target repo's docs and live examples. diff --git a/skills/engineering/add-copilot-project-skill/layout-and-surfaces.md b/skills/engineering/add-copilot-project-skill/layout-and-surfaces.md new file mode 100644 index 0000000..7a0a402 --- /dev/null +++ b/skills/engineering/add-copilot-project-skill/layout-and-surfaces.md @@ -0,0 +1,59 @@ +# Layout, surfaces, and the handoff rule + +How the dual-surface, single-source skill set is arranged in a target repo. + +## File layout + +``` +docs/ canonical procedures (the body — extend, don't duplicate) +AGENTS.md always-on house conventions +skills//SKILL.md canonical skill, Claude Code SKILLS structure +.github/ + copilot-instructions.md always-on conventions, Copilot-wide + prompts/.prompt.md Copilot front door (/name in Copilot Chat) +scripts/validate_extension.* the mechanical checkpoint (just validate) +``` + +The real procedure stays in `docs/`. `SKILL.md` and `.prompt.md` are **stubs**: +a trigger line, a short decision tree, the checklist, and links into `docs/` +plus the live example files. One canonical body, two front doors. + +## Claude Code SKILLS structure → Copilot mapping + +| SKILLS convention | Copilot surface | +|---|---| +| `skills//SKILL.md` (`/name`) | `.github/prompts/.prompt.md` (`/name`) | +| project memory / conventions | `.github/copilot-instructions.md` (always on) | +| auto-trigger by `description` | `.github/instructions/*.instructions.md` with `applyTo:` globs | +| supporting topic files | shared `docs/*.md` referenced by both | + +The canonical skill is authored in the SKILLS structure (frontmatter, "Use +when" trigger, ≤100-line body); the `.prompt.md` mirror points back to it so the +two cannot drift. (If the team also runs Claude Code, symlink or copy +`skills/` into `.claude/skills/` to make it `/`-invocable there too.) + +## Two axes of skills + +- **Leaf skills** — one per *artifact* a contributor edits (a config, a module, + a pipeline node, a report section). Standalone-invocable. +- **Parent skills** — one per *composite* task, sliced by the dimension the + contributor actually thinks in (e.g. data modality: single-cell / bulk / + spatial). A parent interviews, then walks the leaves. + +## The handoff rule (why no auto-chaining) + +A Copilot `.prompt.md` **cannot programmatically invoke another prompt** — the +user types `/next-skill` themselves. So parents must use **guided handoff**: +complete one stage, run the validator, then name the exact next skill and +**pause**. Author Claude `SKILL.md` parents the same way, for parity and so the +contributor stays in the loop and learns the sequence. Never bury the chain. + +## Skill anatomy (leaf or parent) + +1. **Interview first** — gather the few facts that decide the rest before + generating anything. +2. **Point at a live example** — "copy the shape of ``". + Live references never drift; frozen snippets do. +3. **Do the edits** — the minimal set, in the repo's house style. +4. **Validate** — end at `just validate --changed`; interpret its errors. +5. **Hand off** — name the next skill (or declare done) and stop. diff --git a/skills/engineering/add-copilot-project-skill/project-validator.md b/skills/engineering/add-copilot-project-skill/project-validator.md new file mode 100644 index 0000000..30f47b2 --- /dev/null +++ b/skills/engineering/add-copilot-project-skill/project-validator.md @@ -0,0 +1,61 @@ +# Designing the project validator + +The validator is the shared checkpoint every skill ends on. It turns the repo's +silent failure modes into a fast, deterministic check so contributors catch +wiring mistakes in seconds instead of hours into a pipeline run. + +## 1. Enumerate the invariants + +Walk the extension tasks and ask "what holds when this is done right?" Typical +invariants in a config-driven `{targets}`-style R pipeline: + +- **Identity match** — a node's declared `name` string equals its + `tar_target()` symbol. +- **Naming convention** — node names carry the expected prefix for their group. +- **Registration** — every declared node appears in the registry that decides + what gets built. *This is usually the headline silent killer:* declared but + unregistered → never built, no error. +- **Config completeness** — each config file has its load-critical keys, + non-empty, and valid syntax. +- **Cross-reference** — each config id is wired into the loader/registry that + attaches its behavior (formatter/handler). + +Only encode invariants the repo *actually* holds today. Inventing stricter +rules makes the validator fail on the main branch and trains people to ignore it. + +## 2. Parse structurally, not by grep + +Naive `grep` for `name =` catches palette args, filenames, and unrelated keys. +Parse the source instead. In R, `parse()` + a recursive AST walk lets you match +the exact idiom (`list(name = "x", target = tar_target(x, ...))`) and ignore +look-alikes. Compare the declared string to the actual symbol; check membership +against the registry file's text. + +## 3. Severities tuned to pass clean + +- **Errors** fail the run (exit ≠ 0): the structural invariants above. +- **Warnings** are advisory: pre-existing inconsistencies (filename vs id + mismatches, optional blocks). Run the validator on the untouched main branch + and demote anything that fires there from error to warning, or fix the tree. + Goal: **zero errors on a clean checkout.** + +## 4. Scope to what changed + +Default to a full audit; add a `--changed [base]` mode for the skill checkpoint +so it only reports on files the contributor touched. Combine three git sources +so a brand-new file is never skipped: + +- committed diff vs the base (`git diff --name-only `), +- working-tree changes (`git diff --name-only HEAD`), +- **untracked** files (`git ls-files --others --exclude-standard`). + +The untracked source matters most — a freshly-added config is untracked and +`git diff` alone misses it. + +## 5. Wire it and prove it + +- Add a task-runner recipe: `validate *args: scripts/validate_extension.* {{args}}`. +- Prove each check fires: inject one violation of each invariant, run + `--changed`, confirm the matching error, then revert. +- Leave style/lint rules (imports, extraction idioms) to the existing linter and + the module skill — don't duplicate a third copy in the validator. diff --git a/skills/engineering/add-copilot-project-skill/skill-templates.md b/skills/engineering/add-copilot-project-skill/skill-templates.md new file mode 100644 index 0000000..42596b6 --- /dev/null +++ b/skills/engineering/add-copilot-project-skill/skill-templates.md @@ -0,0 +1,83 @@ +# Stub templates + +Copy-paste starting points. Keep them thin — the procedure lives in `docs/`. + +## Canonical leaf skill — `skills//SKILL.md` + +```markdown +--- +name: +description: . Use when the user says "", "/", or . +--- + +# + + +Full procedure: **`docs/.md`**. Live example to copy: +**``**. + +## Interview first +1. +2. ... + +## Steps +1. +2. + +## Finish +- Run **`just validate --changed`**; interpret . +- Hand off: "Next, run `/`." Then stop. +``` + +## Parent (composite) skill + +```markdown +--- +name: +description: End-to-end guide to . Use when ... Orchestrates the leaf skills by guided handoff. +--- + +# (orchestrator) + +Conversation with **guided handoffs**: finish a stage, validate, name the next +leaf skill, and **pause** — do not auto-run the chain. Canonical example: +**``**. + +## Stage 0 — interview + + +## Stage sequence (hand off one at a time) +1. `/leaf-a` +2. `/leaf-b` +3. ... + +## Checkpoints +Run `just validate --changed` after stages ; resolve errors before continuing. +``` + +## Copilot mirror — `.github/prompts/.prompt.md` + +```markdown +--- +mode: agent +description: . +--- + +Follow the canonical procedure in [`skills//SKILL.md`](../../skills//SKILL.md) — read it now — applying [`copilot-instructions.md`](../copilot-instructions.md). + +<2–4 line compressed recap of the steps + the live example path.> + +Finish with `just validate --changed`, then . +``` + +Relative paths from `.github/prompts/`: `../../skills/...`, `../../docs/...`, +`../copilot-instructions.md`. + +## Always-on conventions — `AGENTS.md` and `.github/copilot-instructions.md` + +Same content, two files. Cover: the language style rules (imports, extraction, +iteration), the directory/naming layout, the one-token-everywhere convention +(prefix = cache group = log tag, or your repo's equivalent), the most common +pipeline mistakes, the "run `just validate --changed` before finishing" rule, +and commit conventions. Keep `copilot-instructions.md` self-contained enough to +stand alone; have it link to `AGENTS.md` and `docs/` for depth.