Skip to content

feat(skills): add code-rationale to trace why code has its shape - #262

Merged
paveg merged 2 commits into
mainfrom
feat/code-rationale
Oct 20, 2026
Merged

paveg merged 2 commits into
mainfrom
feat/code-rationale

Conversation

@paveg

@paveg paveg commented Oct 20, 2026

Copy link
Copy Markdown
Owner

概要

コードが「なぜ」いまの形になっているのかを、根拠と確度を付けて調べるスキル code-rationale を足します。cursor/plugins の pstack why(MIT)を移植したものです。

上流は、証拠の種類ごとに調査役のエージェントを並列で立て、まとめ役のエージェントを 1 つ足します。この移植では、すべてを 1 つのセッションの中で順に行います。調査役を絞るには定義にサーバー名を書く必要がありますが、このリポジトリは公開されているので、業務環境のサーバー名は書けません。逆に絞らずに起動すると、書き込み系のツールまで渡ってしまいます。生成と評価を分ける役は、まとめ役のエージェントではなく、既存の skeptic に担わせます。答えの要になる引用を反証させます。

変更内容

  • home/dot_claude/skills/code-rationale/SKILL.md: 手順の本体。起点はコード(blame、log、PR 本文、ADR、メモリ)に置く。使えるソースはセッションのツール一覧から見つけ、7 種類に分ける。そのうえで種類ごとに検索して結果をまとめ、最後に skeptic で確かめる
  • references/epistemics.md: 5 段階の確度(Direct、Supported、Inferred、Speculative、Unknown)と、それぞれの書き方
  • references/output-template.md: 出力の形(The Question から Confidence Summary まで)
  • LICENSE: 上流の MIT の全文

業務環境に固有のソースの使い方は、このリポジトリには入れません。スキルのディレクトリに references/local-sources.md があれば読む、という形にしました。このファイルは手元だけに置きます。そのため、スキルのディレクトリを exact_ にしてはいけません。

レビューの観点

  • 省略してよい理由を 3 つにした: 上流の理由は 2 つで、「ツールがない」と「無関係だと証明できる」です。これに「そのソースの範囲に対象が入らない」を足しました。個人のリポジトリについての質問で、業務組織のチャットやトラッカーを検索するのを避けるためです。Green の 1 回目でこの検索が起きたので足しました
  • skeptic は MCP を使えない: コード以外のソースから引いた主張は、引用した部分を skeptic への依頼に貼り、元のソースは main session が自分で確かめます。そのぶん、コード以外の主張については、生成と評価の分離が弱くなります
  • 既知の限界: 個人の環境では、メールの受信箱まで「real-time chat」として検索しにいくことがあります。直したあとの Green で起きましたが、auto mode の classifier が止めました。また起きたら Step 3 で直します
  • 重い: 1 回の実行で、約 29 万〜30 万トークンを使いました(skeptic の分も含む)

検証

Red(スキルなし)と Green(スキルあり)を、同じ質問で比べました。

質問 Red Green
なぜ main.tmpl の署名鍵は business と personal で分かれているのか(答えは ADR 0004 にある) 中身は正確。ただし 7 つの基準のうち 4 つを落とした(確度のラベル、Don't Know、Sources Consulted がない) 7 つすべて満たした。skeptic は 10 件の主張をすべて確認した
なぜ tmux の history-limit は 50000 なのか(答えはどこにも記録されていない) (採っていない) 1 回目: 「記録がない」に Direct のラベルを付け、業務のソースも検索した。直したあと: 核心を Unknown とし、仮説は Inferred と Competing Hypotheses に置いた。業務のソースは理由を書いて省いた
$ just test   # exit 0
✓ All files formatted correctly!
✓ All checks passed!
$ git grep -n -i -E 'brucke|freee|fdev|cursor|mcps/' -- home/dot_claude/skills/code-rationale
(ヒットは、3 ファイルの出典行にある cursor/plugins の URL だけ)
$ cmp LICENSE <上流の LICENSE>   # exit 0

レビューは spec-reviewer、comment-reviewer、prose-reviewer の 3 つにかけ、CRITICAL は 0 件でした。IMPORTANT は 3 件出たので、すべて直しました(MIT の許諾文がない、ソースの種類の数を本文に書いている、skeptic の制約の書き方が不正確)。

🤖 Generated with Claude Code

paveg and others added 2 commits October 20, 2026 16:58
Inline port of pstack why: the session queries each evidence category
itself, synthesizes per a confidence-tier framework, and checks the
load-bearing claims with the skeptic agent before presenting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ource handling

Add the MIT license text, skip sources whose scope cannot contain records
about the target, state the skeptic's real constraint (no MCP tools), and
keep an empty search out of the Direct tier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d7f2d8c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@paveg
paveg merged commit c2ccca6 into main Oct 20, 2026
12 checks passed
@paveg
paveg deleted the feat/code-rationale branch October 20, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant