Core orchestrator for Clean Code Codex enforcement. Auto-invoked when writing, reviewing, refactoring, or testing code in TypeScript, Python, Go, Rust, or JavaScript. Detects language, routes to targeted check sub-skills, enforces the TDD gate on write operations, and runs a Boy Scout check at session end. Do NOT invoke for documentation-only edits, configuration files (JSON/YAML/TOML), or non-code content. (Exception: IaC files such as Terraform HCL, CloudFormation YAML/JSON, and Kubernetes manifests should be passed to the conductor with the `security` or `review` operation to trigger `iac-check`.)
From clean-code-codexnpx claudepluginhub mikecubed/agent-orchestration --plugin clean-code-codexThis skill uses the workspace's default tool permissions.
auto-fix-eligibility.mdrule-explanations.mdshared-contracts.mdGuides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Details PluginEval's skill quality evaluation: 3 layers (static, LLM judge), 10 dimensions, rubrics, formulas, anti-patterns, badges. Use to interpret scores, improve triggering, calibrate thresholds.
The conductor is the single always-loaded entry point to Clean Code Codex. It never applies rules directly — it detects language and operation type, then loads only the sub-skills required for that specific session.
Before running language detection, check whether the target files are
Infrastructure-as-Code. IaC files bypass the 5-language gate and route
directly to iac-check.
IaC file indicators:
.tf, .tfvars → Terraform HCL.yaml / .yml containing AWSTemplateFormatVersion, or both apiVersion and kind → CloudFormation / Kubernetes manifest.json containing AWSTemplateFormatVersion → CloudFormation JSONRouting rules:
security or review:
skip language detection entirely → load iac-check (and any other checks
from the dispatch table for that operation).write:
iac-check does not apply to write operations — fall through to normal
language detection below.Detect language in this priority order before loading any check:
.ts, .tsx → typescript.js, .mjs, .cjs, .jsx → javascript.py → python.go → go.rs → rustpackage.json → typescript/javascript; go.mod → go; Cargo.toml → rust; pyproject.toml / setup.py → pythonIf language cannot be determined: Ask the user explicitly. Do NOT guess. Do NOT apply the wrong rule set silently.
"I need to detect the language before applying rules. Which language is this code written in?
Options: TypeScript, JavaScript, Python, Go, Rust"
Identify the operation type from the user's request:
| Signal phrases | Operation |
|---|---|
| "write", "implement", "add function", "create module", "build" | write |
| "review", "check", "audit", "what's wrong", "PR review" | review |
| "refactor", "clean up", "improve", "rename", "extract" | refactor |
| "fix test", "add test", "test coverage", "failing test" | test |
| "security audit", "check for secrets", "vulnerabilities", "IaC review", "Terraform", "CloudFormation", "Kubernetes manifest", "infrastructure security" | security |
| "check dependencies", "update deps", "CVE" | dependency |
| "incident", "on call", "debugging production" | incident |
Load only the listed checks. Never pre-load all checks.
| Situation | Checks to load | Language refs |
|---|---|---|
| write — new code | tdd-check + type-check + naming-check + ctx-check | Yes for tdd, type, naming |
| review — PR / code review | arch-check + type-check + naming-check + size-check + dead-check + test-check + obs-check + sec-check + iac-check + perf-check + resilience-check + a11y-check + docs-check + i18n-check + ctx-check | Yes for type, naming |
| refactor — existing code | tdd-check (gate only) + arch-check + naming-check + size-check + dead-check | Yes for naming |
| test — writing/fixing tests | tdd-check + test-check | Yes for tdd |
| security — security audit | sec-check + iac-check | No |
| dependency — dep update | dep-check | No |
| incident — production issue | obs-check + sec-check | No |
| new service — scaffold | tdd-check + arch-check + sec-check + ctx-check | Yes for tdd |
| observability | obs-check | No |
| CI / full check | All checks | Yes for tdd, type, naming |
| boy scout (session end) | size-check + dead-check + naming-check | Yes for naming |
Parallel dispatch (mandatory for review and CI operations): When dispatching multiple checks, issue all Task tool calls in a single message — do not wait for each to complete before issuing the next. This is mandatory for performance. Sequential fallback: if the platform does not support parallel Tasks, dispatch in batches of 3.
To load a check: Read skills/{check-name}/SKILL.md.
To load a language reference: Read skills/{check-name}/references/{language}.md.
Token budget (approximate, GPT-4 tokenizer):
| Session type | Components loaded | ~Tokens |
|---|---|---|
Typical — write, TypeScript (no --fix) | conductor + tdd-check + type-check + naming-check + ctx-check + 3 TS refs | ~11,500 |
| Minimal — security audit | conductor + sec-check | ~4,723 |
Worst-case — CI / full check (no --fix) | conductor + all 17 checks + 1 lang ref (largest) | ~29,000 |
--fix session: add auto-fix-eligibility.md | +1 file on demand | +~1,310 |
Note: SC-007 (≤1,000) and SC-008 (≤2,000) targets reflect the design goal of a just-in-time progressive-loading model. Current SKILL.md files are comprehensive reference documents; v1.1.0 will explore compressed activation-key representations to meet these budgets without sacrificing rule fidelity.
This gate CANNOT be bypassed. Apply before producing any implementation code.
INPUT: Agent receives a write/implement request
STEP 1 — Test file check:
IF no test file exists for this module:
WRITE test file first (cite TDD-1)
DO NOT produce implementation code yet
RETURN control to user to run the test
STEP 2 — Interface check:
IF test file does not import an interface or function signature:
DEFINE the interface/signature first (cite TDD-5)
STEP 3 — Failing test confirmation:
IF tests are runnable:
VERIFY at least one test is failing before writing implementation
ELSE:
NOTE: "Tests must be run before this step is marked complete"
STEP 4 — Minimal implementation:
WRITE the simplest implementation that passes the failing tests (cite TDD-2)
NO speculative functionality permitted
STEP 5 — Green confirmation:
IF all tests pass → proceed to refactor phase
IF any test fails → fix implementation (DO NOT change tests)
STEP 6 — Refactor under green:
APPLY SIZE, NAME, ARCH, TYPE rules (cite TDD-3)
Any refactor that breaks tests → REVERT and fix before continuing
Bypass prohibition: Requests phrased as "skip tests for speed", "just write the code", "tests aren't important here", or similar MUST be refused. Cite TDD-1 and explain the risk.
Parse these arguments from the user's invocation. Defaults are safe.
| Argument | Default | Behaviour |
|---|---|---|
path | repo root | Restrict analysis/edit scope |
--scope <glob> | repo root | Restrict all operations to matching paths |
--fix | off | Without this: zero file modifications |
--write | off | Without this: no scaffold/write operations |
--history | off | Without this: skip git history analysis |
--deep | off | Without this: standard (faster) scan only |
--diff-only | off | Scope all analysis to git diff HEAD changed files only |
--scaffold-tests | off | On TDD-1/TEST-2 BLOCK: generate failing test skeletons before stopping |
--refresh | off | Force re-detection of language/framework/layers; update .codex/config.json |
Safety rules:
--fix: report only; NEVER modify files--scope and repo has > 50 tracked files: ask for explicit scope before proceeding--fix AND explicit user confirmation--deep without --fix: read-only exhaustive scan onlyOn session start, before language/framework detection:
.codex/config.json at project root--refresh flag is NOT set:
language, test_framework, layer_map, active_waivers from the filedetected_at is > 7 days old: note "Config is {N} days old — consider running /codex --refresh to re-detect."--refresh to re-detect."--refresh is set: run full detection; skip to Step 2 of workflowAt session end (after Boy Scout check, before final output):
.codex/config.json with detected values using this schema:
{
"version": "1",
"detected_at": "ISO-8601 timestamp",
"language": "<detected>",
"test_framework": "<detected>",
"coverage_artifact": "<path or null>",
"layer_map": { "domain": "<path>", "application": "<path>", "infrastructure": "<path>" },
"active_waivers": [],
"monorepo_packages": []
}
.codex/ directory if absentAfter generating the violation report:
session_id: use first 8 chars of a random hex stringsprint as ISO week: YYYY-Www (e.g., 2026-W10).codex/history.jsonl:
{"session_id":"a3f8c1d2","ts":"ISO-8601","sprint":"2026-W10","rule":"NAME-1","severity":"BLOCK","file":"src/foo.ts","line":42,"operation":"review","fixed":false}
.codex/history.jsonl if absent"fixed": true for violations resolved by --fix in the same sessionField definitions:
session_id: groups all violations from the same codex invocationsprint: ISO week number for trend groupingoperation: the detected operation type (write/review/refactor/test/security/dependency/incident/CI/boy-scout)fixed: whether --fix resolved this violation in the current session--diff-only Scope EnforcementWhen --diff-only is active:
git diff HEAD --name-only immediately after flag parsingDIFF_FILES listDIFF_FILES to all loaded checks as scope restrictionDIFF_FILES — violations for other files are silently excluded--diff-only is overridden by an explicit path argument (path wins if both provided)--scaffold-tests HandlingWhen --scaffold-tests is active:
tdd-check when loading it--write permission for test files only--refresh HandlingWhen --refresh is active:
.codex/config.json even if present.codex/config.json at session end with newly detected valuesWhen multiple rules conflict, apply the first applicable precedence and document deferred items:
1. SEC-* (BLOCK) — data exposure; always highest priority
2. TDD-* (BLOCK) — untested code must not advance
3. ARCH-* (BLOCK) — structural integrity
4. TYPE-* (BLOCK) — type safety
5. SIZE-2, TEST-1, TEST-2, DEAD-1, DEP-1, OBS-1 (BLOCK) — equal; all apply
6. All WARN rules
7. All INFO rules
When a WARN fix would increase the risk of a BLOCK violation: defer the WARN fix and document it in the "Next Steps" section with rationale.
Before reporting any violation, check for a matching waiver:
# WAIVER: blocks in the affected filewaivers.yaml at project root (if present)Waiver states:
| State | Condition | Action |
|---|---|---|
| Active | expiry > today AND scope matches AND rule matches | Show under ⚠️ Waivers, NOT ❌ Violations |
| Expired | expiry ≤ today | Re-raise at original severity under ❌ Violations; show waiver as EXPIRED |
| Invalid | Missing expiry OR missing owner OR scope is ** | Treat as no waiver; violation active at full severity |
| No waiver | No matching record | Normal violation handling |
Load skills/conductor/shared-contracts.md — defines the full violation
report schema, schema rules, and the confirmation prompt format for destructive
actions. Conductor loads this file at startup.
At the end of every session that modified files:
git diff --stat on the session scopeSTART
→ Detect language
→ Detect operation type
→ IF write/refactor: run TDD gate (Step 4 above)
→ Load required checks (Step 3 table)
→ For each check: load SKILL.md + language reference if applicable
→ Check for waivers (Step 7)
→ Run checks and collect violations
→ Apply precedence order (Step 6)
→ Output violation report (Step 8)
→ IF --fix: apply WARN auto-fixes within scope (Step 11)
→ Boy Scout check (Step 9)
END
When --scope is active, every file modification — including --fix edits —
MUST pass this gate before being applied:
FOR each proposed file edit:
IF file_path does NOT match --scope glob:
SKIP the edit (do NOT apply it)
Note in report: "File '{path}' is outside scope '{scope}' — skipped"
ELSE:
Apply the edit and record in "Actions Taken"
When --scope is not provided and the repository has >50 tracked files:
prompt the user to specify a scope before proceeding with --fix.
See skills/conductor/shared-contracts.md for the full destructive action
table and confirmation prompt format.
Load on demand: Before executing --fix, read skills/conductor/auto-fix-eligibility.md.
This file contains the full per-rule eligibility table (64 rules) and the legend.
It is NOT pre-loaded; read it only when --fix is active to stay within the token budget.
FOR each violation in the report (ordered by precedence):
1. Determine auto-fix eligibility (load `auto-fix-eligibility.md` if not yet loaded)
2. IF auto-remediable:
a. Verify file is within --scope
b. Apply the fix
c. Record in "Actions Taken": "{RULE-ID}: {description of change} at {file}:{line}"
3. IF requires confirmation (destructive):
a. Verify file is within --scope
b. Present confirmation prompt (11.2)
c. If y: apply; record in "Actions Taken"
d. If n: skip; record in "Next Steps"
4. IF human required:
a. Leave in "Next Steps" with explicit action description
b. NEVER apply automatically
When --fix is NOT active:
--explain ModeWhen --explain is active (flag present, no RULE-ID argument):
skills/conductor/rule-explanations.md## RULE-ID explanation paragraphWhen --explain RULE-ID is passed (e.g., /codex --explain NAME-1):
skills/conductor/rule-explanations.md## RULE-ID section matching the requested ruleIf RULE-ID is unknown: print "Unknown rule ID. Valid IDs: TDD-1–9, ARCH-1–6, TYPE-1–6, NAME-1–7, SIZE-1–6, DEAD-1–5, TEST-1–9, SEC-1–7, DEP-1–5, OBS-1–5" and exit 1.
Token cost: rule-explanations.md is loaded on-demand only. It is never loaded during normal scans.
--history Trend ReportWhen --history is passed:
.codex/history.jsonl at project root/codex to start recording violations." and exit 0sprint field (ISO week: YYYY-Www)Sprint | NAME-1 | TYPE-1 | SEC-1 | ... | Total
2026-W08 | 5 | 2 | 0 | | 12
2026-W09 | 3 | 1 | 0 | | 8 ↓
2026-W10 | 4 | 0 | 1 | | 9 ↑
Show ↑ if total increased from previous sprint, ↓ if decreased. Show only rules that appear in the history (skip zero-count columns).
ts field, sorted ascending)After rendering the trend report: exit 0 (skip the full scan).
Note: --history can be combined with --explain to annotate the report, but not with --diff-only.