@cloak.dev/claude-skills 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { cpSync, mkdirSync, readdirSync, existsSync } from "fs";
4
+ import { join, dirname } from "path";
5
+ import { homedir } from "os";
6
+ import { fileURLToPath } from "url";
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const skillsDir = join(__dirname, "..", "skills");
10
+ const targetDir = join(homedir(), ".claude", "commands");
11
+
12
+ mkdirSync(targetDir, { recursive: true });
13
+
14
+ const files = readdirSync(skillsDir).filter((f) => f.endsWith(".md"));
15
+
16
+ for (const file of files) {
17
+ cpSync(join(skillsDir, file), join(targetDir, file));
18
+ const name = file.replace(".md", "");
19
+ console.log(` /${name}`);
20
+ }
21
+
22
+ console.log(`\nInstalled ${files.length} Cloak skills to ${targetDir}`);
23
+ console.log("\nAvailable commands in Claude Code:");
24
+ console.log(" /cloak-send — One-shot private send (deposit + withdraw)");
25
+ console.log(" /cloak-shield — Deposit tokens into shielded pool");
26
+ console.log(" /cloak-pay — Spend from shielded balance");
27
+ console.log(" /cloak-swap — Private swap (SOL to USDC/USDT)");
28
+ console.log("\nDocs: https://docs.cloak.ag");
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@cloak.dev/claude-skills",
3
+ "version": "0.2.1",
4
+ "type": "module",
5
+ "description": "Claude Code slash commands for private Solana transactions via Cloak — shield, pay, send, and swap",
6
+ "bin": {
7
+ "cloak-skills": "bin/cli.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "skills"
12
+ ],
13
+ "keywords": [
14
+ "cloak",
15
+ "solana",
16
+ "privacy",
17
+ "claude-code",
18
+ "claude-skills",
19
+ "ai"
20
+ ],
21
+ "author": "Cloak Labs",
22
+ "license": "Apache-2.0",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/cloak-ag/sdk.git"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ }
30
+ }
@@ -0,0 +1,55 @@
1
+ # Pay from Shielded Balance via Cloak
2
+
3
+ You are helping the user spend from their shielded Cloak balance to pay a recipient.
4
+
5
+ ## Instructions
6
+
7
+ 1. Read https://docs.cloak.ag/llms.txt and https://docs.cloak.ag/sdk/llms.txt to understand the SDK.
8
+
9
+ 2. Parse the user's request to extract:
10
+ - **amount**: in human units (e.g. "5 USDC" = 5_000_000 base units). If "all" or no amount, use full withdraw.
11
+ - **recipient**: the destination wallet public key.
12
+ - **sender keypair path**: the user must specify the path to a `.json` keypair file.
13
+ - **UTXO file**: path to the `shielded-utxo.json` file created by `/cloak-shield`. Default to `shielded-utxo.json` in current directory.
14
+
15
+ 3. Create exactly one script file in the current directory:
16
+ - Name: `pay-from-shielded.ts`
17
+ - CLI: `npx tsx pay-from-shielded.ts <recipientPubkey> <amountBaseUnits> [utxoFile]`
18
+ - If amountBaseUnits equals the full UTXO amount, use `fullWithdraw()`. Otherwise use `partialWithdraw()`.
19
+ - Env: `SOLANA_RPC_URL` and `KEYPAIR_PATH` only
20
+ - Parse all args from `process.argv`
21
+ - Load the UTXO file, reconstruct the Utxo object using `deserializeUtxo()` or by rebuilding from saved fields (amount, keypair privateKey, mint, index)
22
+ - Use `partialWithdraw()` or `fullWithdraw()` with `externalAmount < 0` (withdraw)
23
+ - Keep `programId` as `CLOAK_PROGRAM_ID` internally
24
+ - Set `enforceViewingKeyRegistration: false`
25
+ - **For SPL token withdrawals (not native SOL)**: You MUST pre-build an Address Lookup Table (ALT) before calling `partialWithdraw`/`fullWithdraw`, because SPL transactions exceed Solana's 1232-byte legacy transaction limit. Use this pattern:
26
+ 1. Import `getShieldPoolPDAs` from the SDK and `getAssociatedTokenAddressSync` from `@solana/spl-token`
27
+ 2. Compute all known accounts: `SystemProgram.programId`, `SYSVAR_SLOT_HASHES_PUBKEY`, `SYSVAR_INSTRUCTIONS_PUBKEY`, `ComputeBudgetProgram.programId`, `programId`, pool PDAs (`pool`, `treasury`, `merkleTree`, `vaultAuthority`), pool vault ATA, payer ATA, `TOKEN_PROGRAM_ID`
28
+ 3. Create and extend ALT using `AddressLookupTableProgram.createLookupTable()` and `extendLookupTable()` in one transaction
29
+ 4. Wait for ALT activation: poll `getAddressLookupTable` up to 30 times with 500ms delay. Check activation with `result.value.isActive()` (method call, not property)
30
+ 5. Pass the activated ALT as `addressLookupTableAccounts: [alt]` in `TransactOptions`
31
+ 6. Retry ALT creation up to 3 times on "not a recent slot" errors (wait 2s between retries)
32
+ - If partial withdraw, save the change UTXO back to the UTXO file (overwrite with new change UTXO data)
33
+ - Print: `SENDER_WALLET=...`, `RECIPIENT_WALLET=...`, `AMOUNT_BASE_UNITS=...`, `WITHDRAW_SIGNATURE=...`
34
+ - If change UTXO exists, print: `REMAINING_SHIELDED=<amount> base units`
35
+ - Call `process.exit(0)` on success, `process.exit(1)` on failure
36
+
37
+ 4. Install dependencies if not already present: `npm install @cloak.dev/sdk @solana/web3.js tsx` (add `@solana/spl-token` for SPL tokens).
38
+
39
+ 5. Run the script with the extracted parameters. Use `SOLANA_RPC_URL=https://api.mainnet-beta.solana.com`.
40
+
41
+ 6. After success, verify:
42
+ - `solana confirm <WITHDRAW_SIGNATURE> --url https://api.mainnet-beta.solana.com`
43
+ - Check recipient token balance: `spl-token balance --owner <RECIPIENT> <MINT> --url https://api.mainnet-beta.solana.com` (or `solana balance` for SOL)
44
+
45
+ 7. Report the payment result clearly.
46
+
47
+ ## Token Mints
48
+
49
+ - USDC: `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` (6 decimals)
50
+ - USDT: `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` (6 decimals)
51
+ - SOL: native (9 decimals, use `NATIVE_SOL_MINT` from SDK)
52
+
53
+ ## User Request
54
+
55
+ $ARGUMENTS
@@ -0,0 +1,54 @@
1
+ # Private Send via Cloak
2
+
3
+ You are helping the user send tokens privately on Solana using the Cloak SDK (`@cloak.dev/sdk`).
4
+
5
+ ## Instructions
6
+
7
+ 1. Read the Cloak docs starting at https://docs.cloak.ag/llms.txt and https://docs.cloak.ag/ai-tools/ai-integration to understand the SDK contract.
8
+
9
+ 2. Parse the user's request to extract:
10
+ - **token**: SOL or SPL token (e.g. USDC). Default to SOL if not specified.
11
+ - **amount**: in human units (e.g. "5 USDC" = 5_000_000 base units for USDC with 6 decimals, "0.1 SOL" = 100_000_000 lamports).
12
+ - **recipient**: the destination wallet public key.
13
+ - **sender keypair path**: the user must specify the path to a `.json` keypair file in their prompt. If not provided, ask for it. Use this path as `KEYPAIR_PATH` env var.
14
+
15
+ 3. Create exactly one script file in the current directory following the Cloak docs minimal script contract:
16
+ - For SOL: `send-sol-private.ts`
17
+ - For SPL tokens: `send-private-<token>.ts` (e.g. `send-private-usdc.ts`)
18
+ - CLI: `npx tsx <script> <recipientPubkey> <amountBaseUnits>`
19
+ - Env: `SOLANA_RPC_URL` and `KEYPAIR_PATH` only
20
+ - Parse recipient/amount from `process.argv`
21
+ - Use `transact()` then `fullWithdraw()` UTXO flow
22
+ - Keep `programId` as `CLOAK_PROGRAM_ID` internally
23
+ - Set `enforceViewingKeyRegistration: false`
24
+ - **For SPL token sends (not native SOL)**: You MUST pre-build an Address Lookup Table (ALT) before calling `transact()` and `fullWithdraw()`, because SPL transactions exceed Solana's 1232-byte legacy transaction limit. Use this pattern:
25
+ 1. Import `getShieldPoolPDAs` from the SDK and `getAssociatedTokenAddressSync` from `@solana/spl-token`
26
+ 2. Compute all known accounts: `SystemProgram.programId`, `SYSVAR_SLOT_HASHES_PUBKEY`, `SYSVAR_INSTRUCTIONS_PUBKEY`, `ComputeBudgetProgram.programId`, `programId`, pool PDAs (`pool`, `treasury`, `merkleTree`, `vaultAuthority`), pool vault ATA, payer ATA, `TOKEN_PROGRAM_ID`
27
+ 3. Create and extend ALT using `AddressLookupTableProgram.createLookupTable()` and `extendLookupTable()` in one transaction
28
+ 4. Wait for ALT activation: poll `getAddressLookupTable` up to 30 times with 500ms delay. Check activation with `result.value.isActive()` (method call, not property)
29
+ 5. Pass the activated ALT as `addressLookupTableAccounts: [alt]` in `TransactOptions` for both deposit and withdraw
30
+ 6. Retry ALT creation up to 3 times on "not a recent slot" errors (wait 2s between retries)
31
+ - Print: `SENDER_WALLET=...`, `RECIPIENT_WALLET=...`, `AMOUNT_BASE_UNITS=...`
32
+ - Print: `DEPOSIT_SIGNATURE=...` and `WITHDRAW_SIGNATURE=...`
33
+ - Call `process.exit(0)` on success, `process.exit(1)` on failure
34
+
35
+ 4. Install dependencies: `npm install @cloak.dev/sdk @solana/web3.js tsx` (add `@solana/spl-token` for SPL tokens).
36
+
37
+ 5. Run the script with the extracted parameters. Use `SOLANA_RPC_URL=https://api.mainnet-beta.solana.com`.
38
+
39
+ 6. After the script completes successfully, run verification:
40
+ - `solana confirm <WITHDRAW_SIGNATURE> --url https://api.mainnet-beta.solana.com`
41
+ - For SOL: `solana balance <RECIPIENT> --url https://api.mainnet-beta.solana.com`
42
+ - For SPL: `spl-token balance --owner <RECIPIENT> <MINT> --url https://api.mainnet-beta.solana.com`
43
+
44
+ 7. Report the results clearly.
45
+
46
+ ## Token Mints
47
+
48
+ - USDC: `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` (6 decimals)
49
+ - USDT: `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` (6 decimals)
50
+ - SOL: native (9 decimals, use `NATIVE_SOL_MINT` from SDK)
51
+
52
+ ## User Request
53
+
54
+ $ARGUMENTS
@@ -0,0 +1,53 @@
1
+ # Shield Tokens via Cloak
2
+
3
+ You are helping the user deposit tokens into Cloak's shielded pool using the Cloak SDK (`@cloak.dev/sdk`).
4
+
5
+ ## Instructions
6
+
7
+ 1. Read https://docs.cloak.ag/llms.txt and https://docs.cloak.ag/sdk/llms.txt to understand the SDK.
8
+
9
+ 2. Parse the user's request to extract:
10
+ - **token**: SOL or SPL token (e.g. USDC). Default to SOL if not specified.
11
+ - **amount**: in human units (e.g. "10 USDC" = 10_000_000 base units for 6-decimal USDC, "1 SOL" = 1_000_000_000 lamports).
12
+ - **sender keypair path**: the user must specify the path to a `.json` keypair file.
13
+
14
+ 3. Create exactly one script file in the current directory:
15
+ - Name: `shield-<token>.ts` (e.g. `shield-usdc.ts`, `shield-sol.ts`)
16
+ - CLI: `npx tsx shield-<token>.ts <amountBaseUnits>`
17
+ - Env: `SOLANA_RPC_URL` and `KEYPAIR_PATH` only
18
+ - Parse amount from `process.argv[2]`
19
+ - Use `transact()` with `externalAmount > 0` (deposit)
20
+ - **CRITICAL**: The padding/zero UTXO MUST use the same mint as the deposit. For SPL: `createZeroUtxo(USDC_MINT)`. For SOL: `createZeroUtxo()` or `createZeroUtxo(NATIVE_SOL_MINT)`. Mint mismatch causes proof generation failures.
21
+ - Keep `programId` as `CLOAK_PROGRAM_ID` internally
22
+ - Set `enforceViewingKeyRegistration: false`
23
+ - **For SPL token deposits (not native SOL)**: You MUST pre-build an Address Lookup Table (ALT) before calling `transact()`, because SPL deposits exceed Solana's 1232-byte legacy transaction limit. Use this pattern:
24
+ 1. Import `getShieldPoolPDAs` from the SDK and `getAssociatedTokenAddressSync` from `@solana/spl-token`
25
+ 2. Compute all known accounts: `SystemProgram.programId`, `SYSVAR_SLOT_HASHES_PUBKEY`, `SYSVAR_INSTRUCTIONS_PUBKEY`, `ComputeBudgetProgram.programId`, `programId`, pool PDAs (`pool`, `treasury`, `merkleTree`, `vaultAuthority`), pool vault ATA, payer ATA, `TOKEN_PROGRAM_ID`
26
+ 3. Create and extend ALT using `AddressLookupTableProgram.createLookupTable()` and `extendLookupTable()` in one transaction
27
+ 4. Wait for ALT activation: poll `getAddressLookupTable` up to 30 times with 500ms delay. Check activation with `result.value.isActive()` (method call, not property)
28
+ 5. Pass the activated ALT as `addressLookupTableAccounts: [alt]` in `TransactOptions`
29
+ 6. Retry ALT creation up to 3 times on "not a recent slot" errors (wait 2s between retries)
30
+ - After deposit, serialize the output UTXO using `serializeUtxo()` and save to `shielded-utxo.json` (JSON with hex-encoded bytes, amount, mint, index, and the UTXO keypair privateKey as hex for later spending)
31
+ - IMPORTANT: The saved file must contain everything needed to spend later: `{ utxoBytes: string, amount: string, mint: string, index: number, keypairPrivateKey: string }`
32
+ - Print: `WALLET=...`, `AMOUNT_BASE_UNITS=...`, `DEPOSIT_SIGNATURE=...`, `UTXO_FILE=shielded-utxo.json`
33
+ - Call `process.exit(0)` on success, `process.exit(1)` on failure
34
+
35
+ 4. Install dependencies: `npm install @cloak.dev/sdk @solana/web3.js tsx` (add `@solana/spl-token` for SPL tokens).
36
+
37
+ 5. Run the script with the extracted parameters. Use `SOLANA_RPC_URL=https://api.mainnet-beta.solana.com`.
38
+
39
+ 6. After success, verify:
40
+ - Confirm the deposit tx: `solana confirm <DEPOSIT_SIGNATURE> --url https://api.mainnet-beta.solana.com`
41
+ - Show the saved UTXO file exists and its contents (redact keypairPrivateKey in output)
42
+
43
+ 7. Report: "Your shielded balance is ready. Use `/cloak-pay` to spend from it."
44
+
45
+ ## Token Mints
46
+
47
+ - USDC: `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` (6 decimals)
48
+ - USDT: `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` (6 decimals)
49
+ - SOL: native (9 decimals, use `NATIVE_SOL_MINT` from SDK)
50
+
51
+ ## User Request
52
+
53
+ $ARGUMENTS
@@ -0,0 +1,59 @@
1
+ # Private Swap via Cloak
2
+
3
+ You are helping the user privately swap SOL into an SPL token using the Cloak SDK (`@cloak.dev/sdk`).
4
+
5
+ ## Instructions
6
+
7
+ 1. Read https://docs.cloak.ag/llms.txt and https://docs.cloak.ag/sdk/llms.txt to understand the SDK. Pay special attention to section 6.6 (Swap SOL -> SPL).
8
+
9
+ 2. Parse the user's request to extract:
10
+ - **input amount**: SOL amount in human units (e.g. "0.05 SOL" = 50_000_000 lamports).
11
+ - **output token**: SPL token to receive (e.g. USDC, USDT). Default to USDC if not specified.
12
+ - **recipient**: wallet to receive the output tokens. If not specified, use the sender's own wallet.
13
+ - **sender keypair path**: the user must specify the path to a `.json` keypair file.
14
+ - **slippage**: in basis points. Default to 1500 (15%) for small amounts, 500 (5%) for larger amounts.
15
+
16
+ 3. Create exactly one script file in the current directory:
17
+ - Name: `swap-sol-to-<token>.ts` (e.g. `swap-sol-to-usdc.ts`)
18
+ - CLI: `npx tsx swap-sol-to-<token>.ts <recipientPubkey> <solLamports> [slippageBps]`
19
+ - Env: `SOLANA_RPC_URL` and `KEYPAIR_PATH` only
20
+ - Parse all args from `process.argv`
21
+ - Flow:
22
+ 1. Deposit SOL into shielded pool via `transact()` with `externalAmount > 0`
23
+ 2. Get Jupiter quote via `@jup-ag/api` (`createJupiterApiClient().quoteGet(...)`)
24
+ 3. Call `swapWithChange()` with the shielded UTXOs, swap amount, output mint, recipient ATA, and minOutputAmount from Jupiter quote
25
+ - Use `getAssociatedTokenAddress` from `@solana/spl-token` for recipient ATA
26
+ - Keep `programId` as `CLOAK_PROGRAM_ID` internally
27
+ - Set `enforceViewingKeyRegistration: false`
28
+ - Pass `swapSlippageBps`, `swapStatusMaxAttempts: 60`, `swapStatusDelayMs: 2000` in options
29
+ - Pass `recipientWallet` (the recipient's PublicKey) so relay can create ATA if missing
30
+ - Use `cachedMerkleTree` from deposit result for the swap call
31
+ - Print: `SENDER_WALLET=...`, `RECIPIENT_WALLET=...`, `INPUT_AMOUNT_LAMPORTS=...`, `OUTPUT_TOKEN=...`
32
+ - Print: `DEPOSIT_SIGNATURE=...`, `SWAP_SIGNATURE=...`, `SWAP_STATE_PDA=...`
33
+ - Call `process.exit(0)` on success, `process.exit(1)` on failure
34
+
35
+ 4. Install dependencies: `npm install @cloak.dev/sdk @solana/web3.js @solana/spl-token @jup-ag/api tsx`
36
+
37
+ 5. Run the script with the extracted parameters. Use `SOLANA_RPC_URL=https://api.mainnet-beta.solana.com`.
38
+
39
+ 6. After success, verify:
40
+ - Check recipient token balance BEFORE running the script (or record it in the script before the swap)
41
+ - `solana confirm <SWAP_SIGNATURE> --url https://api.mainnet-beta.solana.com`
42
+ - Check recipient token balance AFTER: `spl-token balance --owner <RECIPIENT> <OUTPUT_MINT> --url https://api.mainnet-beta.solana.com`
43
+ - Calculate actual received = balance_after - balance_before
44
+ - Report the actual amount received (not the Jupiter quote estimate)
45
+
46
+ 7. Report the results clearly:
47
+ - Actual tokens received (balance diff, not quote)
48
+ - Effective rate = actual_received / input_SOL
49
+ - Note that Cloak charges a protocol fee (0.005 SOL fixed + 0.3% variable) on the withdrawal side of the swap
50
+
51
+ ## Token Mints
52
+
53
+ - USDC: `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` (6 decimals)
54
+ - USDT: `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` (6 decimals)
55
+ - SOL: native (9 decimals, use `NATIVE_SOL_MINT` from SDK, mint address `So11111111111111111111111111111111111111112`)
56
+
57
+ ## User Request
58
+
59
+ $ARGUMENTS