From arthur0824hao-skills
BDD-style behavior specification engine for the skill system. Use when: (1) defining a new skill's behavior before implementation, (2) validating a spec against the schema, (3) generating a behavior contract (Mermaid DAG) from a spec, (4) running structural acceptance tests against a built skill. Workflow: Spec → Test → Develop → Contract.
npx claudepluginhub arthur0824hao/skills --plugin document-skillsThis skill uses the workspace's default tool permissions.
Define **what** a skill does before writing **how**. This skill enforces a BDD-style workflow:
SKILL.behavior.yamlSKILL.spec.yamlschema/spec-v1.yamlschema/spec-v2.yamlschemas/skill-manifest-v2.yamlscripts/behavior_read_gate.pyscripts/build_graph.pyscripts/coverage_gate.pyscripts/generate_behavior.pyscripts/generate_contract.pyscripts/refresh_behavior_projections.pyscripts/spec_discovery.pyscripts/test_behavior_read_gate.pyscripts/test_build_graph.pyscripts/test_coverage_gate.pyscripts/test_generate_behavior.pyscripts/test_generate_contract.pyscripts/test_refresh_behavior_projections.pyscripts/test_validate_spec.pyscripts/test_verify_structural.pyCreates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Define what a skill does before writing how. This skill enforces a BDD-style workflow:
SKILL.spec.yaml → Acceptance Tests → Implementation → SKILL.behavior.yaml (generated)
(WHAT) (VERIFY) (HOW) (DOCUMENT)
Every skill's behavior is defined in SKILL.spec.yaml:
schema_version: 1
skill_name: my-skill
description: "What this skill does"
operations:
- name: do-something
intent: "Why this operation exists"
inputs: [...]
outputs: [...]
constraints: ["Must not...", "Must always..."]
expected_effects: [...]
acceptance_tests:
structural:
- id: manifest-valid
assert: "manifest exposes all operations"
behavioral:
- id: happy-path
given: "Valid input"
when: "do-something is called"
then: "Returns expected output"
Full schema: schema/spec-v1.yaml
For v2 behavior specs (*.behavior.yaml), you can also include an optional
interaction_diagram Mermaid block to describe cross-node interactions.
interaction_diagram: |
flowchart LR
Script["runtime-doctor"] -->|"reads"| Config["config/memory.yaml"]
Scaffold a new SKILL.spec.yaml from the schema template.
schema/spec-v1.yaml for the formatSKILL.spec.yaml in the target skill directoryValidate a SKILL.spec.yaml against the v1 schema.
SKILL.spec.yamlschema_version, skill_name, description, operationsname, intent, at least one input or output, constraints presentmanifest-valid and scripts-existRun via: python3 scripts/validate_spec.py <path-to-SKILL.spec.yaml>
Run structural acceptance tests against a built skill.
SKILL.spec.yaml for declared operationsSKILL.md for the skill-manifest blockskills-index.json includes this skill's capabilitiesGenerate a SKILL.behavior.yaml (Mermaid DAG) from a completed spec + implementation.
SKILL.spec.yaml for operations, inputs, outputs, constraintsSKILL.behavior.yaml with embedded Mermaid diagramThis is the last step — only run after implementation is complete and tests pass.
Scan a project tree for scripts/modules that are missing behavior specs.
project_dir for scripts that match the configured patterns*.behavior.yaml files in the same treeRun via: python3 scripts/coverage_gate.py <project_dir> [--patterns ...] [--exclude ...]
Use this before declaring "behavior coverage is complete."
1. Understand the skill (examples, triggers)
2. Create spec → skill-system-behavior:create-spec
3. Validate spec → skill-system-behavior:validate-spec
4. Write tests → define acceptance criteria from spec
5. Initialize skill → skill-system-creator:init
6. Implement skill → edit SKILL.md, scripts, references
7. Verify structural → skill-system-behavior:verify-structural
8. Generate contract → skill-system-behavior:generate-contract
9. Package → skill-system-creator:package
SKILL.spec.yaml — the authoritative definition (human-written, reviewed)SKILL.md + manifest — implementation (must conform to spec)SKILL.behavior.yaml — generated documentation (derived from spec)Use this 3-tier hierarchy as guidance for organizing cross-file governance docs:
Tier 1 — System Architecture
├── SYSTEM_ARCHITECTURE.md (system boundaries + data flow)
└── PIPELINE_DAG.md (zoom-in companion, state machines)
Tier 2 — Behavior Contracts
├── *.behavior.yaml (single-script: inputs/outputs/stages/error_paths)
└── BEHAVIOR_RUNTIME.md (strictly cross-script scenarios only)
Tier 3 — Tests
└── test_*.py (each test traces to a specific behavior scenario)
For Tier 2 → Tier 3 traceability, use acceptance_tests.behavioral[].tested_by in SKILL.spec.yaml to point to validating tests.
For cross-tier references, use optional governance.tier and governance.traces_to in SKILL.spec.yaml to declare where a spec sits and what higher/lower artifacts it traces to.
*.behavior.yaml defines single-script behavior only (inputs, outputs, stages, error paths for one script).BEHAVIOR_RUNTIME.md is for cross-script scenarios only (2+ scripts interacting)..behavior.yaml, not in BEHAVIOR_RUNTIME.md.intent describes WHY, not HOW — implementation details go in SKILL.md{
"schema_version": "2.0",
"id": "skill-system-behavior",
"version": "2.0.0",
"capabilities": ["spec-create", "spec-validate", "spec-verify", "contract-generate", "coverage-gate", "skill-graph-build"],
"effects": ["fs.read", "fs.write", "proc.exec"],
"operations": {
"create-spec": {
"description": "Scaffold a new SKILL.spec.yaml from the schema template.",
"input": {
"skill_name": { "type": "string", "required": true, "description": "Name of the skill to spec" },
"skill_dir": { "type": "string", "required": false, "description": "Target directory (default: skills/<skill_name>)" }
},
"output": {
"description": "Path to created SKILL.spec.yaml",
"fields": { "path": "string" }
},
"entrypoints": {
"agent": "Read schema/spec-v1.yaml, then scaffold SKILL.spec.yaml in skill_dir"
}
},
"validate-spec": {
"description": "Validate a SKILL.spec.yaml against the v1 schema.",
"input": {
"spec_path": { "type": "string", "required": true, "description": "Path to SKILL.spec.yaml" }
},
"output": {
"description": "Validation result with pass/fail and violations list",
"fields": { "status": "string", "violations": "array" }
},
"entrypoints": {
"unix": ["python3", "scripts/validate_spec.py", "{spec_path}"],
"windows": ["python", "scripts/validate_spec.py", "{spec_path}"]
}
},
"verify-structural": {
"description": "Run structural acceptance tests against a built skill or general behavior spec.",
"input": {
"skill_dir": { "type": "string", "required": true, "description": "Path to skill directory or direct spec path" }
},
"output": {
"description": "Test results checklist",
"fields": { "status": "string", "results": "array" }
},
"entrypoints": {
"unix": ["python3", "scripts/verify_structural.py", "{skill_dir}"],
"windows": ["python", "scripts/verify_structural.py", "{skill_dir}"]
}
},
"generate-contract": {
"description": "Generate behavior contract Mermaid DAGs from completed skill or project specs.",
"input": {
"skill_dir": { "type": "string", "required": true, "description": "Path to skill directory or direct spec path" }
},
"output": {
"description": "Path to generated SKILL.behavior.yaml",
"fields": { "path": "string" }
},
"entrypoints": {
"unix": ["python3", "scripts/generate_contract.py", "{skill_dir}"],
"windows": ["python", "scripts/generate_contract.py", "{skill_dir}"]
}
},
"coverage-gate": {
"description": "Scan project for scripts/modules missing behavior specs.",
"input": {
"project_dir": { "type": "string", "required": true, "description": "Root directory to scan" },
"patterns": { "type": "string", "required": false, "description": "Comma-separated glob patterns (default: **/*.py,**/*.sh)" },
"exclude": { "type": "string", "required": false, "description": "Patterns to exclude (default: test_*,__pycache__,.*)" }
},
"output": {
"description": "Coverage report with covered/uncovered lists and percentage",
"fields": { "covered": "array", "uncovered": "array", "coverage_pct": "number" }
},
"entrypoints": {
"unix": ["python3", "scripts/coverage_gate.py", "{project_dir}"],
"windows": ["python", "scripts/coverage_gate.py", "{project_dir}"]
}
},
"build-graph": {
"description": "Build a project behavior graph from discovered spec files.",
"input": {
"skills_dir": { "type": "string", "required": false, "description": "Root directory to scan using config/spec_discovery.yaml patterns" },
"output_format": { "type": "string", "required": false, "description": "mermaid, json, or sql" }
},
"output": {
"description": "Graph output in the requested format",
"fields": { "graph": "string|json" }
},
"entrypoints": {
"unix": ["python3", "scripts/build_graph.py", "--skills-dir", "{skills_dir}", "--format", "{output_format}"]
}
},
"refresh-projections": {
"description": "Refresh behavior projection bundles from SKILL.spec.yaml files for behavior_* tables.",
"input": {
"skills_dir": { "type": "string", "required": false, "description": "Root directory to scan (default: ./skills)" },
"output_format": { "type": "string", "required": false, "description": "json or sql" }
},
"output": {
"description": "Projection bundle or SQL statements for behavior_* refresh",
"fields": { "bundle": "json|string" }
},
"entrypoints": {
"unix": ["python3", "scripts/refresh_behavior_projections.py", "--skills-dir", "{skills_dir}", "--format", "{output_format}"]
}
}
},
"stdout_contract": {
"last_line_json": true
}
}