Codex SPECTRE Implementation
Trigger: codex, spectre, codex install, sessionstart, agents.override, registry, spectre-learn, spectre-recall, hooks.json, config.toml, doctor Confidence: high Created: 2026-03-30 Updated: 2026-07-19 Version: 5
Current Design
Codex SPECTRE installs the workflow as Codex-native skills, subagent TOML configs, and generated SessionStart hooks. Project knowledge and session continuity are written into managed AGENTS.override.md blocks so hook output stays short.
Reusable project knowledge is both configured as normal skills and injected as a compact trigger registry:
spectre-learnwrites project skills under.agents/skills/{category}-{slug}/SKILL.md.- The recall registry lives at
.agents/skills/spectre-recall/references/registry.toon. spectre-recallis generated as an explicit search/load skill.- Project installs sync
.agents/skills/*/SKILL.mdinto Codex[[skills.config]]. spectre-applycontains a{{REGISTRY}}placeholder that both the hook andsrc/lib/knowledge.jssubstitute before writing the managed knowledge block.bootstrap→handoff-resume→load-knowledgeis the required SessionStart order.
Workflow task execution now uses a two-artifact contract:
spectre-create_taskswrites{OUT_DIR}/specs/execute.mdplus{OUT_DIR}/specs/tasks.json.execute.mdis the compact primary-agent index (document manifest, task detail source, execution summary, wave plan, parent-task index, slicing rules).tasks.jsonis the full mutable detail/status source (meta+phases[]); primary execution/review/validation consumers should slice it by parent task id instead of reading the whole file.- Do not reintroduce the old
specs/tasks.mdtask-list flow or a Markdown fallback/converter.
Review gates use one cross-runtime contract:
spectre-plan_reviewprefers the opposing CLI with an explicit high-effort model: Codex launches Claude Code with--model opus --effort high; Claude Code launches Codex with-m gpt-5.6-sol -c 'model_reasoning_effort="high"'. The launcher allows each attempt up to 20 minutes, but passes no duration guidance to the reviewer.spectre-task_reviewuses a focused medium-effort opposing-runtime contract: Codex launches Claude Code using--model opus --effort medium; Claude Code launches Codex using-m gpt-5.6-sol -c 'model_reasoning_effort="medium"'. The primary agent runs consumer-safety preflight, explicitly launches and monitors the reviewer for up to 20 minutes, validates the report, allows one repair, owns native fallback and write-back, and passes no duration guidance to the reviewer.spectre-code_reviewuses a high-effort opposing-runtime contract: Codex launches Claude Code using--model opus --effort high; Claude Code launches Codex using-m gpt-5.6-sol -c 'model_reasoning_effort="high"'.- If the opposing runtime is unavailable or fails validation after one repair attempt, the gate dispatches one native reviewer with the same manifest, adversarial lenses, severity/evidence rules, exclusions, and report schema. This fallback does not block completion and must record its reason plus runtime/model metadata.
spectre-code_reviewis an adversarial, evidence-gated review for correctness, regressions/integration, security, performance/reliability, overengineering, and test adequacy. It does not use subjective numeric scores.spectre-executedelegates its final cumulative review tospectre-code_review --orchestrated; do not reintroduce a separate final-review prompt inside execute.- Canonical workflow skills live under
plugins/spectre/skills/; regenerateplugins/spectre-codex/and keep regression assertions inscripts/test_sync-codex.cjsaligned with these invariants.
Install Flow
src/main.jsparsesinstall codex, resolves scope, and switchesCODEX_HOMEto./.codexfor project installs.installCodex()insrc/lib/install.jscopies generated Codex assets fromplugins/spectre-codex/:- workflow skills into
CODEX_HOME/skills/ - agent TOML configs into
CODEX_HOME/spectre/agents/ - generated hooks into
CODEX_HOME/spectre/hooks/ - runtime helper scripts into
CODEX_HOME/spectre/tools/
- workflow skills into
installCodex()removes the fork-era sibling runtime and agent tables before writing current[agents.spectre_*]definitions.ensureSpectreHooksConfigured()enablesfeatures.hooks,features.skills, andfeatures.multi_agent, then materializes generated SessionStart commands intoCODEX_HOME/hooks.jsonwithout clobbering unrelated handlers.- For project installs,
installProjectFiles()creates.spectre/manifest.json, initializes recall files, clears stale managed blocks, and callssyncProjectSkillsConfigured(). - On SessionStart, the hooks refresh session and knowledge blocks only when the workspace has the relevant Spectre surface.
Key Files
plugins/spectre/skills/Canonical Claude/Codex-compatible workflow skill sources.plugins/spectre-codex/Generated Codex bundle. Regenerate withnpm run sync-codex -- --quiet.src/lib/install.jsMain installer/uninstaller.src/lib/config.jsOwnsconfig.toml,hooks.json, agent tables, and project skill sync.src/lib/project.jsOwns.spectre/manifest.json, handoff lookup, managed override blocks, and legacy cleanup.src/lib/knowledge.jsOwns recall generation and Codex-side{{REGISTRY}}substitution.src/lib/doctor.jsVerifies installed runtime/config state and reports stale hook remnants.
Common Tasks
Add or change a workflow skill
- Edit
plugins/spectre/skills/spectre-*/SKILL.md. - Run:
npm run sync-codex -- --quiet npm run sync-codex -- --check --quiet - Run focused tests when installer or translator behavior changed:
node --test src/install.test.js src/config.test.js scripts/test_sync-codex.cjs - If changing
spectre-create_taskstask artifacts, also validate both task fixtures parse:node -e "JSON.parse(require('fs').readFileSync('plugins/spectre/skills/spectre-create_tasks/references/tasks.example.json','utf8'))"
Add a learned project skill and make sure Codex sees it
- Write the skill under
.agents/skills/{category}-{slug}/SKILL.md. - Register it in
.agents/skills/spectre-recall/references/registry.toon. - Regenerate
.agents/skills/spectre-recall/SKILL.md. - Refresh project install state:
npx @codename_inc/spectre update codex --scope project --project-dir "$PWD"
Debug why a project skill is not being used
Check, in order:
- The skill exists at
.agents/skills/{name}/SKILL.md. - Its frontmatter description contains concrete trigger language.
config.tomlcontains a[[skills.config]]entry for the skill path.- If explicit search is needed, the registry entry exists in
.agents/skills/spectre-recall/references/registry.toon. hooks.jsoncontains SessionStart commands forbootstrap.mjs,handoff-resume.mjs, andload-knowledge.mjs.AGENTS.override.mdcontains an inlined registry and no raw{{REGISTRY}}.- Run:
npx @codename_inc/spectre doctor codex --scope project
Expected Install Artifacts
After npx @codename_inc/spectre install codex --scope project, expect files like:
.codex/config.toml
.codex/hooks.json
.codex/skills/spectre-apply/SKILL.md
.codex/skills/spectre-scope/SKILL.md
.codex/spectre/hooks/hooks.json
.codex/spectre/hooks/scripts/bootstrap.mjs
.codex/spectre/hooks/scripts/handoff-resume.mjs
.codex/spectre/hooks/scripts/load-knowledge.mjs
.codex/spectre/hooks/scripts/register_learning.mjs
.codex/spectre/agents/dev.toml
.spectre/manifest.json
.agents/skills/spectre-recall/SKILL.md
.agents/skills/spectre-recall/references/registry.toon
Do not reintroduce:
spectre-guidespectre-evaluatespectre-architecture_review- fork-name CLI aliases or duplicate runtime trees
- raw
{{REGISTRY}}in generated or installed context - startup payloads in
additionalContext; use managedAGENTS.override.mdblocks