The Mimic CLI (@mimicprotocol/cli) is the main tool for scaffolding, building, and deploying functions. You use it via npx without a global install, or as a local dev dependency invoked through yarn mimic.
Recommended Agent Workflow
When an AI agent helps with Mimic projects, follow these defaults:
Always verify the CLI version first and prefer the latest release.
For new projects, always start with init instead of creating files manually.
1) Always use the latest CLI
Use the latest CLI when running ad-hoc commands:
npx@mimicprotocol/cli@latest<command>
If the project uses a local dev dependency, check and update it before continuing:
This avoids version drift across workspaces and prevents docs/code mismatches.
2) Start new projects with init
For new function projects, bootstrap with init first, even when working in multi-workspace setups:
npx@mimicprotocol/cli@latestinit [directory]
init creates the correct baseline (manifest.yaml, TypeScript setup, starter function, dependencies, and codegen). Manual scaffolding should be the exception, not the default.
Installation
No global install required. Run any command directly with npx:
Or add it as a local dev dependency and invoke it through yarn scripts:
Commands
init — Scaffold a new project
Creates a minimal project structure with a manifest file, a starter function, and all dependencies.
Option
Description
Default
directory
Where to initialize the project
./
--force, -f
Overwrite existing files (asks for confirmation)
false
Examples
Output structure
After scaffolding, the CLI automatically runs yarn install and yarn codegen.
codegen — Generate types from the manifest
Reads manifest.yaml and generates typed AssemblyScript interfaces for declared inputs and ABIs into src/types/.
Option
Description
Default
--manifest, -m
Path to manifest file
manifest.yaml
--output, -o
Output directory for generated types
./src/types
--clean, -c
Delete existing types before regenerating (asks confirmation)
false
Examples
Output
src/types/index.ts — Input parameter types
src/types/<ContractName>.ts — One file per ABI, with read/write methods and event decoders
Run codegen every time you change manifest.yaml. Generated files are meant to be committed — do not edit them manually.
compile — Build to WebAssembly
Validates the manifest and compiles your AssemblyScript function into a WASM binary.
Option
Description
Default
--function, -f
Path to entry file
src/function.ts
--manifest, -m
Path to manifest file
manifest.yaml
--output, -o
Output directory
build
Examples
Output
login — Save your API key locally
Stores credentials in ~/.mimic/credentials so you don't need to pass --api-key on every deploy.
Option
Description
Default
--profile, -p
Profile name
default
--api-key, -k
API key (skips interactive prompt)
—
--force-login, -f
Overwrite existing profile without confirmation
false
Examples
Retrieve your API key from the Mimic explorer under account settings. Profile names cannot contain [, ], or =.
logout — Remove stored credentials
profiles — List configured profiles
deploy — Upload to the Mimic Registry
Runs codegen + compile (unless skipped), uploads artifacts to IPFS, and registers the function in the Mimic Registry so relayers can discover it.
Option
Description
Default
--api-key, -k
API key
—
--profile, -p
Credential profile to use
default
--input, -i
Directory with compiled artifacts
build
--output, -o
Directory to write the CID file
build
--skip-compile
Skip codegen and compile
false
--url, -u
Registry base URL
https://api-protocol.mimic.fi
Examples
Before uploading, the CLI validates that build/ contains both manifest.json and function.wasm.
Output: build/CID.json — the IPFS Content Identifier for your deployed function.
test — Run function tests
Runs codegen + compile, then executes tests/**/*.spec.ts with Mocha.
Option
Description
Default
--directory, -d
Function directory to test
./
--skip-compile
Skip codegen and compile before tests
false
Multi-function projects (mimic.yaml)
For projects with more than one function, create a mimic.yaml at the project root. All commands (codegen, compile, test, deploy) will iterate over every function defined in it.
Filtering
mimic.yaml is optional — single-function projects can continue using individual command flags without it.
# New project in ./my-function
npx @mimicprotocol/cli@latest init ./my-function
# Reinitialize in an existing directory
npx @mimicprotocol/cli@latest init ./my-function --force
my-function/
├── manifest.yaml # Function metadata, inputs, and ABI references
├── package.json
├── tsconfig.json
└── src/
└── function.ts # Your AssemblyScript function
Configured profiles (stored in ~/.mimic/credentials):
* default (default)
* staging
* production
Use mimic deploy --profile <name> to deploy with a specific profile.
# Only run for specific functions
yarn mimic compile --include function-one function-two
# Run for all except one
yarn mimic codegen --exclude function-two
# Override the config file location
yarn mimic compile --config-file ./config/functions.yaml
# Ignore mimic.yaml entirely
yarn mimic compile --no-config --function ./src/function.ts