.claude/skills/crane-deployment/SKILL.md
This skill should be used when the user asks about "create3", "deploy", "diamond factory", "package", "deterministic deployment", "cross-chain", "DiamondPackageCallBackFactory", "FactoryService", or needs guidance on deploying Diamond proxies and facets using Crane's factory system.
npx skillsauth add cyotee/crane crane-deploymentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Crane uses a two-factory system for deterministic cross-chain deployments of Diamond proxies.
Create3Factory # Deploys facets, packages, and any contract
└── DiamondPackageCallBackFactory # Deploys Diamond proxy instances from packages
In test setUp() or deployment scripts:
(ICreate3Factory factory, IDiamondPackageCallBackFactory diamondFactory) =
InitDevService.initEnv(address(this));
Use Create3Factory to deploy facets with deterministic addresses:
IFacet erc20Facet = factory.deployFacet(
type(ERC20Facet).creationCode,
abi.encode(type(ERC20Facet).name)._hash() // Salt from name hash
);
Deploy package with facet references in constructor:
IERC20DFPkg erc20Pkg = IERC20DFPkg(address(
factory.deployPackageWithArgs(
type(ERC20DFPkg).creationCode,
abi.encode(IERC20DFPkg.PkgInit({ erc20Facet: erc20Facet })), // Constructor args
abi.encode(type(ERC20DFPkg).name)._hash() // Salt
)
));
// Option A: Via package's deploy() helper
IERC20 token = erc20Pkg.deploy(diamondFactory, "Token", "TKN", 18, 1000e18, recipient, bytes32(0));
// Option B: Via factory directly
address proxy = diamondFactory.deploy(pkg, abi.encode(pkgArgs));
| Component | Purpose |
|-----------|---------|
| Create3Factory | Deploys any contract with deterministic addresses via CREATE3 |
| DiamondPackageCallBackFactory | Deploys Diamond proxies, calls initAccount() via delegatecall |
| IDiamondFactoryPackage | Interface for packages - bundles facets + initialization logic |
| InitDevService | Library to bootstrap the factory system in tests |
deployFacet()Deploy a facet (no constructor args):
IFacet facet = factory.deployFacet(
type(MyFacet).creationCode,
salt
);
deployPackageWithArgs()Deploy a package with constructor arguments:
IDiamondFactoryPackage pkg = IDiamondFactoryPackage(address(
factory.deployPackageWithArgs(
type(MyPkg).creationCode,
abi.encode(IMyPkg.PkgInit({ ... })), // Constructor args
salt
)
));
deploy()Deploy any contract:
address deployed = factory.deploy(
creationCode,
salt
);
Always derive salt from type name for deterministic addresses:
using BetterEfficientHashLib for bytes;
bytes32 salt = abi.encode(type(MyContract).name)._hash();
This ensures:
factory.deploy(pkg, pkgArgs)pkg.calcSalt(pkgArgs)MinimalDiamondCallBackProxy via CREATE2initAccount()pkg.initAccount() to initialize storagepkg.postDeploy() for any post-deployment hooksGroup related deployments in FactoryService libraries:
library MyFeatureFactoryService {
using BetterEfficientHashLib for bytes;
Vm constant vm = Vm(VM_ADDRESS);
function deployMyFacet(ICreate3Factory factory) internal returns (IFacet) {
IFacet facet = factory.deployFacet(
type(MyFacet).creationCode,
abi.encode(type(MyFacet).name)._hash()
);
vm.label(address(facet), type(MyFacet).name); // Always label!
return facet;
}
}
See references/factory-service-examples.md for complete examples.
contract MyTest is CraneTest {
IFacet myFacet;
IMyDFPkg myPkg;
function setUp() public override {
super.setUp(); // Initializes factories
// Deploy facet
myFacet = create3Factory.deployFacet(
type(MyFacet).creationCode,
abi.encode(type(MyFacet).name)._hash()
);
vm.label(address(myFacet), "MyFacet");
// Deploy package
myPkg = IMyDFPkg(address(
create3Factory.deployPackageWithArgs(
type(MyDFPkg).creationCode,
abi.encode(IMyDFPkg.PkgInit({ myFacet: myFacet })),
abi.encode(type(MyDFPkg).name)._hash()
)
));
vm.label(address(myPkg), "MyDFPkg");
}
}
references/factory-service-examples.md - Complete FactoryService examplesreferences/deployment-scripts.md - Production deployment script patterns/contracts/factories/create3/Create3Factory.sol - CREATE3 factory/contracts/factories/diamondPkg/DiamondPackageCallBackFactory.sol - Diamond factory/contracts/InitDevService.sol - Factory initialization/contracts/interfaces/IDiamondFactoryPackage.sol - Package interface with flow diagramdevelopment
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
documentation
Write to contracts and send transactions. Use when executing state-changing contract functions.
development
HTTP and WebSocket transports for blockchain connectivity. Use when configuring network connections.
data-ai
Read contract data with type-safe ABI. Use when querying smart contract view/pure functions.