/craftsman:ci - CI/CD Integration
Outcome Contract
- Outcome: a CI pipeline that enforces the same rules as the local hooks, from the same validators, the same rules engine and the same per-file severity resolution.
- Done when: the generated pipeline file exists for the target provider, references the same pack validators as the hooks, and a dry run reports the same violations locally and in CI.
- Evidence: craftsman-ci.sh output, the generated template, and the provider adapter used.
Integrate Craftsman quality gates into your CI/CD pipeline.
Subcommands
/craftsman:ci export- Generate.github/workflows/craftsman-quality-gate.yml/craftsman:ci status- Show current CI integration status
Execution
If the user runs /craftsman:ci export:
- Read
.craft-config.ymlif it exists to pick upstrictnessandstacksettings. - Check for
composer.json(PHP),package.json(Node.js), anddeptrac.yamlto tailor the workflow. - Copy
ci/templates/craftsman-quality-gate.ymlinto.github/workflows/craftsman-quality-gate.yml.- If
.github/workflows/does not exist, create it. - If the file already exists, ask the user before overwriting.
- If
- Confirm the export with a summary:
Craftsman CI workflow exported to:
.github/workflows/craftsman-quality-gate.yml
Detected stack: <stack>
Config: <strictness> strictness
Next steps:
1. Commit and push: git add .github/workflows/craftsman-quality-gate.yml
2. Open a PR to trigger the workflow
3. Review docs/ci-integration.md for advanced configuration
If the user runs /craftsman:ci status:
Check the following and report:
Workflow file - Does
.github/workflows/craftsman-quality-gate.ymlexist?- If yes: show
strictnessandstackfrom the embedded config, and the file's last modified date. - If no: suggest running
/craftsman:ci export.
- If yes: show
craftsman-ci CLI - Does
ci/craftsman-ci.shexist and is it executable?Config file - Does
.craft-config.ymlexist?Stack detection - Are
composer.json/package.json/deptrac.yamlpresent?
Output a clear status table:
Craftsman CI Status
===================
Workflow file: ✓ .github/workflows/craftsman-quality-gate.yml
craftsman-ci: ✓ ci/craftsman-ci.sh (executable)
Config: ✓ .craft-config.yml (strictness=strict, stack=fullstack)
Stack detected: PHP (composer.json), Node.js (package.json)
Run /craftsman:ci export to generate the workflow if missing.
Constraints
- Never modify
hooks/,agents/, orpacks/- CI is an additive integration layer. - The exported workflow uses the same rules as the hooks; they must never diverge.
- If
ci/craftsman-ci.shis not present, warn the user - the workflow depends on it. - All shell commands use
|| truefor optional tools (PHPStan, ESLint, deptrac) so the workflow degrades gracefully.
Cross-Harness Doctrine Export
Teammates using Copilot, Cursor, Codex, Gemini, or Antigravity cannot run craftsman hooks, but they can read instruction files. Export the active rules as those files so the doctrine travels with the repository:
craftsman-ci export --target agents-md # AGENTS.md (read by most agents)
craftsman-ci export --target cursor # .cursor/rules/craftsman.mdc
craftsman-ci export --target copilot # .github/copilot-instructions.md
craftsman-ci export --target all
The rules engine remains the single source of truth: severity overrides and ignored rules in .craft-config.yml are reflected in the generated files, which carry a do-not-edit header and are regenerated (not hand-maintained). Enforcement is unchanged: hooks locally where craftsman runs, craftsman-ci in the pipeline for everyone else. Commit the generated files and re-run the export whenever the rules change.