원클릭으로
canton-sdk-generator
Generate TypeScript API from Daml smart contracts. Use when user mentions "generate canton SDK".
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Generate TypeScript API from Daml smart contracts. Use when user mentions "generate canton SDK".
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Design and generate themed PlantUML activity diagrams for Daml workflows and choice flows. Use this skill whenever the user asks to diagram a Daml choice, visualize a multi-party workflow, draw swim lanes for parties or templates, render an exercise flow, or sketch a contract interaction — even if "PlantUML" is not named explicitly. Currently covers activity/workflow diagrams only; not yet transaction trees or contract lifecycle graphs.
Decision framework for choosing between on-ledger Daml/Canton logic and off-ledger backend code. Use whenever the user is designing Daml templates, choices, or interfaces; deciding what should live in a smart contract vs an operator backend; weighing Canton throughput or contention concerns; integrating oracles, KYC, or any external data with Daml; refactoring an on-ledger component because it's too heavy; or asking variations of "should this be a Daml choice?", "where does this logic go?", "is this on-ledger?", or "should the backend handle this?". Default the user toward off-ledger and require explicit justification for putting anything on-ledger.
Generate TypeScript tests from Daml scripts. Use when user mentions "generate tests", "create tests for canton", or "generate canton tests".
Generate a React webapp for Canton ledger. Use when user mentions "generate webapp", "create webapp", or "build frontend".
| name | canton-sdk-generator |
| description | Generate TypeScript API from Daml smart contracts. Use when user mentions "generate canton SDK". |
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep, AskUserQuestion |
Generate a clean, developer-friendly TypeScript API from Daml smart contracts.
Look for Daml project configuration:
multi-package.yaml in workspace root - if exists, parse to find all project pathsdaml.yaml in workspace root - single project setup**/daml.yaml - scan for projects in subdirectoriesFor each project found, extract:
name: field in daml.yaml)If multiple projects are found, use AskUserQuestion to ask the user:
"Which Daml project should I generate the API for?"
Options should list all discovered project names.
cd <project-path> && daml build
If build fails, report error and stop.
After successful build, find all DAR files needed for codegen:
<project-path>/.daml/dist/<project-name>-*.dar.lib/: <project-path>/.lib/*.darBuild the codegen command dynamically with all discovered DARs.
Run daml codegen js with all discovered DAR files:
cd <project-path> && daml codegen js -o <sdk-path>/daml-js <all-dar-files>
Where:
<sdk-path> defaults to <project-path>/sdk - the SDK output directory<all-dar-files> is the space-separated list of all DARs from Step 3The generator script produces ALL SDK code including:
cd <sdk-path> && npx ts-node <path-to-skill>/scripts/generate-canton-api.ts daml-js . <project-name>
Where:
<path-to-skill> is the absolute path to this skill's directory<sdk-path> defaults to <project-path>/sdk<project-name> is the name discovered in Step 1cd <sdk-path> && npx tsc --noEmit
Fix any errors before proceeding.
Run the React hooks generator:
cd <sdk-path> && npx ts-node <path-to-skill>/scripts/generate-canton-react.ts . <project-name>
Generates:
react/context/LedgerContext.tsx - React context providerreact/context/useLedger.ts - Context hookreact/hooks/core.ts - Generic hooks (useContractQuery, useChoiceMutation)react/hooks/queries.ts - Typed query hooks for each templatereact/hooks/mutations.ts - Typed create + choice mutation hooks (action-first naming) and grouped actions per templatereact/hooks/keys.ts - Query key factories aligned with core query keys (so invalidation works)react/index.ts - Barrel exportRead prompts/enhance-api.md for validation checklist:
docs/SDK.md documentation (required)This step validates generated code and creates user documentation.
If you manually call the JSON API (e.g. with curl) and see:
missing Authorization header with OAuth 2.0 Bearer Token
Remember:
Authorization: Bearer <JWT>.The generated SDK README includes a copy‑pasteable curl + token snippet.
Report when complete:
<project-name><project-path><sdk-path>After SDK generation is complete, suggest:
"SDK generated successfully! To generate integration tests, run the
canton-test-generatorskill."
The test generator will:
daml/Scripts/tests/