Migration: dfx → icp CLI
Context
dfx is now considered legacy. The new officially supported CLI is icp (@icp-sdk/icp-cli).
Benefits of icp over dfx
| Feature |
icp |
dfx |
| Networks |
Project-local — each project has isolated local network |
Shared global network |
| Canister IDs |
Stored in .icp/data/ (committed to version control) |
Scattered in .dfx/ (gitignored) |
| Env vars |
ic_env cookie — no .env files needed |
Required .env files with CANISTER_ID_* |
| Identity |
icp identity default (one default) |
dfx identity use (switching confusion) |
| Build |
Official version-pinned recipes (e.g., @dfinity/rust@v3.2.0) |
Manual build steps, easy to misconfigure |
| Deploy |
icp deploy -e ic (cleaner) |
dfx deploy --network ic (legacy) |
| Local dev |
icp network start -d in project dir |
dfx start (global shared state) |
How to Leverage icp Improvements
1. Project-Local Networks
- Run
icp network start -d in each project directory
- No more collisions between projects using the same canister IDs
- Clean isolation for parallel development
2. Version-Pinned Recipes
Instead of manual build steps in dfx.json:
# icp.yaml
build:
recipe: @dfinity/rust@v3.2.0
This ensures reproducible builds across all environments.
3. Git-Friendly Canister IDs
Move from .dfx/ (gitignored) to .icp/data/ (should be committed):
# After first deploy, commit the generated IDs
.gitignore
- .dfx/
+ .icp/data/
Team members now share the same canister IDs automatically.
4. No More .env Files
Remove all CANISTER_ID_* from .env. The ic_env cookie handles this:
# Old (dfx)
source .env && dfx deploy
# New (icp)
icp deploy -e ic # cookie handles canister IDs
5. Simpler Identity Management
# Set once, use everywhere
icp identity default my_identity
# No more "which identity am I using?" confusion
Migration Steps
- Install icp CLI:
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
- Convert
dfx.json → icp.yaml (see docs)
- Update deploy scripts to use
icp commands
- Move canister IDs from
.dfx/ to .icp/data/ and commit
- Update CI/CD workflows
- Update documentation
Resources
Acceptance Criteria
Migration: dfx → icp CLI
Context
dfx is now considered legacy. The new officially supported CLI is
icp(@icp-sdk/icp-cli).Benefits of icp over dfx
.icp/data/(committed to version control).dfx/(gitignored)ic_envcookie — no.envfiles needed.envfiles withCANISTER_ID_*icp identity default(one default)dfx identity use(switching confusion)@dfinity/rust@v3.2.0)icp deploy -e ic(cleaner)dfx deploy --network ic(legacy)icp network start -din project dirdfx start(global shared state)How to Leverage icp Improvements
1. Project-Local Networks
icp network start -din each project directory2. Version-Pinned Recipes
Instead of manual build steps in dfx.json:
This ensures reproducible builds across all environments.
3. Git-Friendly Canister IDs
Move from
.dfx/(gitignored) to.icp/data/(should be committed):# After first deploy, commit the generated IDs .gitignore - .dfx/ + .icp/data/Team members now share the same canister IDs automatically.
4. No More .env Files
Remove all
CANISTER_ID_*from.env. Theic_envcookie handles this:5. Simpler Identity Management
Migration Steps
npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasmdfx.json→icp.yaml(see docs)icpcommands.dfx/to.icp/data/and commitResources
Acceptance Criteria
icp network start -dicp deploy -e <env>