async-state-type

async-state-type is a skill for Claude Code from ncaq/konoka. It costs 37 tokens per session (849 once invoked), scanned A, original, Apache-2.0.

A React and TypeScript coding guideline for representing asynchronous data-fetching states without allowing contradictory combinations. It recommends Suspense or a discriminated union, a type structure where each state is explicitly separate.

In plain words
What is it for?
Use it when writing or reviewing React and TypeScript code that loads data asynchronously, especially components using Suspense or explicit loading and error states.
Why use it?
Loose state types can claim that data, loading, and an error exist at the same time, forcing code to handle impossible combinations. This approach makes the allowed states clearer to the type checker.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the web-tasuke plugin — 17 skills shipped together

Good fit Use it when writing or reviewing React and TypeScript code that loads data asynchronously, especially components using Suspense or explicit loading and error states.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ncaq/konoka/async-state-type
View source ↗ ncaq/konoka
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add ncaq/konoka --skill async-state-type
Clone the repo
git clone --depth 1 https://github.com/ncaq/konoka

Made for: Claude Code.

Or install web-tasuke, the plugin that ships this one along with the rest of its 17 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for async-state-type

README.md
[![agentmods](https://agentmods.dev/badge/skills/ncaq/konoka/async-state-type/github.svg)](https://agentmods.dev/skills/ncaq/konoka/async-state-type)
Your own site
<a href="https://agentmods.dev/skills/ncaq/konoka/async-state-type"><img src="https://agentmods.dev/badge/skills/ncaq/konoka/async-state-type/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for async-state-type

Your own site · 80×15
<a href="https://agentmods.dev/skills/ncaq/konoka/async-state-type"><img src="https://agentmods.dev/badge/skills/ncaq/konoka/async-state-type.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 849 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.00849
Opus 5 $0.00018 $0.00425
Sonnet 5 $0.00007 $0.00170
Haiku 4.5 $0.00004 $0.00085

Measured 4d ago against content hash 7de429205e2a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

async-state-type scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/web-tasuke/skills/async-state-type/SKILL.md · 103 lines

What it actually says

非同期データ取得の型設計

矛盾した状態を許容する型を避ける

非同期データ取得において以下のような型設計は避けてください。

// Bad: dataにアクセス可能なのにloading/errorも同時に存在しうる
type AsyncState<T> = {
  data: T | undefined;
  loading: boolean;
  error: Error | undefined;
};

この型は以下の問題を持ちます。

  • dataが存在するのにloading: trueという矛盾した状態を型が許容します
  • dataerrorが同時に存在する状態を型が許容します
  • 実行時の状態遷移に依存しており、型レベルでの安全性がありません

推奨されるアプローチ

Suspenseパターンを使う

React Suspenseを使えば、ローディング中はコンポーネントがレンダリングされないため、 dataの型が確定します。

// Good: useSuspenseQueryはdataがT型で確定している
function UserList() {
  const { data } = useSuspenseQuery({
    queryKey: ["users"],
    queryFn: fetchUsers,
  });
  // data: User[] (undefinedにならない)
  return (
    <ul>
      {data.map((user) => (
        <li key={user.id}>{user.name}</li>
      ))}
    </ul>
  );
}

// 親コンポーネントでSuspenseとErrorBoundaryを使う
<ErrorBoundary fallback={<ErrorMessage />}>
  <Suspense fallback={<Loading />}>
    <UserList />
  </Suspense>
</ErrorBoundary>;

判別共用体(Discriminated Union)を使う

Suspenseが使えない場合は、状態を排他的に表現する判別共用体を使ってください。

// Good: 状態が排他的に表現されている
type AsyncState<T> =
  | { status: "loading" }
  | { status: "error"; error: Error }
  | { status: "success"; data: T };

statusフィールドで分岐することで、各状態で利用可能なフィールドが型レベルで保証されます。

function renderState(state: AsyncState<User[]>) {
  switch (state.status) {
    case "loading":
      return <Loading />;
    case "error":
      return <ErrorMessage error={state.error} />;
    case "success":
      return <UserList users={state.data} />;
  }
}

EffectSchemaを使えば、 APIレスポンスのデコード時に型を確定させつつ、 失敗をExitEitherで型安全に表現できます。 判別共用体を手書きする代わりにEffectの仕組みに乗せるのも良いでしょう。

ライブラリの関数選定時の注意

データ取得ライブラリを使用する場合、 Suspense対応のAPIが存在するならそちらを優先して使用してください。

例えば、 apollo-clientや、 TanStack Queryなら、 useQueryではなくuseSuspenseQueryを使います。

Suspense対応APIはdataT | undefinedではなくTで返るため、型安全です。

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 103 lines · 37 tokens per session scan A 7de429205e2a

Subscribe to this mod's changes

async-state-type is a skill published in the GitHub repository ncaq/konoka (3 stars, last pushed yesterday), licensed Apache-2.0. It adds 37 tokens to every session and 849 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

Other skills, from other repositories

frontend-ai-guide

Applies React/TypeScript-specific technical decision criteria, anti-pattern detection, debugging, and frontend quality gates. Use when reviewing components, hooks, browser behavior, or frontend implementation completeness.

shinpr/claude-code-workflows · 41 tokens

typescript-rules

React/TypeScript frontend development rules including type safety, component design, state management, and error handling. Use when implementing React components, TypeScript code, or frontend features.

shinpr/claude-code-workflows · 39 tokens

bun-bundler

This skill should be used when the user asks about "bun build", "Bun.build", "bundling with Bun", "code splitting", "tree shaking", "minification", "sourcemaps", "bundle optimization", "esbuild alternative", "building for production", "bundling TypeScript", "bundling for browser", "bundling for Node", or…

secondsky/claude-skills · 90 tokens

tanstack-form-composition

Migrate a React @tanstack/react-form codebase from the prop-drilled useForm + erased-form-type pattern to the official createFormHook composition API (useAppForm / withForm / field.X). Use when a project threads a form object (often cast to an any-erased type like ReactFormExtendedApi ) through field-wrapper…

suxrobGM/jobpilot · 158 tokens

react-frontend

React, TypeScript, and Next.js patterns for frontend development. Use when building React components, managing state, fetching data, optimizing performance, or working with Next.js App Router. Covers React 18-19, hooks, Server Components, and type-safe patterns.

iliaal/whetstone · 57 tokens

stitch-nextjs-components

Converts a Stitch screen, a local HTML file, or a URL into production-ready Next.js 15 App Router components — Server vs Client split, dark mode via CSS variables, TypeScript strict, ARIA, and responsive mobile-first layout. Only the Stitch route needs an API key.

gabelul/stitch-kit · 64 tokens