pit-of-success
できること
AIが、誤用されうるAPI呼び出し、セッター、プロップを探し、必要な振る舞いを共有のコードに移す手順を案内します。コードをレビューまたはリファクタリングする開発者向けです。
使う場面
- ✓APIやセッター、コンポーネントのプロップに、自然な呼び出しで落ちてしまう罠があるとき。
- ✓安全な方法が既定の方法になるように、コードをリファクタリングするとき。
- ✓重複するヘルパーやラッパーを、一つの共有の実装に置き換えたいとき。
スキルのリンク
https://github.com/trycompai/crm/blob/release/.agents/skills/pit-of-success/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このセッターは、nullを渡されると壊れます。通常の呼び出しが常に動くように、コードを変えてもらえますか。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは公開された入口のすべての呼び出し元を探し、自然な呼び出しが振る舞いを壊すかを確認して、ルールを共有のコードに移します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Pit of Success
Make misuse hard and the obvious call correct.
Steps
- Find the public seam being used: exported function, hook return value, setter, component prop, route body, schema, or command. Then search every caller of that seam. Done when you know the natural call a future maintainer would write.
- Run the footgun test: “If someone does the obvious thing without knowing the hidden helper or convention, does behavior break?” Examples:
setSelection(null)should mean the product’s normal clear behavior; a schema should reject states the UI never wants; a prop should not require sibling props in the right combo. - Move the invariant into the seam. Prefer, in order:
- make the existing API do the safe thing,
- narrow the type/schema so bad states cannot be represented,
- rename/split the API so the dangerous path is explicit,
- only then add a helper, and only if all natural callers use it.
- Delete bypasses and duplicate meanings. Replace local wrappers, parallel helper names, and comments that explain the trap with one shared implementation at the seam.
- Prove the pit with one check: a focused test or type/schema assertion showing the obvious call now preserves behavior, plus a grep confirming no caller still uses the old footgun.
Rules
- Do not fix only the named callsite. If the seam is wrong, fix the seam.
- Do not rely on “remember to call this helper first” when callers can still call the raw API.
- Do not add comments as a substitute for making misuse impossible or obvious.
- Keep the diff boring: one invariant, one owner, no speculative abstraction.
- If compatibility prevents changing the seam, name the dangerous API accordingly and expose a safe default API beside it.
よくある質問
一つの呼び出し箇所だけを直しますか?
いいえ。APIそのものが誤っている場合は、一つの呼び出し元ではなく、共有の接点を直すよう定めています。
修正の優先順位は?
既存のAPIを安全にすることを優先し、次に型を絞り込み、次にAPIを分け、ヘルパーの追加は最後に行います。
どうやって修正を確かめますか?
自然な呼び出しが動くことを示す、焦点を絞ったテストや型チェックを使い、古い呼び出し元が残っていないかを検索で確認します。
詳細
作者による元の説明
Review or refactor code so the correct behavior is the default path; use when APIs, setters, hooks, helpers, or component props have footguns where a natural call bypasses required semantics.
repo: trycompai/crm
人気
- GitHubのスター
- 12k
- ランキング
- #11523
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
ai-elements
12kエージェントが、会話、メッセージ、ツールの表示、プロンプト入力のための既成のコンポーネントを使って、AIチャットの画面を作れるよう支援します。
ai-sdk
12kエージェントが、テキスト生成、ストリーミング、ツール呼び出し、エージェントを含め、Vercel AI SDKでAI機能を作れるよう支援します。
better-accessibility
12kエージェントが、フォーカス、ラベル、ARIA、フォームを含め、キーボードとスクリーンリーダーで使えるインターフェースを作れるよう支援します。
better-auth-best-practices
12kエージェントが、Better Authの文書の手順に従い、TypeScriptのアプリでログイン、セッション、OAuth、プラグインのための設定を行えるよう支援します。
似ているスキル
diffs
394k編集内容の実際の共有可能な差分を、手書きの要約ではなく、ビューアーのリンクや画像ファイルとして作成するようエージェントを支援します。
coding-agent
394kCodex、Claude Code、OpenCodeに大きめのコーディング作業をバックグラウンドのワーカーとして渡し、その進捗を確認するようエージェントを支援します。
gh-issues
394kGitHubのイシューを探し、取り組むものを選び、修正を含むプルリクエストを開くようエージェントを支援します。レビューコメントへの対応も含みます。