ai-craftsman-superpowers
AGENTS.md35 starsChanged 52 days agoApache-2.0View on GitHub
Codex plugin that transforms Codex into a disciplined Senior Software Craftsman. DDD, Clean Architecture, TDD methodology enforced through hooks, commands, agents, and a rules engine. Current version: 4.10.3 Stack: Bash (hooks/CI), Markdown (skills/agents/templates), Python (metrics helpers), YAML (config) - All hook scripts MUST use exit 0 (pass) or exit 2 (block). NEVER exit 1. - Hook command output MUST be valid JSON (jq -n pattern). - Semantic verification runs in headless Haiku subprocesses via hooks/lib/haiku-verify.sh (never native agent/prompt hook types:…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository23 other files it gives its agents.
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
All hook scripts MUST use exit 0 (pass) or exit 2 (block).
- Very specific: line 53
All commands MUST have description, effort in frontmatter.
- Very specific: line 144
Run scripts/bump-version.sh <version>: it updates the four tracked files and exits non-zero on any that drifted.
- Distinctive: line 147
When bumping version, update ALL of these:
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Craftsman Superpowers - Project Instructions
Project Overview
Codex plugin that transforms Codex into a disciplined Senior Software Craftsman. DDD, Clean Architecture, TDD methodology enforced through hooks, commands, agents, and a rules engine.
Current version: 4.10.3 Stack: Bash (hooks/CI), Markdown (skills/agents/templates), Python (metrics helpers), YAML (config)
Development Rules
- All hook scripts MUST use
exit 0(pass) orexit 2(block). NEVERexit 1. - Hook command output MUST be valid JSON (
jq -npattern). - Semantic verification runs in headless Haiku subprocesses via
hooks/lib/haiku-verify.sh(never native agent/prompt hook types: no option gating, see ADR-0018). Always guard withCRAFTSMAN_HEADLESS_VERIFY. - The
metrics-query.pyhelper MUST be used for all SQLite writes (parameterized queries). NEVER use string interpolation in SQL. - Session state is one file PER SESSION,
session-state-<id>.json, resolved byhooks/lib/session-files.shfromCLAUDE_CODE_SESSION_ID(set by Codex in hook and Bash tool subprocesses alike; the sharedsession-state.jsonis the fallback with no id). Never hardcode the shared path: one shared file let a session's end delete another's pending findings and one project's patterns surface in another. All writes MUST use atomic writes (tempfile.mkstemp() + os.rename()). Known TOCTOU window between read and rename when multiple async hooks fire simultaneously - acceptable at current hook frequencies but do not add file-locking without benchmarking first. - CI adapters follow the
adapter_detect/run/annotate/comment/exitinterface. - The engine holds no list of languages. A pack declares its own in
pack.ymlunderlanguages:(extensions,validators,static_analysis,test_commands,entry_markers,protected_configs,lsp,metrics_dialect,supersedes), andhooks/lib/lang-registry.shcompiles those manifests into the registry every hook andci/craftsman-ci.shreads. Never add acase "$EXT"or an extension literal to a hook, to the pipeline or to a Python helper: uselang_for_file,lang_capabilityorpack_dispatch_file.tests/core/test-lang-registry.shfails when a capability is declared but no consumer reads it.metrics_dialectacceptsc-likeandphp-likeonly; a language whose structure the engine cannot extract declares none rather than a dialect that would measure it wrongly. supersedes:declares which Level 1 rules a Level 2/3 analyser owns, one<tool>=<RULE>,<RULE>entry per line (vendor/bin/deptrac=LAYER001,LAYER002). A claimed rule is DEFERRED, never dropped:hooks/lib/precedence.shholds the Level 1 finding, the analyser emits directly and declares the codes it answered for (precedence_declare_covered), andprecedence_flushre-emits everything left over with full severity resolution. No verdict is not a clean verdict, so a timeout, a crash or an analyser configured to ignore the rule all end with the regex reporting.lang_registry.pyrefuses at compile time any entry where a tool would outrank its own verdicts.tests/core/test-precedence.shcovers both directions.- Severity is the rules engine's decision, never the validator's. Emit through
add_violationoradd_warning(both resolverules_severity_for_file), and declare a rule's advisory default ONCE, asdefault_severity: warnin the manifest that owns it (rules/core.ymlor the pack'spack.yml). Neither the engine norci/craftsman-ci.shholds a list of advisory rules;tests/ci/test-craftsman-ci.shfails when one comes back, and checks that every declared default reaches both front-ends. - A plugin option reaches a hook as
CLAUDE_PLUGIN_OPTION_<KEY>with the key UPPERCASED (agent_hooksbecomesCLAUDE_PLUGIN_OPTION_AGENT_HOOKS). Read it throughconfig_getor in the dual form"${CLAUDE_PLUGIN_OPTION_AGENT_HOOKS:-${CLAUDE_PLUGIN_OPTION_agent_hooks:-true}}", exported spelling first; a test that sets only the lowercase form proves nothing about the consumer, which is howagent_hooks: falsedid nothing for four releases. - All commands MUST have
description,effortin frontmatter.effortis Codex's own frontmatter key, not project metadata: it overrides the session effort level, so onlylow,medium,high,xhigh,maxare valid. - Templates MUST have: top-level heading,
## Missionsection,## Context Filessection. - An agent that declares
maxTurnsMUST carry a## Turn Budgetsection ending on "never let your final action be a tool call". When the cap lands on a tool call the agent loop stops there and returns no text, and a forked skill in that state surfaces as the bare stringCommand completedwith no error: 23 ofcraftsman:architect's first 38 runs ended that way. A read-only agent (noWrite/Editintools:) MUST NOT declareisolation: worktree, because a worktree is a clean checkout and the uncommitted diff it was asked to review is absent from it.context: forkis refused into any agent without the delivery contract, and never belongs on a skill that delivers a verdict to the user (ADR-0028): a fork carries neither the conversation nor the user's attachments.tests/core/test-turn-budget.shenforces all three, with fixtures that prove each check can fail. - A skill with
disable-model-invocation: truestarts ONLY when the user types/craftsman:<name>first in a prompt; the Skill tool refuses it. So: an agent'sskills:frontmatter may list only model-invocable skills and never one whoseagent:binding points back at that agent; a skill body may write**Invokes:** /craftsman:xonly whenxis model-invocable, otherwise**Hands off to:**plus the command to paste.tests/core/test-invocation-policy.shenforces both.
Testing
# Run full test suite
bash tests/run-tests.sh
# Run hook tests only
bash tests/core/test-hooks.sh
# Run template validation only
bash tests/templates/test-templates.shKey Differentiators (Marketing)
These are the 6 genuine features that differentiate AI Craftsman Superpowers:
1. Correction Learning System
Records every violation fix users make, injects correction trends at next session start, and promotes recurring fixes into human-reviewed learned skills. SQLite-backed feedback loop that progressively teaches Codex the exact patterns your codebase rejects. Cross-file pattern detection suggests project-wide fixes when 3+ files share the same violation. Differentiator: the learning loop is coupled to the rules engine, so what is learned comes from violations that same engine enforces in hooks and in CI, not from a separate model of what good code looks like.
2. Rules Engine with 3-Level Inheritance
Enterprise-ready rule customization: Global → Project → Directory overrides. Short form (PHP001: warn) and long form (custom rules with regex, message, severity, languages, paths). Legacy code coexists with strict new code via directory-level relaxation. Python-backed YAML parser with bash 3.2 shell compatibility.
3. Cognitive Bias Detector
Real-time detection of acceleration bias, scope creep, and over-optimization in user prompts. Context-aware bilingual FR/EN pattern matching on UserPromptSubmit hook - requires imperative verb context to reduce false positives. Non-blocking warnings that encourage reflection before action.
4. Real-Time Quality Gate
3-level progressive validation on every Write/Edit:
- Level 1: Regex - strict_types, final, any, setters. Always active. The cost
is measured, not asserted:
bash tests/perf/test-hook-latency.sh --reportprints the median per hook, and the suite fails when a hook crosses its ceiling. The "<50ms" that stood here for four releases was 15 to 60 times under what the hooks actually take, on the smallest input there is. - Level 2: Static analysis - PHPStan, ESLint. When tools installed and trusted, under a budget of 15s per file and 30s per project.
- Level 3: Architecture - deptrac, dependency-cruiser. Same budget. Graceful degradation: works with zero tools installed (Level 1 only).
5. Multi-Provider CI Pipeline
CI sources the same pack validators and the same rules engine as the hooks, and resolves severity per file so directory-level .craft-rules.yml applies in both. tests/ci/test-craftsman-ci.sh fails when the two disagree. 4 provider templates, all with native annotations: GitHub Actions (inline annotations and a PR comment), GitLab CI (code-quality report and an MR note), Bitbucket Pipelines (build report), Jenkins (a Checkstyle report that Warnings Next Generation attaches to the file and line). The generic adapter remains the fallback for anything else. Adapter pattern: detect → run → annotate → comment → exit.
6. Metrics & Trend Analysis
SQLite-backed tracking of violations, corrections, and sessions. 7-day and 30-day trend views. Data-driven quality improvement: identify most-violated rules and adjust strictness. Currently per-machine - team metrics sync planned for v3.
Architecture
hooks/ → Real-time validation (SessionStart → PostToolUse → Stop → SessionEnd)
hooks/lib/ → Shared libraries (pack-loader, config, rules-engine, metrics, static-analysis)
skills/ → Core workflows as skills/<name>/SKILL.md (ADR-0017); pack workflows symlinked in at runtime
agents/ → Core agents (6) + 6 shipped pack copies (checked by scripts/native-manifests.py)
knowledge/ → Core methodology, language-agnostic (Clean Architecture, Hexagonal, DDD, TDD, testing strategy, Clean Code, Refactoring, legacy techniques, Design Patterns, principles, anti-patterns)
knowledge/ddd/ → Agnostic DDD tactical/CQRS (Symfony specifics live in packs/symfony/knowledge/ddd-symfony-implementation.md)
knowledge/legacy/, knowledge/refactoring/ → Legacy rescue and refactoring campaign methodology
packs/ → Loadable language packs (7 packs)
symfony/ → PHP/Symfony pack (validators, agents, knowledge, templates)
react/ → React/TypeScript pack (validators, agents, knowledge, templates)
python/ → Python pack (validators, knowledge, anti-patterns)
go/ → Go pack (validators, Go structure scanner, canonical example)
rust/ → Rust pack (validators, Rust structure scanner, clippy at Level 2)
bash/ → Bash/Shell pack (validators, knowledge, anti-patterns)
ai-ml/ → AI/ML pack (agents, knowledge, commands)
ci/ → CI pipeline integration; ci/adapters/ = CI providers
adapters/ → host agent runtimes (a different axis from ci/adapters/)
hermes/ → Nous Research Hermes: pre_verify hook, Codex wrapperThree front-ends over one core: hooks/ for Codex, ci/craftsman-ci.sh
for pipelines, adapters/<host>/ for other agent runtimes. The rules engine,
the packs and knowledge/ are shared, and the parity tests fail when two
front-ends disagree on a severity. A fourth front-end is an adapter, never a
fork.
Version Sync Checklist
Run scripts/bump-version.sh <version>: it updates the four tracked files and
exits non-zero on any that drifted. It does not write the changelog or the tag.
When bumping version, update ALL of these:
.Codex-plugin/plugin.json→version.Codex-plugin/marketplace.json→ rootversion+ pluginversionci/craftsman-ci.sh→VERSION=AGENTS.md→**Current version:**(this file; the checklist used to omit itself, so 4.6.2 shipped with 4.6.1 written here and only the bump script caught it)CHANGELOG.md→ new entryREADME.md→ Version badgeREADME.fr.md→ Version badge + sync any README.md content changes (French mirror, English is the source of truth)
Then tag with Codex plugin tag --push, which produces the
craftsman--v<version> tag that plugin dependency resolution reads. A plain
v<version> tag is kept alongside it for release continuity.
Pushing the v<version> tag runs .github/workflows/release.yml, which
orchestrates two scripts and nothing else. scripts/release-guard.sh <tag>
refuses a tag that is not v<x.y.z>, a tag the four tracked files disagree
with (through scripts/bump-version.sh --check, so there is one list of those
files and not two), and a craftsman--v<version> tag on another commit; the
marketplace tag is waited for, never skipped. scripts/release-build.sh builds
craftsman-<version>.tar.gz reproducibly (gzip -n) with its SHA256SUMS.txt.
The workflow then attests, publishes, and re-runs the exact gh attestation
verify --signer-workflow command SECURITY.md documents.
Both scripts run outside GitHub, which is what lets tests/meta/test-release.sh
test the release path without pushing a tag. Two rules hold that job honest:
every value reaches a shell block through env:, never through ${{ }}, and
there is no workflow_dispatch (it can be aimed at any ref, so it would let
any writer sign arbitrary content). The remaining exposure is stated in
SECURITY.md rather than papered over: a tag push runs the workflow file from
that tag's own tree, so the real control is the release environment's
required reviewers, a repository setting.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

