Concurrency Reasoningのロゴ

Concurrency Reasoning

コミュニティ
adamentwistle
concurrency-reasoning

非同期・並行処理・ストリーミングを安全に扱うための指針です。5つの観点(処理の重複実行、確認後の状態変化、awaitをまたぐ変更、レスポンスの順序、キャンセル)、ガードの適用範囲、ファンアウト時の失敗、冪等性のあるリトライ、共有状態の監査、競合状態の増幅を確認します。非同期ファンアウト(Promise.all、gather)、ストリーム/SSE/WebSocket、キューワーカー、cronジョブ、Webhook、キャッシュ、ロック、リトライを扱う場合や、「ときどき」「重複する」「二重請求される」「負荷がかかったときだけ」といった不具合を調査する場合に使ってください。

Add to TypingMind

概要

公開者adamentwistle
リポジトリfable-skills
スキル名concurrency-reasoning
スター
98
フォーク
11
同梱ファイル
指示のみ
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    adamentwistleがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Concurrency Reasoning」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/adamentwistle/fable-skills/tree/main/concurrency-reasoning
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/adamentwistle/fable-skills.git /tmp/fable-skills
mkdir -p .claude/skills
cp -r /tmp/fable-skills/concurrency-reasoning .claude/skills/concurrency-reasoning
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでConcurrency Reasoningを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にConcurrency Reasoningを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Concurrency Reasoningは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Concurrency Reasoning

Concurrency bugs don't announce themselves in review — the code reads fine sequentially. Weak reasoning reads top to bottom and calls it correct. Strong reasoning asks a fixed set of questions about every async surface, because the compiler won't.

Step 0 — Inventory the surfaces

Before writing or reviewing, list every await/callback/handler/worker in the diff and every piece of state it touches that outlives one invocation (module globals, singletons, caches, class fields, DB rows, files). The questions below are asked per item on that list, not once per file.

The core question set

  1. What if this runs twice, overlapping? Two clicks, two requests, a retry racing the original, cron overlapping its previous run, a webhook delivered twice. If the answer is corrupted state or a double effect, add a guard: idempotency key, unique constraint, mutex, request de-dupe, disable-on-click.
  2. What happens between the check and the act? Every if (exists) then update on shared state is a TOCTOU window. Close it with an atomic operation (upsert, compare-and-swap, unique constraint, transaction) — not a smaller window.
  3. Who else mutates this while I await? Every await is a yield point: module variables, caches, closure-captured objects can change under you. Re-read after the await if it matters; don't carry pre-await reads across the gap.
  4. What order do these land in? Two in-flight requests resolve in either order. If responses update the same state (search-as-you-type, autosave), guard with sequence numbers, latest-wins checks, or cancel the superseded one.
  5. What happens on cancellation/unmount/disconnect mid-flight? Handlers firing after teardown need abort signals, mounted flags, or subscription cleanup. Partial effects from an aborted multi-step operation need cleanup or resumability.

Guard scope must match concurrency scope

An in-process mutex or in-memory de-dupe set guards one process only. If the service runs as multiple instances, workers, or serverless invocations, the guard must live where the contention is: database unique constraint, row lock, atomic compare-and-swap in the shared store, or a distributed lock with a lease. Name which one in the report.

Fan-out

For Promise.all/gather-style fan-out, decide what happens when one of N fails (abort the rest, collect all outcomes, report partial success as partial) and bound the concurrency — unbounded fan-out over a list of unknown size is a self-DoS.

Retries and exactly-once

  • Retry only idempotent operations, or make them idempotent first (idempotency keys, natural unique constraints). A retried "create" without one is a duplicate.
  • Backoff + jitter + a cap. Immediate retry in a loop is a DoS on your own dependency.
  • Distinguish "the request failed" from "the response failed" — the operation may have succeeded server-side. Design reads-back or upserts accordingly.

Shared-state audit

For each state item in the Step 0 inventory: who writes it, from how many concurrent contexts, and what serializes those writes? "Nothing serializes them, but it's probably fine" is a bug report from the future. Put the answer in the report.

Debugging suspected races

  • Flaky test → don't rerun until green. Amplify: run 20–100× in a loop, add load, add sleep at suspected interleaving points to widen the window until it fails deterministically.
  • Bisect by interleaving, not by code: log timestamps + IDs at each async boundary and reconstruct the actual order of the failing run.
  • The fix must name the interleaving it prevents, and a test must force that interleaving (two calls with a barrier or injected delay) and fail before the fix. "Added a lock and it stopped failing" without knowing the race is a hidden deadlock waiting.

Deadlock/starvation reflexes

Consistent lock ordering; never hold a lock across an await/IO; timeouts on anything that waits on another party; bounded queues (an unbounded queue turns backpressure into an OOM).

よくある質問

AIスキル「Concurrency Reasoning」では何ができますか?

非同期・並行処理・ストリーミングを安全に扱うための指針です。5つの観点(処理の重複実行、確認後の状態変化、awaitをまたぐ変更、レスポンスの順序、キャンセル)、ガードの適用範囲、ファンアウト時の失敗、冪等性のあるリトライ、共有状態の監査、競合状態の増幅を確認します。非同期ファンアウト(Promise.all、gather)、ストリーム/SSE/WebSocket、キューワーカー、cronジョブ、Webhook、キャッシュ、ロック、リトライを扱う場合や、「ときどき」「重複する」「二重請求される」「負荷がかかったときだけ」といった不具合を調査する場合に使ってください。

TypingMindでConcurrency Reasoningを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Concurrency Reasoningはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにConcurrency Reasoningをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/adamentwistle/fable-skills/tree/main/concurrency-reasoningを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Concurrency Reasoningを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Concurrency Reasoningで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもConcurrency Reasoningを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Concurrency Reasoning」は無料ですか?

はい。adamentwistleがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇