Codexplain is a project-local explanation UX layer for Codex.
It does not replace Codex or depend on a specific GPT version. The goal is to make Codex answers easier to understand across model versions by adding a stable explanation contract, terminal-friendly rendering, and feedback-driven preference tuning.
- โก One-Line Setup
- ๐ One-Line Use
- โจ What It Improves
- ๐งฉ Adaptive UX Components
- ๐ง Model-Agnostic Goal
- ๐ RLHF-Lite
- ๐๏ธ CLI
- ๐ฆ Rust Core
- ๐พ Storage Safety
- ๐ Ouroboros Readiness
- ๐ Project Files
- โ Verification
Install from this repository and enable it in the current project:
npm install -g github:NomaDamas/Codexplain && codexplain install-codex --local --forceIf you are inside this repository while developing it:
npm run onAfter setup, Codex in that project receives AGENTS.md guidance for clearer
answers. Setup is project-local; it does not edit global Codex config.
Run Codex through Codexplain and locally shape the captured output:
codexplain-codex --local-shape --prompt "์ฝ๊ณ ์์ธํ๊ฒ TLDR์ ํ/ํ๋ฆ๋๋ก ์ค๋ช
ํด์ค" exec "์ด ํ๋ก์ ํธ ์ํคํ
์ฒ ์ค๋ช
ํด์ค"Set your preferred style:
codexplain profile --detail deep --set-style tutorial --theme ocean --frame unicodeControl explanation depth with 3-stage levels:
codexplain profile \
--explanation-depth deep \
--architecture-depth internals \
--abstraction-level architecture \
--layers tldr,summary,architecture,implementation,evidence,next-stepThe 3-stage controls are intentionally non-numeric:
explanation-depth light | standard | deep
architecture-depth overview | system | internals
abstraction-level concrete | architecture | strategy
Numeric controls still exist for selector tuning, not explanation depth:
codexplain profile --ux-density 70 --risk-sensitivity 80Use --theme ocean, forest, or warm to make Codexplain terminal output
color-highlight important labels. Use --theme none when copy/paste-safe plain
text is more important than visual scanning.
Available color themes include:
none, ocean, forest, warm, sunset, grape, slate, rose, mono
If your shell sets NO_COLOR=1 but you want Codexplain color anyway, force it
for this project command:
CODEXPLAIN_COLOR=always codexplain shape --theme grape --prompt "๊ฐ์กฐํด์ ์ค๋ช
" --response "์๋ฃ PASS"Give feedback after an answer:
codexplain rlhf --rating 5 --comment "์ด ์ ๋ ๊น์ด์ ์ฌ์ด ๋ง์ด ์ข๋ค"Codexplain improves the explanation layer, not the underlying coding model.
Codex answer
โ
โผ
Codexplain policy
โ protects exact JSON, code, logs, diffs, patches
โผ
UX profile
โ detail, style, audience, color, frame, feedback reward
โผ
Rust shaper / renderer
โ TLDR, evidence, next action, table/flow layout
โผ
Readable terminal answer
The result should be:
- TLDR first when the output is explanatory.
- Korean-first when the user writes Korean.
- Short paragraphs instead of scattered process narration.
- Unicode box tables and diagrams when they help scanning.
- Row dividers in dense tables so long architecture lists are easier to track.
- Semantic color highlights for labels such as TLDR, ํต์ฌ, ์ฅ์ , ๋จ์ , ์ํ.
- Three-stage explanation depth: light, standard, deep.
- Three-stage architecture depth: overview, system, internals.
- Three-stage abstraction level: concrete, architecture, strategy.
- Adjustable detail layers: TLDR, summary, concept, mechanism, architecture, implementation, evidence, next-step.
- Dynamic renderer selection: TLDR prose, progress reports, table, flow, pros/cons panels, numbered index lists, formula boxes, and richer status UX components when they help scanning.
- Compositional renderer selection: when a prompt asks for architecture, tradeoffs, and formulas together, Codexplain can combine table/flow context, pros/cons comparison, and formula boxes instead of choosing only the first matching format.
- Pros/cons and tradeoff questions as comparison panels instead of loose bullets.
- Progress reports with a short status label above the bar, then a compact checkpoint table for current state, percentage, and next action.
- Tool-calling-like UX composition: status badges, checklists, risk panels, confidence meters, diff summary cards, decision matrices, ETA strips, attention callouts, and next-action footers are selected from prompt and response signals instead of always being shown.
- Three selector modes: rules for explicit requests, score thresholds for
implicit components, and optional planner hints through
CODEXPLAIN_UX_PLANorCODEXPLAIN_UX_PLANNER_COMMAND. - Formula boxes for decision rules or simple math explanations.
- Side-by-side table/flow panels only when terminal width allows it.
- Exact commands, file paths, risks, test evidence, and dates preserved.
Codexplain treats terminal UX blocks like a small renderer toolbox. It selects only the components that match the question, the answer state, 3-stage depth profile, optional selector controls, and the terminal width. A simple explanation can stay as TLDR prose; a work-status answer can add a badge, progress bar, checklist, risk panel, and next action; a decision answer can add pros/cons, formula, confidence, and a decision matrix.
Selector versions now available:
- V1 rules: explicit prompt signals such as
progress,risk,์์, or์ฅ๋จ์ map to known renderers. - V2 scores: implicit UX signals are scored against
uxDensityandriskSensitivity, while explanation depth itself uses the 3-stage controls. - V3 planner hints: set
CODEXPLAIN_UX_PLAN="risk-panel,next-action"orCODEXPLAIN_UX_PLANNER_COMMANDto let an external planner output component names; Rust still performs the final safe rendering.
Available visual components:
- Status badge: shows running, blocked, done, or review-needed state.
- Progress report: status text above a bar, followed by checkpoint details.
- Checklist: separates completed, current, and remaining work.
- Risk panel: calls out hidden assumptions, failures, drift, or blockers.
- Confidence meter: shows certainty as a labeled bar without relying on color.
- Diff summary card: summarizes what changed, impact, and verification.
- Decision matrix: compares options with score and rationale.
- ETA strip: gives elapsed/remaining-state language for progress answers.
- Attention callout: highlights important warnings or copy/paste-safe notes.
- Next-action footer: ends with the single most useful next step.
Example:
codexplain shape \
--ux-density 90 \
--risk-sensitivity 80 \
--prompt "์งํ์ํฉ์ ํ๋ถํ UX๋ก ๋ณด์ฌ์ค: risk, confidence, next action" \
--response "ํ์ฌ 4/5 ๋จ๊ณ ์งํ ์ค์
๋๋ค. ํ
์คํธ๋ ํต๊ณผํ๊ณ ๋ฆด๋ฆฌ์ฆ ๊ฒ์ฆ์ด ๋จ์์ต๋๋ค."Planner hint example:
CODEXPLAIN_UX_PLAN="status-badge,risk-panel,next-action" \
codexplain shape --prompt "์ํ ๋ณด๊ณ " --response "์คํจ: provider timeout"Codexplain is designed to work whether Codex is backed by a newer or older GPT model. The model may change; the UX contract stays stable.
GPT backend changes
โ
โผ
Codex coding behavior
โ
โผ
Codexplain explanation contract
โ
โผ
Consistent user-facing explanation style
This project does not train a full RLHF model. Full RLHF needs preference data, reward modeling, offline evaluation, and model fine-tuning.
Codexplain implements a practical project-local version:
User rates answer
โ
โผ
Signal extraction
โ too hard / too short / too long / needs examples
โผ
Preference reward profile
โ .codexplain/ux-profile.json
โผ
Next answer uses adjusted detail and style
The profile stores compact preference signals only. It does not store raw answer text.
codexplain demo
codexplain guide --prompt "ํ์ฌ ์ํ๋ฅผ ์ฝ๊ฒ ์ค๋ช
ํด์ค"
codexplain shape --prompt "ํ๋ฆ๋๋ก ์ค๋ช
ํด์ค" --response "๊ตฌํ์ ์๋ฃ๋์ต๋๋ค."
codexplain shape --prompt "Rust-only ์ ํ์ pros and cons ํ์ ์์์ผ๋ก ์ค๋ช
ํด์ค" --response "Rust๋ ๋จ์ผ ๋ฐ์ด๋๋ฆฌ์ ๋ฎ์ ๋ฐํ์ ์์กด์ฑ์ ์ ๋ฆฌํฉ๋๋ค."
codexplain post-response --prompt "์ฝ๊ฒ ์ค๋ช
ํด์ค"
codexplain feedback --rating 2 --comment "๋๋ฌด ์ด๋ ต๊ณ ์ค๋ช
์ด ๋ถ์กฑํด"
codexplain rlhf --rating 5 --comment "์ด ์คํ์ผ์ด ์ข์"
codexplain build-size
codexplain build-clean --targetRenderer composition is local and deterministic by default. If you need an
external planner to choose UX blocks, set CODEXPLAIN_UX_PLAN or
CODEXPLAIN_UX_PLANNER_COMMAND; Rust still performs the final strict-output
check and terminal rendering.
Legacy claudex and claudex-codex command names remain as compatibility
aliases, but codexplain is the official command.
The runtime implementation is Rust-only. Shell launchers in bin/ locate the
release binary at target/release/codexplain and fall back to cargo run while
developing. There are no project JS/MJS runtime files.
The Rust core is dependency-free, fast to start, and keeps build output under
ignored target/. Build artifact controls are explicit:
cargo run --bin codexplain -- pros-cons
cargo run --bin codexplain -- formula --frame ascii
cargo run --bin codexplain -- build-size
cargo run --bin codexplain -- build-clean --target
cargo run --bin codexplain -- storage-check --min-free-gb 5
cargo run --bin codexplain -- storage-check --min-free-gb 5 --clean
cargo testThe default threshold is configured as 5 GB in the Rust configuration layer.
Projects may override it in .codexplain/config.json:
{
"storageCheck": {
"minFree": { "value": 5, "unit": "gb" }
}
}Invalid values or unsupported units are ignored and fall back to the safe
default of 5 GB; the CLI flag --min-free-gb still overrides configuration.
storage-check resolves the effective threshold from the CLI flag, then
project config, then the Rust default. It prints both the compatibility
min_free_gb field and effective_min_free_gb, and its pass/fail message
uses that effective value. If free storage drops below the configured
threshold, it reports cleanup candidates such as target/, dist/, and
node_modules/. With --clean, it only removes target/, which is regenerated
by Cargo. The command prints stable key=value lines beginning with
contract=codexplain.storage-check.v1 for script-safe parsing.
This cleanup rule is intentionally narrow:
target/can be deleted because Cargo can rebuild it.dist/is reported but never removed automatically.node_modules/is reported but never removed automatically.- Cleanup only runs when available storage is below the effective threshold.
Codexplain can be evaluated with Ouroboros, but automation must remain scoped to this repository. If an evolve or Ralph run emits acceptance criteria from a different project, cancel that job and restart from an explicit project-local Seed instead of reusing the drifted lineage.
Current Seed coverage should include:
- Rust is the actual terminal explanation UX core, not a prototype.
- JS runtime has been removed; only shell launchers and the Rust binary remain.
- Dynamic renderer selection can compose multiple requested formats.
- Project-local profile, storage config, and post-response adapter are written
under
.codexplain/only. - Storage cleanup only removes
target/below the effective threshold. - Verification includes Rust tests, release build, diff whitespace, forbidden
trace grep, JS-file trace check,
build-size, andstorage-check.
Gap checks added for the renderer migration:
compound_prompts_combine_architecture_tradeoff_and_formula_renderersresponsive_architecture_panels_stack_when_terminal_is_narrowprogress_renderer_reports_status_text_bar_and_detail_tablerich_ux_prompt_combines_all_visual_status_componentsux_components_are_selected_dynamically_from_prompt_and_failure_textux_density_numerically_controls_implicit_progress_componentsux_planner_plan_parser_accepts_llm_style_component_namesnarrow_width_table_snapshot_wraps_and_fits_visible_width
Setup writes:
AGENTS.md
.codexplain/post-response
.codexplain/README.md
.codexplain/config.json
.codexplain/ux-profile.json
Repository layout:
bin/codexplain shell launcher for the Rust CLI
bin/codexplain-codex shell launcher for Codex wrapping
bin/claudex legacy compatibility alias
bin/claudex-codex legacy compatibility alias
rust/codexplain.rs dependency-free Rust CLI core
target/ ignored Cargo build artifacts
npm test
npm run check
cargo fmt --check
cargo test
cargo build --release
./bin/codexplain build-size
./bin/codexplain storage-check --min-free-gb 5