|
| 1 | +# Agent skill generation |
| 2 | + |
| 3 | +How agent-skill-forge turns a requirement YAML into a complete, verifiable skill package. This covers pipeline stages 1–4; verification and release are covered in [skill-verification-pipeline.md](skill-verification-pipeline.md) and [llm-eval-quality-gates.md](llm-eval-quality-gates.md). |
| 4 | + |
| 5 | +## From requirement to normalized requirement |
| 6 | + |
| 7 | +The input is a single YAML file (see `examples/`). The schema (`src/requirements/requirement-schema.ts`) validates: |
| 8 | + |
| 9 | +- `name` (kebab-case), `version` (semver), `description` |
| 10 | +- `goals` (min 1), `non_goals` |
| 11 | +- `tools` — each with `name` (snake_case), `type` (`read` | `write`), `description`; duplicates rejected |
| 12 | +- `safety_requirements`, `acceptance_criteria` (min 1) |
| 13 | +- optional `quality_gate` thresholds |
| 14 | + |
| 15 | +Validation fails early with per-field messages. The normalizer (`requirement-normalizer.ts`) trims whitespace, converts snake_case to camelCase, and applies default quality gate thresholds (90% pass rate, 100% schema validity, 2% unsupported claims, 5% tool errors) when the file omits them. The result is persisted as `artifacts/normalized-requirement.json`. |
| 16 | + |
| 17 | +## From requirement to skill spec |
| 18 | + |
| 19 | +`generate_spec` produces an explicit behavioral contract (`artifacts/skill-spec.json`). The offline mock adapter derives it deterministically (`src/spec/skill-spec-generator.ts`): |
| 20 | + |
| 21 | +| Requirement signal | Spec consequence | |
| 22 | +| ------------------ | ---------------- | |
| 23 | +| tool `type: write` | `requiresConfirmation: true` on that tool boundary (safe default, always) | |
| 24 | +| safety mentions "idempoten…" | write tools get `idempotent: true` | |
| 25 | +| safety mentions "rate limit" | rate limit backoff/failure rules added to failure behavior | |
| 26 | +| safety/acceptance mention partial failure | `partial_success` reporting rule added | |
| 27 | +| goals/criteria mention citations or grounding | `citations` added to required output fields | |
| 28 | + |
| 29 | +Every spec declares the same five statuses (`success`, `partial_success`, `insufficient_information`, `refused`, `error`), input expectations, failure behavior, and an eval strategy (case counts scale with goals and non-goals). |
| 30 | + |
| 31 | +Real model adapters may produce richer specs, but the pipeline re-validates whatever comes back against `skillSpecSchema` (zod) at the stage boundary — an invalid spec fails the stage instead of corrupting downstream generation. |
| 32 | + |
| 33 | +## From spec to package files |
| 34 | + |
| 35 | +`generate_skill_package` renders the core files (`src/generators/`): |
| 36 | + |
| 37 | +- **SKILL.md** (`skill-md-generator.ts`) — eight fixed sections (When to Use → Acceptance Criteria). Every behavioral rule appears as concrete text: the machine-parsable `- Allowed status values:` line, per-tool confirmation and idempotency bullets, safety requirements verbatim, explicit partial-failure and missing-field handling. |
| 38 | +- **skill.manifest.json** (`manifest-generator.ts`) — name, version, `generatedBy`, `generatedAt`, tool list, file map, quality gate. |
| 39 | +- **tools.json** (`tools-generator.ts`) — one contract per tool with a JSON-Schema-style `inputSchema`; confirmation-gated tools require `user_confirmed`, idempotent tools require `idempotency_key`. Details in [tool-calling-skill-contracts.md](tool-calling-skill-contracts.md). |
| 40 | +- **examples.md** — happy path, missing-information edge case, refusal, and (when a write tool exists) a confirmed-write example with real JSON outputs. |
| 41 | +- **README.md** — package-level overview and regeneration instructions. |
| 42 | + |
| 43 | +## From spec to eval cases |
| 44 | + |
| 45 | +`generate_eval_cases` (`eval-case-generator.ts`) emits machine-checkable cases: |
| 46 | + |
| 47 | +- **golden** — one per goal; expect `success`, check `structured_output`, `no_unsupported_claims` (plus `mentions:citation` for grounded skills) |
| 48 | +- **negative** — one per non-goal; expect `refused`, check the non-goal is covered verbatim |
| 49 | +- **edge** — missing required fields (`insufficient_information`), partial workflow success (`partial_success`, when relevant), out-of-scope request (`refused`) |
| 50 | +- **tool_failure** — rate-limit failure and confirmation-bypass attempts against write tools |
| 51 | + |
| 52 | +Each case carries an expected status plus capability checks (`status:…`, `confirm:…`, `mentions:…`; full grammar in [skill-package-format.md](skill-package-format.md)). Verification rules (`verification-rules-generator.ts`) — required files, sections, statuses, and forbidden claim patterns like "guarantee" or "never fails" — complete the package. |
| 53 | + |
| 54 | +## Properties worth relying on |
| 55 | + |
| 56 | +- **Deterministic**: with `--model mock`, the same YAML always yields the same package (timestamps aside). CI and tests depend on this. |
| 57 | +- **Self-describing**: the package embeds its own eval cases and verification rules, so any conforming verifier can re-check it later without the original requirement. |
| 58 | +- **Regenerable**: the requirement file is the source of truth. To change a skill, edit the YAML and re-run the pipeline; hand-edits to generated files are overwritten (see [production-agent-skills.md](production-agent-skills.md)). |
0 commit comments