From 4cf0fc319e6694fc80d8d399f1686e6a3a409b2d Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Thu, 29 Jan 2026 14:27:46 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=AB=E3=83=90?= =?UTF-8?q?=E3=83=83=E3=82=AF=E5=8E=9F=E5=89=87=E7=A6=81=E6=AD=A2=20&=20ai?= =?UTF-8?q?-reviewer=20=E3=82=92=20ai-antipattern-reviewer=20=E3=81=AB?= =?UTF-8?q?=E3=83=AA=E3=83=8D=E3=83=BC=E3=83=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...reviewer.md => ai-antipattern-reviewer.md} | 23 ++++++++++++++++++- resources/global/en/agents/default/coder.md | 4 +--- resources/global/en/workflows/default.yaml | 2 +- .../global/en/workflows/expert-cqrs.yaml | 2 +- resources/global/en/workflows/expert.yaml | 2 +- resources/global/en/workflows/simple.yaml | 2 +- ...reviewer.md => ai-antipattern-reviewer.md} | 23 ++++++++++++++++++- resources/global/ja/agents/default/coder.md | 4 +--- resources/global/ja/workflows/default.yaml | 2 +- .../global/ja/workflows/expert-cqrs.yaml | 2 +- resources/global/ja/workflows/expert.yaml | 2 +- resources/global/ja/workflows/simple.yaml | 2 +- 12 files changed, 54 insertions(+), 16 deletions(-) rename resources/global/en/agents/default/{ai-reviewer.md => ai-antipattern-reviewer.md} (81%) rename resources/global/ja/agents/default/{ai-reviewer.md => ai-antipattern-reviewer.md} (86%) diff --git a/resources/global/en/agents/default/ai-reviewer.md b/resources/global/en/agents/default/ai-antipattern-reviewer.md similarity index 81% rename from resources/global/en/agents/default/ai-reviewer.md rename to resources/global/en/agents/default/ai-antipattern-reviewer.md index dfc065e..046c392 100644 --- a/resources/global/en/agents/default/ai-reviewer.md +++ b/resources/global/en/agents/default/ai-antipattern-reviewer.md @@ -96,7 +96,28 @@ AI-generated code has unique characteristics: **Principle:** The best code is the minimum code that solves the problem. -### 6. Decision Traceability Review +### 6. Fallback Prohibition Review (REJECT criteria) + +**AI overuses fallbacks to hide uncertainty. This is a REJECT by default.** + +| Pattern | Example | Verdict | +|---------|---------|---------| +| Swallowing with defaults | `?? 'unknown'`, `\|\| 'default'`, `?? []` | REJECT | +| try-catch returning empty | `catch { return ''; }` `catch { return 0; }` | REJECT | +| Silent skip via conditionals | `if (!x) return;` skipping what should be an error | REJECT | +| Multi-level fallback chains | `a ?? b ?? c ?? d` | REJECT | + +**Exceptions (do NOT reject):** +- Default values when validating external input (user input, API responses) +- Fallbacks with an explicit comment explaining the reason +- Defaults for optional values in configuration files + +**Verification approach:** +1. Grep the diff for `??`, `||`, `catch` +2. Check whether each fallback has a legitimate reason +3. REJECT if even one unjustified fallback exists + +### 7. Decision Traceability Review **Verify that Coder's decision log is reasonable.** diff --git a/resources/global/en/agents/default/coder.md b/resources/global/en/agents/default/coder.md index 4cb53b8..ece3074 100644 --- a/resources/global/en/agents/default/coder.md +++ b/resources/global/en/agents/default/coder.md @@ -105,8 +105,6 @@ Perform self-check after implementation. | Boy Scout | Leave touched areas slightly improved | | Fail Fast | Detect errors early. Don't swallow them | -**When in doubt**: Choose Simple. - ## Abstraction Principles **Before adding conditional branches, consider:** @@ -289,7 +287,7 @@ test('returns NotFound error when user does not exist', async () => { ## Prohibited -- **Fallback value overuse** - Don't hide problems with `?? 'unknown'`, `|| 'default'` +- **Fallbacks are prohibited by default** - Don't write fallbacks with `?? 'unknown'`, `|| 'default'`, or `try-catch` that swallow errors. Propagate errors upward. If absolutely necessary, document the reason in a comment - **Explanatory comments** - Express intent through code - **Unused code** - Don't write "just in case" code - **any type** - Don't break type safety diff --git a/resources/global/en/workflows/default.yaml b/resources/global/en/workflows/default.yaml index 35eb7b1..bd6e23f 100644 --- a/resources/global/en/workflows/default.yaml +++ b/resources/global/en/workflows/default.yaml @@ -426,7 +426,7 @@ steps: next_step: plan - name: ai_review - agent: ~/.takt/agents/default/ai-reviewer.md + agent: ~/.takt/agents/default/ai-antipattern-reviewer.md allowed_tools: - Read - Glob diff --git a/resources/global/en/workflows/expert-cqrs.yaml b/resources/global/en/workflows/expert-cqrs.yaml index 86fca79..6e7b135 100644 --- a/resources/global/en/workflows/expert-cqrs.yaml +++ b/resources/global/en/workflows/expert-cqrs.yaml @@ -483,7 +483,7 @@ steps: # Phase 4: AI Review # =========================================== - name: ai_review - agent: ~/.takt/agents/default/ai-reviewer.md + agent: ~/.takt/agents/default/ai-antipattern-reviewer.md allowed_tools: - Read - Glob diff --git a/resources/global/en/workflows/expert.yaml b/resources/global/en/workflows/expert.yaml index 15e4b83..fb24f92 100644 --- a/resources/global/en/workflows/expert.yaml +++ b/resources/global/en/workflows/expert.yaml @@ -493,7 +493,7 @@ steps: # Phase 4: AI Review # =========================================== - name: ai_review - agent: ~/.takt/agents/default/ai-reviewer.md + agent: ~/.takt/agents/default/ai-antipattern-reviewer.md allowed_tools: - Read - Glob diff --git a/resources/global/en/workflows/simple.yaml b/resources/global/en/workflows/simple.yaml index 2de2158..da3fb87 100644 --- a/resources/global/en/workflows/simple.yaml +++ b/resources/global/en/workflows/simple.yaml @@ -344,7 +344,7 @@ steps: next_step: plan - name: ai_review - agent: ~/.takt/agents/default/ai-reviewer.md + agent: ~/.takt/agents/default/ai-antipattern-reviewer.md allowed_tools: - Read - Glob diff --git a/resources/global/ja/agents/default/ai-reviewer.md b/resources/global/ja/agents/default/ai-antipattern-reviewer.md similarity index 86% rename from resources/global/ja/agents/default/ai-reviewer.md rename to resources/global/ja/agents/default/ai-antipattern-reviewer.md index 93c9e53..7320983 100644 --- a/resources/global/ja/agents/default/ai-reviewer.md +++ b/resources/global/ja/agents/default/ai-antipattern-reviewer.md @@ -119,7 +119,28 @@ AI生成コードには特有の特徴があります: 2. 公開モジュール(index ファイル等)のエクスポート一覧と実体が一致しているか確認 3. 新規追加されたコードに対応する古いコードが残っていないか確認 -### 7. 決定トレーサビリティレビュー +### 7. フォールバック禁止レビュー(REJECT基準) + +**AIは不確実性を隠すためにフォールバックを多用する。これは原則REJECT。** + +| パターン | 例 | 判定 | +|---------|-----|------| +| デフォルト値で握りつぶし | `?? 'unknown'`、`\|\| 'default'`、`?? []` | REJECT | +| try-catch で空値返却 | `catch { return ''; }` `catch { return 0; }` | REJECT | +| 条件分岐でサイレント無視 | `if (!x) return;` で本来エラーの状況をスキップ | REJECT | +| 多段フォールバック | `a ?? b ?? c ?? d` | REJECT | + +**例外(REJECTしない):** +- 外部入力(ユーザー入力、API応答)のバリデーション時のデフォルト値 +- 明示的にコメントで理由が記載されているフォールバック +- 設定ファイルのオプショナル値に対するデフォルト + +**検証アプローチ:** +1. 変更差分で `??`、`||`、`catch` を grep +2. 各フォールバックに正当な理由があるか確認 +3. 理由なしのフォールバックが1つでもあれば REJECT + +### 8. 決定トレーサビリティレビュー **Coderの決定ログが妥当か検証する。** diff --git a/resources/global/ja/agents/default/coder.md b/resources/global/ja/agents/default/coder.md index 6d73fd7..a8a23a3 100644 --- a/resources/global/ja/agents/default/coder.md +++ b/resources/global/ja/agents/default/coder.md @@ -106,8 +106,6 @@ | ボーイスカウト | 触った箇所は少し改善して去る | | Fail Fast | エラーは早期に検出。握りつぶさない | -**迷ったら**: Simple を選ぶ。 - ## 抽象化の原則 **条件分岐を追加する前に考える:** @@ -290,7 +288,7 @@ test('ユーザーが存在しない場合、NotFoundエラーを返す', async ## 禁止事項 -- **フォールバック値の乱用** - `?? 'unknown'`、`|| 'default'` で問題を隠さない +- **フォールバックは原則禁止** - `?? 'unknown'`、`|| 'default'`、`try-catch` で握りつぶすフォールバックを書かない。エラーは上位に伝播させる。どうしても必要な場合はコメントで理由を明記する - **説明コメント** - コードで意図を表現する - **未使用コード** - 「念のため」のコードは書かない - **any型** - 型安全を破壊しない diff --git a/resources/global/ja/workflows/default.yaml b/resources/global/ja/workflows/default.yaml index cac106d..6437301 100644 --- a/resources/global/ja/workflows/default.yaml +++ b/resources/global/ja/workflows/default.yaml @@ -441,7 +441,7 @@ steps: next_step: plan - name: ai_review - agent: ~/.takt/agents/default/ai-reviewer.md + agent: ~/.takt/agents/default/ai-antipattern-reviewer.md allowed_tools: - Read - Glob diff --git a/resources/global/ja/workflows/expert-cqrs.yaml b/resources/global/ja/workflows/expert-cqrs.yaml index bbe7450..6c03a76 100644 --- a/resources/global/ja/workflows/expert-cqrs.yaml +++ b/resources/global/ja/workflows/expert-cqrs.yaml @@ -635,7 +635,7 @@ steps: # Phase 4: AI Review # =========================================== - name: ai_review - agent: ~/.takt/agents/default/ai-reviewer.md + agent: ~/.takt/agents/default/ai-antipattern-reviewer.md allowed_tools: - Read - Glob diff --git a/resources/global/ja/workflows/expert.yaml b/resources/global/ja/workflows/expert.yaml index b67de05..769ad68 100644 --- a/resources/global/ja/workflows/expert.yaml +++ b/resources/global/ja/workflows/expert.yaml @@ -493,7 +493,7 @@ steps: # Phase 4: AI Review # =========================================== - name: ai_review - agent: ~/.takt/agents/default/ai-reviewer.md + agent: ~/.takt/agents/default/ai-antipattern-reviewer.md allowed_tools: - Read - Glob diff --git a/resources/global/ja/workflows/simple.yaml b/resources/global/ja/workflows/simple.yaml index 898cc91..4dfab57 100644 --- a/resources/global/ja/workflows/simple.yaml +++ b/resources/global/ja/workflows/simple.yaml @@ -344,7 +344,7 @@ steps: next_step: plan - name: ai_review - agent: ~/.takt/agents/default/ai-reviewer.md + agent: ~/.takt/agents/default/ai-antipattern-reviewer.md allowed_tools: - Read - Glob