From harness-thrift-codex
Codex CLI port of /thrift — cost-conscious long-session optimisation. TOML hooks in ~/.codex/config.toml, OpenAI cost table, session-priming variant of Phase 4. Same six-phase pipeline as harness-thrift (CC); see plugins/harness-thrift/skills/thrift/SKILL.md for source-of-truth.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-thrift-codex:thrift-codexThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Bootstraps cost-conscious patterns in the current project on Codex CLI.
lib/config-loader.mjslib/cost-estimator.mjslib/settings-patcher.mjsphases/0-preflight.mdphases/1-config.mdphases/2-instrument.mdphases/3-summariser.mdphases/4-cache-prime.mdphases/5-audit.mdreferences/porting-notes.mdtemplates/audit-report.md.hbstemplates/hooks/thrift-posttool-summariser-trigger.toml.hbstemplates/hooks/thrift-pretool-bash-telemetry.toml.hbstemplates/hooks/thrift-pretool-read-coerce.toml.hbstemplates/hooks/thrift-sessionend-audit.toml.hbstemplates/hooks/thrift-sessionstart-cache-prime.toml.hbstemplates/thrift.config.json.hbsBootstraps cost-conscious patterns in the current project on Codex CLI.
Reads .thrift.json (or seeds it), patches ~/.codex/config.toml's
[hooks] block append-only, and arms session_start cache-prime +
post_tool_use summariser-trigger flows.
/thrift-codex # one-time setup; idempotent
/thrift-codex summarise # manual summariser trigger
/thrift-codex audit # write audit report now
/thrift-codex --force # re-seed .thrift.json
--force — overwrite existing .thrift.json.--no-instrument — skip the ~/.codex/config.toml patch (just seed config).--dry-run — print what would be patched; don't write.| Phase | File | Purpose |
|---|---|---|
| 0 | phases/0-preflight.md | detect context-mode-codex + Codex version + existing [hooks] block |
| 1 | phases/1-config.md | seed/load .thrift.json + compute thresholds |
| 2 | phases/2-instrument.md | patch ~/.codex/config.toml (append-only, sentinel-line revert) |
| 3 | phases/3-summariser.md | summarise current window (stderr-advisory on Codex) |
| 4 | phases/4-cache-prime.md | session-priming via exec_command (best-effort on OpenAI cache) |
| 5 | phases/5-audit.md | write end-of-session audit report |
~/.codex/config.toml. New entries are bracketed by sentinel
comment lines: # thrift: thrift-<name> (start) and # end thrift: thrift-<name> (end). Revert deletes only blocks between matching
sentinels..thrift.json cache.enabled = true./compact in the Codex TUI via stderr (Codex has no
Notification hook equivalent)..thrift-state.json rather than relying solely on session_end hook.| Action | Codex primitive |
|---|---|
| Read file | implicit (model reads directly) |
| Write file | apply_patch |
| Shell (one-shot) | shell_command |
| Shell (cache prime / session reuse) | exec_command |
| Hook registration | [hooks] block in ~/.codex/config.toml |
| Notification | stderr from a post_tool_use hook + write to ~/.codex/notifications/ |
| Prompt user | ask_user |
lib/config-loader.mjs — loadConfig(path) → {ok, config | errors, warning?}.lib/cost-estimator.mjs — estimate({tokensInUncached, tokensInCached, tokensOut, model}) → {actualUSD, baselineUSD, savedRatio}. OpenAI rate table.lib/settings-patcher.mjs — patchCodexConfig({configPath, hooksToAdd, dryRun}) → diff applied. Minimal TOML-aware append/remove..thrift.json invalid → abort with field-level errors.skipped. Re-runs are idempotent.~/.codex/config.toml not readable → abort with the OS error.
The patcher refuses to create the file from scratch (user must run
codex once first to seed it)..thrift-state.json; user can retry
via /thrift-codex summarise.Print:
Thrift audit (Codex): <duration> session, <turns> turns, $<actual> actual vs $<baseline> baseline (saved <%>).
Report: <output-path>
references/porting-notes.md — Codex-specific decisions + open questionsplugins/harness-thrift/skills/thrift/SKILL.md — CC source-of-truth pipelinedocs/superpowers/specs/2026-05-18-harness-thrift-per-platform-decomposition.md — porting decompositionCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub kim-song-jun/agent-skill --plugin harness-thrift-codex