本文へスキップ
Skillpedia
一般的なプログラミング12k · #11523

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がスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/trycompai/crm/blob/release/.agents/skills/pit-of-success/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“このセッターは、nullを渡されると壊れます。通常の呼び出しが常に動くように、コードを変えてもらえますか。”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIは公開された入口のすべての呼び出し元を探し、自然な呼び出しが振る舞いを壊すかを確認して、ルールを共有のコードに移します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Pit of Success

Make misuse hard and the obvious call correct.

Steps

  1. 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.
  2. 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.
  3. 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.
  4. Delete bypasses and duplicate meanings. Replace local wrappers, parallel helper names, and comments that explain the trap with one shared implementation at the seam.
  5. 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

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル