Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions packages/canton-devenv-start/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ Pre-configured Docker environment for Canton/DAML development. Eliminates manual

**Files:**
- **Dockerfile** - Shared base with DAML SDK + tooling
- **latest/** - SDK 3.x (Canton 3.4.8)
- **latest/** - SDK 3.x
- **stable/** - SDK 2.x
- **install-daml-vsix.sh** - Auto-installs DAML IDE extension
- **daml-lsp-restart.sh** - Language server helper
- **daml-lsp-restart.sh** - Language server restarter helper

### Claude Code Integration
**Problem:** DAML's `codegen js` produces verbose, deeply-nested TypeScript with package hashes and complex type paths—difficult to use directly in applications.

**Solution:** AI-assisted SDK generation via slash command:
**Solution:** AI-assisted SDK generation via Skill (auto-invoked when you mention "generate canton SDK"):

```bash
/project:generate-api
```
Generate a TypeScript API from my Daml contracts
```

Transforms raw Daml JS bindings → clean, documented TypeScript API:
- Parses `daml.yaml` / `multi-package.yaml` projects
Claude automatically:
- Discovers `daml.yaml` / `multi-package.yaml` projects
- Runs `daml build` + `daml codegen js`
- Generates type-safe SDK with workflows (CreateAccount, Transfer, DvP, etc.)
- Generates type-safe SDK
- Produces test suite with Vitest

**Output structure:**
Expand All @@ -61,21 +61,20 @@ sdk/
└── <project>-api.test.ts
```

**Skill location:** `.claude/skills/canton-sdk-generator/`

## Getting Started
1. Run scaffold command
2. Open in VS Code/Cursor
3. "Reopen in Container" → choose **latest** or **stable**
4. (Optional) Run `/project:generate-api` to generate TypeScript SDK

## Forwarded Ports
`5011` `5012` `5021` `5022` `5018` `5019` `7500` `7575`
4. (Optional) Ask Claude to generate TypeScript SDK from your Daml contracts

## Local Development
```bash
# From repo root
bunx --bun link
# From package directory
cd packages/canton-devenv-start
bun link

# In test workspace
bun link canton-devenv-start
bunx devenv-init --dir /tmp/test-canton-env --force
bunx canton-devenv-start
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
description: Generate TypeScript API from Daml contracts - builds, generates bindings, creates clean API, and generates tests
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
---

Expand Down Expand Up @@ -66,13 +67,16 @@ Where:

## STEP 5: Run Generator Script

Ensure the output directory has dependencies, then run the generator:
Ensure the output directory has dependencies, then run the generator.

The generator script is located in this skill's directory at `scripts/generate-canton-api.ts`.

```bash
cd <sdk-path> && npm install && npx ts-node <repo-root>/.claude/commands/canton-sdk-generator/scripts/generate-canton-api.ts daml-js . <project-name>
cd <sdk-path> && npm install && 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 1
- Output will be written to `<sdk-path>/`
Expand All @@ -91,10 +95,7 @@ Fix any errors before proceeding.

## STEP 7: Enhance the Generated API

Read and apply the enhancement instructions from:
```
.claude/commands/canton-sdk-generator/prompts/enhance-api.md
```
Read and apply the enhancement instructions from `prompts/enhance-api.md` in this skill's directory.

Add the following to `<project-name>-api.ts`:
1. **Query namespace** - Helper functions for querying contracts
Expand All @@ -110,10 +111,12 @@ After adding enhancements, re-validate TypeScript.

## STEP 8: Generate Tests

Run the test generator to create explicit tests for the generated API:
Run the test generator to create explicit tests for the generated API.

The test generator script is at `scripts/generate-canton-tests.ts` in this skill's directory.

```bash
cd <sdk-path> && npx ts-node <repo-root>/.claude/commands/canton-sdk-generator/scripts/generate-canton-tests.ts . <project-name>
cd <sdk-path> && npx ts-node <path-to-skill>/scripts/generate-canton-tests.ts . <project-name>
```

This will:
Expand Down