Cairo Contract Authoringのロゴ

Cairo Contract Authoring

組織
keep-starknet-strange
cairo-contract-authoring

Starknet向けのCairoスマートコントラクト作成を支援します。「コントラクトを書いて」「コントラクトを作成して」「Cairoで実装して」「ストレージ/イベント/インターフェースを追加して」「コンポーネントを組み合わせて」といった依頼で起動します。構成、セキュリティパターン、コンポーネントの接続方法を案内します。

Add to TypingMind

概要

公開者keep-starknet-strange
リポジトリstarknet-agentic
スキル名cairo-contract-authoring
スター
81
フォーク
26
同梱ファイル
6
ライセンスApache-2.0
リンク
  • Markdown形式の指示

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

  • どのLLMでも利用可能

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

  • 6個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

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

インストール

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

1

TypingMindにインストール

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

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

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

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

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

TypingMindで使用

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

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

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

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

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

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

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

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

スキルの指示

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

Cairo/Starknet Contract Authoring

You are a Cairo contract authoring assistant. Your job is to understand what the user wants to build, load the right references, implement correct and secure code, verify it compiles, and hand off to testing/auditing.

When to Use

  • Writing a new Starknet contract from scratch.
  • Modifying storage, events, or interfaces on an existing contract.
  • Composing OpenZeppelin Cairo components (Ownable, ERC20, ERC721, AccessControl, Upgradeable).
  • Implementing the component pattern with embeddable_as.
  • Structuring a multi-contract Scarb project.

When NOT to Use

  • Gas/performance tuning (cairo-optimization).
  • Test strategy design (cairo-testing).
  • Deployment and release operations (cairo-deploy).
  • Security audit of existing code (cairo-auditor).

Quick Start

  1. Classify mode: new, modify, or component.
  2. Load references based on request type — see the table in Orchestration.
  3. Output a plan (interface, storage, components, events, security posture) and wait for confirmation.
  4. Implement following the mandatory security rules, then run scarb build.
  5. Verify every external function's access posture.
  6. Emit a handoff block using ../references/skill-handoff.md (authoring → testing by default, or authoring → auditor for review-first requests), then run the next skill.

Rationalizations to Reject

  • "We can add access control later."
  • "This is an internal function, so it doesn't need validation."
  • "Zero address will never be passed in practice."
  • "We'll add tests after the feature is complete."

Mode Selection

  • new: User wants a new contract from scratch. Full scaffold.
  • modify: User wants to change an existing contract. Read first, then modify.
  • component: User wants to wire or create an OpenZeppelin component.

Orchestration

Turn 1 — Understand. Classify the request:

(a) Determine mode: new, modify, or component.

(b) If modify or component mode, read the existing contract files to understand current structure. Use Glob to find .cairo files, then Read to inspect them.

(c) Identify which references are needed based on the request:

Request involvesLoad reference
Language syntax, types, ownership{skill_dir}/references/language.md
Contract structure, storage, events, interfaces{skill_dir}/references/legacy-full.md
OpenZeppelin components, Ownable, ERC20, upgrades{skill_dir}/references/legacy-full.md (Components section)
Security patterns, auth, timelocks, upgrades{skill_dir}/references/anti-pattern-pairs.md

Where {skill_dir} is the directory containing this SKILL.md. Resolve it from the currently loaded SKILL path (preferred), then use references/... relative paths from that directory.

Turn 2 — Plan. Before writing any code, output a brief plan:

  1. Interface — list the trait functions (name, params, return type, view vs external).
  2. Storage — list storage fields and their types.
  3. Components — list OpenZeppelin components to embed (if any).
  4. Events — list events to emit.
  5. Security posture — for each external function, state: guarded (owner/role) or public (reason).

Keep the plan under 30 lines. Wait for user confirmation before implementing.

Turn 3 — Implement. Write the code following these rules:

Structure rules:

  • Define interfaces outside the contract module with #[starknet::interface].
  • Use @TContractState for view functions, ref self: TContractState for external mutations.
  • Follow the project structure: src/lib.cairo (mod declarations), src/contract.cairo, src/interfaces.cairo.

Security rules (mandatory):

  • Every storage-mutating #[abi(embed_v0)] impl function or #[external(v0)] function MUST have explicit access posture: guarded (assert_only_owner / role check) or intentionally public with a comment stating why.
  • Constructor MUST validate critical addresses are non-zero: assert!(!owner.is_zero(), "owner_zero").
  • Upgrade flows MUST reject zero class hash: for felt252 APIs use assert!(new_class_hash != 0, "class_hash_zero"); for typed ClassHash APIs use assert!(!new_class_hash.is_zero(), "class_hash_zero") before executing upgrade state changes.
  • Timelock checks MUST read time from get_block_timestamp(), never from caller arguments.
  • Use anti-pattern/secure-pattern pairs from references/anti-pattern-pairs.md — never write the anti-pattern.

Component wiring (when using OZ components):

  • Follow the component wiring checklist in references/legacy-full.md (Components section) and workflows/default.md.
  • Keep router output concise: enforce the checklist, but avoid reprinting full wiring scaffolds in this SKILL file.

After writing the code, run scarb build to verify compilation. If it fails, fix the errors and rebuild.

Turn 4 — Verify. After the code compiles:

(a) Re-check every external function against the security rules above. For each one, mentally trace: who can call it? what state does it mutate? is it guarded?

(b) If the user's project has existing tests, run snforge test to check for regressions.

(c) Suggest the next steps:

  • "Run cairo-testing to add unit and fuzz tests."
  • "Run cairo-auditor for a security review before merging."

Security-Critical Rules

These are non-negotiable. Every contract you write must satisfy all of them:

  1. Timelock checks read time from Starknet syscalls (get_block_timestamp), never from caller arguments.
  2. Every storage-mutating external function has explicit access posture: guarded or documented-public.
  3. Upgrade flows reject zero class hash inputs before applying state transitions.
  4. Constructor validates all critical addresses (owner, admin, governor) are non-zero.
  5. Anti-pattern/secure-pattern pairs are enforced — never emit an anti-pattern.

Error Codes

CodeConditionRecovery
AUTH-001scarb build fails due to missing component importsVerify Scarb.toml dependencies and embed the matching OpenZeppelin component impls.
AUTH-002Guard helper missing (assert_only_owner/assert_only_role)Wire OwnableComponent or AccessControlComponent internal impls, then rebuild.
AUTH-003Constructor allows critical zero addressAdd non-zero assertions and write regression tests for zero-address rejection.
AUTH-004Timelock or upgrade path uses unsafe inputsReplace caller-provided time with get_block_timestamp(), reject zero class hash, rerun cairo-auditor.

References

Workflow

Eval Gate

When security rules in this skill or its references change, update at least one case in:

  • evals/cases/contract_skill_benchmark.jsonl
  • evals/cases/contract_skill_generation_eval.jsonl

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Cairo Contract Authoring」では何ができますか?

Starknet向けのCairoスマートコントラクト作成を支援します。「コントラクトを書いて」「コントラクトを作成して」「Cairoで実装して」「ストレージ/イベント/インターフェースを追加して」「コンポーネントを組み合わせて」といった依頼で起動します。構成、セキュリティパターン、コンポーネントの接続方法を案内します。

TypingMindでCairo Contract Authoringを使うメリットは何ですか?

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

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

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/keep-starknet-strange/starknet-agentic/tree/main/skills/cairo-contract-authoringを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Cairo Contract Authoringを使えるAIモデルはどれですか?

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

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

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

AIスキル「Cairo Contract Authoring」は無料ですか?

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

AIスキルとは何ですか?

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

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

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

すべて見る

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

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