フォールバック原則禁止 & ai-reviewer を ai-antipattern-reviewer にリネーム
This commit is contained in:
parent
73c4a3c555
commit
4cf0fc319e
@ -96,7 +96,28 @@ AI-generated code has unique characteristics:
|
|||||||
|
|
||||||
**Principle:** The best code is the minimum code that solves the problem.
|
**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.**
|
**Verify that Coder's decision log is reasonable.**
|
||||||
|
|
||||||
@ -105,8 +105,6 @@ Perform self-check after implementation.
|
|||||||
| Boy Scout | Leave touched areas slightly improved |
|
| Boy Scout | Leave touched areas slightly improved |
|
||||||
| Fail Fast | Detect errors early. Don't swallow them |
|
| Fail Fast | Detect errors early. Don't swallow them |
|
||||||
|
|
||||||
**When in doubt**: Choose Simple.
|
|
||||||
|
|
||||||
## Abstraction Principles
|
## Abstraction Principles
|
||||||
|
|
||||||
**Before adding conditional branches, consider:**
|
**Before adding conditional branches, consider:**
|
||||||
@ -289,7 +287,7 @@ test('returns NotFound error when user does not exist', async () => {
|
|||||||
|
|
||||||
## Prohibited
|
## 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
|
- **Explanatory comments** - Express intent through code
|
||||||
- **Unused code** - Don't write "just in case" code
|
- **Unused code** - Don't write "just in case" code
|
||||||
- **any type** - Don't break type safety
|
- **any type** - Don't break type safety
|
||||||
|
|||||||
@ -426,7 +426,7 @@ steps:
|
|||||||
next_step: plan
|
next_step: plan
|
||||||
|
|
||||||
- name: ai_review
|
- name: ai_review
|
||||||
agent: ~/.takt/agents/default/ai-reviewer.md
|
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
|
||||||
allowed_tools:
|
allowed_tools:
|
||||||
- Read
|
- Read
|
||||||
- Glob
|
- Glob
|
||||||
|
|||||||
@ -483,7 +483,7 @@ steps:
|
|||||||
# Phase 4: AI Review
|
# Phase 4: AI Review
|
||||||
# ===========================================
|
# ===========================================
|
||||||
- name: ai_review
|
- name: ai_review
|
||||||
agent: ~/.takt/agents/default/ai-reviewer.md
|
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
|
||||||
allowed_tools:
|
allowed_tools:
|
||||||
- Read
|
- Read
|
||||||
- Glob
|
- Glob
|
||||||
|
|||||||
@ -493,7 +493,7 @@ steps:
|
|||||||
# Phase 4: AI Review
|
# Phase 4: AI Review
|
||||||
# ===========================================
|
# ===========================================
|
||||||
- name: ai_review
|
- name: ai_review
|
||||||
agent: ~/.takt/agents/default/ai-reviewer.md
|
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
|
||||||
allowed_tools:
|
allowed_tools:
|
||||||
- Read
|
- Read
|
||||||
- Glob
|
- Glob
|
||||||
|
|||||||
@ -344,7 +344,7 @@ steps:
|
|||||||
next_step: plan
|
next_step: plan
|
||||||
|
|
||||||
- name: ai_review
|
- name: ai_review
|
||||||
agent: ~/.takt/agents/default/ai-reviewer.md
|
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
|
||||||
allowed_tools:
|
allowed_tools:
|
||||||
- Read
|
- Read
|
||||||
- Glob
|
- Glob
|
||||||
|
|||||||
@ -119,7 +119,28 @@ AI生成コードには特有の特徴があります:
|
|||||||
2. 公開モジュール(index ファイル等)のエクスポート一覧と実体が一致しているか確認
|
2. 公開モジュール(index ファイル等)のエクスポート一覧と実体が一致しているか確認
|
||||||
3. 新規追加されたコードに対応する古いコードが残っていないか確認
|
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の決定ログが妥当か検証する。**
|
**Coderの決定ログが妥当か検証する。**
|
||||||
|
|
||||||
@ -106,8 +106,6 @@
|
|||||||
| ボーイスカウト | 触った箇所は少し改善して去る |
|
| ボーイスカウト | 触った箇所は少し改善して去る |
|
||||||
| Fail Fast | エラーは早期に検出。握りつぶさない |
|
| Fail Fast | エラーは早期に検出。握りつぶさない |
|
||||||
|
|
||||||
**迷ったら**: Simple を選ぶ。
|
|
||||||
|
|
||||||
## 抽象化の原則
|
## 抽象化の原則
|
||||||
|
|
||||||
**条件分岐を追加する前に考える:**
|
**条件分岐を追加する前に考える:**
|
||||||
@ -290,7 +288,7 @@ test('ユーザーが存在しない場合、NotFoundエラーを返す', async
|
|||||||
|
|
||||||
## 禁止事項
|
## 禁止事項
|
||||||
|
|
||||||
- **フォールバック値の乱用** - `?? 'unknown'`、`|| 'default'` で問題を隠さない
|
- **フォールバックは原則禁止** - `?? 'unknown'`、`|| 'default'`、`try-catch` で握りつぶすフォールバックを書かない。エラーは上位に伝播させる。どうしても必要な場合はコメントで理由を明記する
|
||||||
- **説明コメント** - コードで意図を表現する
|
- **説明コメント** - コードで意図を表現する
|
||||||
- **未使用コード** - 「念のため」のコードは書かない
|
- **未使用コード** - 「念のため」のコードは書かない
|
||||||
- **any型** - 型安全を破壊しない
|
- **any型** - 型安全を破壊しない
|
||||||
|
|||||||
@ -441,7 +441,7 @@ steps:
|
|||||||
next_step: plan
|
next_step: plan
|
||||||
|
|
||||||
- name: ai_review
|
- name: ai_review
|
||||||
agent: ~/.takt/agents/default/ai-reviewer.md
|
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
|
||||||
allowed_tools:
|
allowed_tools:
|
||||||
- Read
|
- Read
|
||||||
- Glob
|
- Glob
|
||||||
|
|||||||
@ -635,7 +635,7 @@ steps:
|
|||||||
# Phase 4: AI Review
|
# Phase 4: AI Review
|
||||||
# ===========================================
|
# ===========================================
|
||||||
- name: ai_review
|
- name: ai_review
|
||||||
agent: ~/.takt/agents/default/ai-reviewer.md
|
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
|
||||||
allowed_tools:
|
allowed_tools:
|
||||||
- Read
|
- Read
|
||||||
- Glob
|
- Glob
|
||||||
|
|||||||
@ -493,7 +493,7 @@ steps:
|
|||||||
# Phase 4: AI Review
|
# Phase 4: AI Review
|
||||||
# ===========================================
|
# ===========================================
|
||||||
- name: ai_review
|
- name: ai_review
|
||||||
agent: ~/.takt/agents/default/ai-reviewer.md
|
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
|
||||||
allowed_tools:
|
allowed_tools:
|
||||||
- Read
|
- Read
|
||||||
- Glob
|
- Glob
|
||||||
|
|||||||
@ -344,7 +344,7 @@ steps:
|
|||||||
next_step: plan
|
next_step: plan
|
||||||
|
|
||||||
- name: ai_review
|
- name: ai_review
|
||||||
agent: ~/.takt/agents/default/ai-reviewer.md
|
agent: ~/.takt/agents/default/ai-antipattern-reviewer.md
|
||||||
allowed_tools:
|
allowed_tools:
|
||||||
- Read
|
- Read
|
||||||
- Glob
|
- Glob
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user