Trace Code Work
Keep a compact audit trail beside the project so a later agent or developer can recover both the reasoning and the runtime path without rediscovering the codebase.
Non-negotiable rules
- Treat
<project-root>/code-logs/YYYY-MM-DD/ as the canonical daily log directory. Use the project's local calendar date.
- Maintain exactly these core files in each active daily directory:
DECISIONS.md, FLOW.md, EXPLORE.md, and QUIZ.md.
- Append or edit the current day's files. Never overwrite earlier dated logs.
- Record evidence and concise rationale, not hidden chain-of-thought. Explain constraints, alternatives, tradeoffs, and verification in user-auditable terms.
- Update logs during the work, not only at handoff. Log a fact as soon as it becomes relevant.
- Do not claim a call path is verified unless it was established from code, tests, runtime traces, or documentation. Label inferred paths.
- Do not duplicate secrets, tokens, personal data, or large code blocks in logs.
Start-of-task gate
Perform this sequence before editing source, tests, configuration, schemas, dependencies, generated artifacts, or deployment files.
- Locate the project root and inspect
code-logs/ read-only.
- Find the newest completed session before today. Read its four core files.
- If that session is marked
Length: long, quiz the user before any project mutation. Read-only exploration is allowed; project and log writes are not.
- Ask three to five concrete questions drawn from the recorded changes. Cover at least:
- one rationale or tradeoff;
- one execution-flow or call-order fact;
- one changed module, behavior, or test.
- Wait for the user's answers. Then give concise corrections and ask whether to proceed if their response does not already authorize continuation.
- After the gate passes, initialize today's logs and record the questions, answers, corrections, source-session date, and gate result in
QUIZ.md.
- If no prior completed long session exists, initialize today's logs and record why the quiz was not required.
The gate applies once per coding session. A user may explicitly waive it; record the waiver in QUIZ.md. Never invent answers for the user.
Define a long session
Mark a session Length: long when any one condition is met:
- active work reaches 90 minutes;
- at least five material decisions are logged;
- at least ten distinct code/config/test files are inspected or changed;
- at least three modules or services participate in a traced execution path;
- the user explicitly calls the session long.
At handoff, set each log's Status to completed and its Length to short or long. A session still marked active is not a completed session for the next quiz gate.
Initialize daily logs
Run:
python3 <skill-dir>/scripts/init_code_logs.py --root <project-root>
Pass --date YYYY-MM-DD only to reproduce or test a specific date. The script creates missing files from assets/ and preserves existing content.
If script execution is unavailable, copy the four templates from assets/ manually and replace {{DATE}}.
Maintain DECISIONS.md
Create one decision entry for every material choice, including:
- architecture, algorithm, API, data model, or error-handling approach;
- library or dependency selection, rejection, upgrade, or removal;
- behavior-changing interpretation of an ambiguous requirement;
- important testing, compatibility, performance, or security tradeoff.
Give every entry a stable daily ID such as D-001. Include context, considered alternatives, chosen option, concise rationale, consequences, affected paths, and supporting evidence. Do not log trivial syntax choices.
Maintain FLOW.md
Document the actual execution path relevant to the task:
- identify external and internal entry points;
- show call order with qualified symbols such as
module.function();
- record important inputs, outputs, state changes, branches, asynchronous boundaries, and external calls;
- mark each node as
unchanged, modified, added, or removed;
- include before and after paths when the change alters control or data flow;
- cite file paths and line numbers or symbols, refreshing stale line numbers before handoff.
Prefer a compact ordered path plus a caller/callee table. Restrict the map to paths relevant to the current task.
Maintain EXPLORE.md
Log each materially inspected file, module, class, function, schema, or configuration surface. Record why it was inspected, what was learned, whether it is in scope, and whether it must be revisited. Search this file before reopening previously explored areas, but re-check any observation that may be stale after edits.
Maintain QUIZ.md
Record whether the start gate was required, passed, waived, or skipped. When required, preserve the questions, a short summary of the user's answers, corrections, and the prior session date used as the source. Do not store an invented score; use passed when the review occurred and the user authorized work to continue.
Work cycle
For each coding task:
- Complete the start-of-task gate.
- Initialize or reuse today's log directory.
- Explore read-only and update
EXPLORE.md after each meaningful discovery.
- Establish the relevant current call path in
FLOW.md before modifying it.
- Record a decision before or alongside each material implementation choice.
- Make the code change and mark the exact changed nodes and paths in
FLOW.md.
- Run proportionate verification and attach results to the relevant decision and flow entries.
- Reconcile logs against the final diff; remove stale claims while retaining superseded decisions with status
superseded.
- Complete the session headers and add a concise changed-this-cycle summary to every core log.
Quality check before handoff
Confirm that:
- every changed path appears in at least one decision or flow entry;
- every modified runtime path has an entry point and ordered caller/callee chain;
- every significant inspected symbol appears in
EXPLORE.md;
- every new dependency has a selection rationale and rejected alternatives;
- quiz status and session length are explicit;
- the logs describe the final implementation and verification, not an abandoned plan.
1---2name: trace-code-work3description: Maintain auditable, dated coding-session records for implementation, debugging, refactoring, and code review. Use whenever Codex changes source code, tests, configuration, schemas, dependencies, build or deployment code, or resumes a coding project that has prior session logs. Create and update code-logs/YYYY-MM-DD/DECISIONS.md, FLOW.md, EXPLORE.md, and QUIZ.md; record why approaches and libraries were chosen, trace caller-to-callee execution paths and modified segments, remember explored files/functions, and enforce a user recall quiz before further project changes after a long completed session.4---56# Trace Code Work78Keep a compact audit trail beside the project so a later agent or developer can recover both the reasoning and the runtime path without rediscovering the codebase.910## Non-negotiable rules11121. Treat `<project-root>/code-logs/YYYY-MM-DD/` as the canonical daily log directory. Use the project's local calendar date.132. Maintain exactly these core files in each active daily directory: `DECISIONS.md`, `FLOW.md`, `EXPLORE.md`, and `QUIZ.md`.143. Append or edit the current day's files. Never overwrite earlier dated logs.154. Record evidence and concise rationale, not hidden chain-of-thought. Explain constraints, alternatives, tradeoffs, and verification in user-auditable terms.165. Update logs during the work, not only at handoff. Log a fact as soon as it becomes relevant.176. Do not claim a call path is verified unless it was established from code, tests, runtime traces, or documentation. Label inferred paths.187. Do not duplicate secrets, tokens, personal data, or large code blocks in logs.1920## Start-of-task gate2122Perform this sequence before editing source, tests, configuration, schemas, dependencies, generated artifacts, or deployment files.23241. Locate the project root and inspect `code-logs/` read-only.252. Find the newest completed session before today. Read its four core files.263. If that session is marked `Length: long`, quiz the user before any project mutation. Read-only exploration is allowed; project and log writes are not.274. Ask three to five concrete questions drawn from the recorded changes. Cover at least:28 - one rationale or tradeoff;29 - one execution-flow or call-order fact;30 - one changed module, behavior, or test.315. Wait for the user's answers. Then give concise corrections and ask whether to proceed if their response does not already authorize continuation.326. After the gate passes, initialize today's logs and record the questions, answers, corrections, source-session date, and gate result in `QUIZ.md`.337. If no prior completed long session exists, initialize today's logs and record why the quiz was not required.3435The gate applies once per coding session. A user may explicitly waive it; record the waiver in `QUIZ.md`. Never invent answers for the user.3637## Define a long session3839Mark a session `Length: long` when any one condition is met:4041- active work reaches 90 minutes;42- at least five material decisions are logged;43- at least ten distinct code/config/test files are inspected or changed;44- at least three modules or services participate in a traced execution path;45- the user explicitly calls the session long.4647At handoff, set each log's `Status` to `completed` and its `Length` to `short` or `long`. A session still marked `active` is not a completed session for the next quiz gate.4849## Initialize daily logs5051Run:5253```bash54python3 <skill-dir>/scripts/init_code_logs.py --root <project-root>55```5657Pass `--date YYYY-MM-DD` only to reproduce or test a specific date. The script creates missing files from `assets/` and preserves existing content.5859If script execution is unavailable, copy the four templates from `assets/` manually and replace `{{DATE}}`.6061## Maintain `DECISIONS.md`6263Create one decision entry for every material choice, including:6465- architecture, algorithm, API, data model, or error-handling approach;66- library or dependency selection, rejection, upgrade, or removal;67- behavior-changing interpretation of an ambiguous requirement;68- important testing, compatibility, performance, or security tradeoff.6970Give every entry a stable daily ID such as `D-001`. Include context, considered alternatives, chosen option, concise rationale, consequences, affected paths, and supporting evidence. Do not log trivial syntax choices.7172## Maintain `FLOW.md`7374Document the actual execution path relevant to the task:7576- identify external and internal entry points;77- show call order with qualified symbols such as `module.function()`;78- record important inputs, outputs, state changes, branches, asynchronous boundaries, and external calls;79- mark each node as `unchanged`, `modified`, `added`, or `removed`;80- include before and after paths when the change alters control or data flow;81- cite file paths and line numbers or symbols, refreshing stale line numbers before handoff.8283Prefer a compact ordered path plus a caller/callee table. Restrict the map to paths relevant to the current task.8485## Maintain `EXPLORE.md`8687Log each materially inspected file, module, class, function, schema, or configuration surface. Record why it was inspected, what was learned, whether it is in scope, and whether it must be revisited. Search this file before reopening previously explored areas, but re-check any observation that may be stale after edits.8889## Maintain `QUIZ.md`9091Record whether the start gate was required, passed, waived, or skipped. When required, preserve the questions, a short summary of the user's answers, corrections, and the prior session date used as the source. Do not store an invented score; use `passed` when the review occurred and the user authorized work to continue.9293## Work cycle9495For each coding task:96971. Complete the start-of-task gate.982. Initialize or reuse today's log directory.993. Explore read-only and update `EXPLORE.md` after each meaningful discovery.1004. Establish the relevant current call path in `FLOW.md` before modifying it.1015. Record a decision before or alongside each material implementation choice.1026. Make the code change and mark the exact changed nodes and paths in `FLOW.md`.1037. Run proportionate verification and attach results to the relevant decision and flow entries.1048. Reconcile logs against the final diff; remove stale claims while retaining superseded decisions with status `superseded`.1059. Complete the session headers and add a concise changed-this-cycle summary to every core log.106107## Quality check before handoff108109Confirm that:110111- every changed path appears in at least one decision or flow entry;112- every modified runtime path has an entry point and ordered caller/callee chain;113- every significant inspected symbol appears in `EXPLORE.md`;114- every new dependency has a selection rationale and rejected alternatives;115- quiz status and session length are explicit;116- the logs describe the final implementation and verification, not an abandoned plan.