Skip to content
Back to skills

Trace Decision

ASecurity

Use when the user asks the reason for a decision or about an earlier version, or before you overturn a decision. Do not search history for other reasons.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentsgobashnodegit

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add c-w-z/commit-decision-record --skill trace-decision --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Trace Decision?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Trace Decision
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/c-w-z-trace-decision/badge)](https://www.skillsdirectory.com/skills/c-w-z-trace-decision)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: trace-decision
description: Use when the user asks the reason for a decision or about an earlier version, or before you overturn a decision. Do not search history for other reasons.
---

# Find the reason for a decision

Docs show only the current state. Commit bodies show why a decision changed (see History and Commits in `CONTRIBUTING.md`).

- Old content in history is not the current decision. Do not act on it.

## Steps

1. **Read the current docs first.** Look at the reason, the accepted costs and the rejected options next to the decision. These usually answer the question.
2. **Find the history of a doc section:** Run each command below two times. First add `--first-parent origin/HEAD` after `git log`, to find the landing commits on the default branch. Without a ref, Git starts from the current branch. Then run it without them, to find the commits inside a pull request.
   ```bash
   git log --format='%h %ad %s' --date=short -L '/^## Modules/,/^## /:docs/design/architecture.md'
   ```
   If the heading changed or the section moved, search for a phrase in all files. Replace `<phrase>` with a quoted sentence from the section. `:(top)` makes the path start at the repo root:
   ```bash
   git log --format='%h %ad %s' --date=short -S <phrase> -- ':(top)docs'
   ```
   If the file has a new name, add `--follow`: `git log --follow --format='%h %s' -- ':(top)docs/design/architecture.md'`.
   To find the landing commit of lines in a file, use the script of step 4. It gives the landing commit of the lines as they are in the working tree.
3. **Read each commit that you found:** `git show --stat <hash>`. Read the change. Read the reason, the rejected options, the accepted costs, the evidence and any overturned decision in the message.
4. **Go from code to design:**
   1. Read the comments next to the code. If a comment links a design section, follow it with step 2 (Find the history of a doc section).
   2. Collect the sources of all lines of the decision. The lines of one decision can come from more than one commit. The script prints each commit with its lines, its full message and its design doc diff.
      For each commit, it also gives the landing commit. It is the commit on the first-parent line of the default branch that brought the commit in. Examples are a squash commit and a merge commit. A `landing commit` block holds a landing commit that is not a commit of the lines.
      Through `gh`, the script also prints the pull request of each commit and landing commit. This includes the body, the other commits and the design doc diff. It also prints the issues and comments that they name. Its `--help` text gives the parameters and the exit codes. The command finds the script from the repo root, and `<file>` is a path from the current directory:
      ```bash
      node "$(git rev-parse --show-toplevel)/tools/trace-decision/collect.mjs" <file> <start> <end>
      ```
      If the script exits with 1, fix the input. If it exits with 2, each status line `--- <source>: not read` marks one source that you did not read. A line `--- <source>: not read in full` marks a source that you read only in part. A line `--- pull request: not confirmed` means that the script could not confirm which pull request contains the commit. The evidence of such a pull request can still be in a `candidate pull request` block. A line `--- github: not read` means that the script read only Git. Only these status lines give the status. The text from Git and GitHub has 4 spaces before each line. The other sources in the same block are read.
      If the line `--- references: not read` names a reference that can explain the decision, run the script again with a larger `--max-references`.
      The line `--- first-parent line: read, <ref>` names the ref of the landing commits. If it is `HEAD`, the repo has no `origin/HEAD`. Then on a branch other than the default branch, the landing commits can be wrong. Say so if you give a reason from them. `git remote set-head origin --auto` sets `origin/HEAD`.
   3. Judge each block, the landing commits first. The reason of a pull request is in two places: the message of its landing commit, and its body in the pull request block. With the merge setting `PR_BODY`, the merge copies the body into the landing commit message.
      - The two places belong to the same pull request only if the block `=== pull request of commit <landing commit>` has the line `--- pull request: read, #<n>, merged as this commit`. Otherwise they can belong to different pull requests, for example when a stack of pull requests merges as one merge commit. Then report them as separate sources, and do not compare them. The next three rules apply only to the same pull request.
      - If the landing commit message has only a subject, the body gives the reason of the pull request. The body can have changed after the merge.
      - Compare the two only if they belong to the same pull request: the subject of the landing commit ends with `(#<number>)` of that pull request. GitHub adds it to the PR title at the merge. A merge commit of a stack holds the body and the number of the top pull request, but the script can name a lower pull request as merged as this commit (#71). If the numbers differ, do not compare. Give the two sources apart, and say which pull request each belongs to. If the subject has no number, say that the pull request of the message is not confirmed.
      - If both give a reason, compare only the parts about the decision. These are the `## Why` section or the `Why:` line, and the `Rejected:` and `Cost:` lines. In a record that has them, these are also the `## Supersedes` section or the `Supersedes:` line. A difference in the other sections, for example Validations or Checks, does not matter. A difference only in line breaks does not matter.
      - If the reasons differ, give both and the difference. Do not choose one. The landing commit message is the text at the merge, and the person who merged can have changed it. The body can have changed after the merge.
      - If the script did not read GitHub and the landing commit message has only a subject, say that you did not read the body.

      A commit inside a pull request gives a reason at a point inside the pull request. Such commits are a commit whose landing commit is a different commit, and each commit in a pull request block. A later commit of the same pull request can undo that choice. Compare such a reason with the final change. Also compare it with the landing commit if the first rule above confirms the same pull request.
      A commit or a pull request can also do more than the decision in the code. Its `Why` and its changed design sections can be about a different decision. If a changed section is about the decision, follow it with step 2 (Find the history of a doc section). Follow a reference that explains the decision. You do not need to read every source that a pull request names.
      A `candidate pull request` block holds a pull request that the script could not confirm for a commit. Its evidence can be about a different change. If you give a reason from it, say that the pull request is not confirmed.
   4. Use this step when no comment links a design section about the decision, and no changed design section is about it:
      - Report the sources that you read: the comment, the commits, and the pull requests, issues and comments.
      - Say that none of them links a design section about the decision. Do not say that no design section exists.
      - Give each reason that is about the decision: from the `Why` of a commit, a pull request, an issue or a comment. If none is about it, say that the sources that you read do not give the reason. In both cases, you can add an inference, as Report says.

## Report

- Keep the current reason and accepted costs (from the docs) separate from the reason and costs at that time (from commits).
- Keep a reason from a commit inside a pull request separate from the reason of its landing commit. Say that it is a reason at a point inside the pull request.
- For the reason of a pull request, say if it comes from the landing commit message or from the body.
- If the question is about a downside, say if a design doc or a `Cost:` line lists it.
- Cite each reason and cost by source:
  - Design doc: link the section. For a code comment, give its file path and line.
  - Commit: give its hash and author date. Use the date in the collector output. If it is missing, use `git show -s --format=%ad --date=short <hash>` if the commit is local. Otherwise, say that the date is unknown.
  - Pull request or issue: link its URL. For an issue comment or review comment, link the URL of that comment, not the discussion page.
- A commit can have no reason or no `Cost:` line. In that case, say that you did not find it. Do not conclude that the author accepted or missed a downside. Do not give a guess from the diff as a fact.
- The reader must be able to tell a reason that a source gives from a reason that you infer. You can add a reason that no source states, as an inference after the sources. This also applies when a source gives a different reason:
  - Mark it with words that say that no source gives it, for example "My inference, no source gives this reason:".
  - Cite each fact that it uses, as for a reason.
  - For a fact from a doc, find the commit that added the text. Replace `<phrase>` with a quoted sentence of the fact, and `<path>` with the path of its file from the repo root. The text is in the file, so empty output means a wrong phrase or path:
    ```bash
    git log --format='%h %ad %s' --date=short -S <phrase> -- ':(top)<path>' | grep . || { echo "No commit added this text. Check the phrase and the path." >&2; false; }
    ```
    Give the hash and date of the oldest commit in the output. If that commit is later than the decision, say so.
  - Do not give the inference as the reason of the author at that time.
- Report each source that the script of step 4 marks as "not read" as not read, and each source that it marks as "not read in full" as read in part. Do this also when you found a design section.
- For a commit whose pull request is "not confirmed", say that its pull request is not known. Report what you read from each candidate pull request apart from that.
- Before you overturn a decision, give the user what you found. The maintainer decides.
- After the maintainer decides, update the docs as `docs/doc-rules.md` says. Follow [Message format in CONTRIBUTING.md](../../../CONTRIBUTING.md#message-format) to record why the change does not keep the earlier decision.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.