A Claude Skill that teaches Claude (Claude Code, claude.ai, or the API) how to write correct confidential smart contracts with Fhenix CoFHE — first try, no leaked secrets, no ACLNotAllowed surprises.
FHE development is not normal Solidity with extra steps. It's a different programming model:
- Encrypted values are handles, not data
- Everything is async — results don't exist in the same transaction
- Access control is per-handle, and every operation creates a new handle with no permissions
- You cannot branch on encrypted data — no
if, norequire - Reverting on overflow would leak information, so arithmetic silently wraps
An AI assistant that doesn't know these rules will happily generate contracts that compile, deploy, and then either brick on the second transaction or quietly leak the secrets they were supposed to protect. This skill encodes the rules, the patterns, and the footguns so vibe-coding a confidential dApp actually works.
While stress-testing this skill against realistic builds, its own review checklist surfaced issues that (as of writing) aren't documented anywhere official:
- The handle-swap vulnerability — if your
publishDecryptResultwrapper accepts a ctHash as a parameter without binding it to the contract's stored handle, anyone can submit a valid Threshold Network signature for a different publicly-decryptable handle and swap your results (e.g., flip an election's yes/no tallies). Fix:require(euintXX.unwrap(param) == euintXX.unwrap(stored)). - The uninitialized-handle revert — a never-written
mapping(address => euint64)entry is handle0; any FHE op on it reverts. A new user's first interaction with your token bricks unless you guard reads with a pre-allowed encrypted ZERO fallback. - Modulo bias in the docs' own randomness recipe —
FHE.rem(random, N)is slightly biased unless N divides the type max. Fine for games, not for anything where uniformity is consequential.
All three are encoded as patterns in the skill.
cofhe-dev/
├── SKILL.md # mental model + 13-item gotcha checklist
└── references/
├── contract-patterns.md # FHE.sol: types, ops, ACL, decrypt flow,
│ # randomness, anti-patterns, 9-pt review checklist
├── client-sdk.md # @cofhe/sdk: setup, encrypt, decrypt, permits,
│ # async UX states, full cofhejs migration guide
└── setup-testing-errors.md # Hardhat/Foundry setup, mock-first workflow,
# all error families + "my decryption is stuck"
Covers the current stack: @cofhe/sdk 0.5.x (not deprecated cofhejs), the allowPublic + publishDecryptResult decryption flow (not deprecated FHE.decrypt), ERC-7984/FHERC20, and Sepolia / Arbitrum Sepolia / Base Sepolia.
# personal (all projects)
git clone https://github.com/interesting-guy/cofhe-dev-skill.git
cp -r cofhe-dev-skill/cofhe-dev ~/.claude/skills/
# or project-scoped (shared with your team via the repo)
cp -r cofhe-dev-skill/cofhe-dev your-project/.claude/skills/Then just ask: "build me a sealed-bid auction where bids stay encrypted" — the skill triggers automatically.
Download cofhe-dev.skill from this repo and upload it via Settings → Capabilities → Skills.
Load the cofhe-dev/ folder contents into your agent's skills directory per the Agent Skills docs.
The examples/ folder contains unedited outputs from skill test runs:
PrivateVote.sol— encrypted yes/no voting, tallies hidden until close, permissionless settlement, handle-binding fix appliedShieldedToken.sol— ERC20 shield/unshield wrapper with clamped confidential transfers and the two-phase unshield revealwitness-migration.ts— a real cofhejs → @cofhe/sdk migration
Found a case where Claude-with-this-skill got CoFHE wrong? That's the most valuable thing you can give this repo. Open an issue with the prompt, the wrong output, and what correct looks like. Field failures drive every release.
Not affiliated with or endorsed by Fhenix (just built by a badge holder who likes the tech). Example contracts are educational, not audited — don't deploy them to guard real value. CoFHE is testnet-only as of June 2026; APIs move fast, and the skill instructs Claude to verify against live docs when in doubt.
MIT