CLI Reference

Every magiclock subcommand and flag in one place.

Everything is one command: magiclock <subcommand> [options]. magiclock --version prints the installed version; bare magiclock prints help.

activate

Authenticate and provision this machine. Idempotent — safe to run again.

FlagMeaning
--server URLLicense server URL (falls back to a saved session, then $MAGICLOCK_SERVER).
--token TOKENBearer token (falls back to a saved session, then $MAGICLOCK_TOKEN).
--with-tokenHeadless mode: read a portal-minted token from $MAGICLOCK_TOKEN or stdin.
--no-browserIf sign-in is needed, print a link + code instead of opening a browser.

status

Show this machine's account and activation state.

FlagMeaning
--offlineSkip the live server round-trip; report from local state only.

protect

Encrypt a .py file (or a directory, recursively) into a gated .pya.

shell
magiclock protect PATH [-o OUT] [--remove]
                  [--trial | --expires-in DURATION | --expires-at DATE]
                  [--bind-machine [--passphrase] | --passphrase | --emit-key]
FlagMeaning
PATHA .py file or a directory to protect recursively (.venv, venv, __pycache__, .git, dist, build are skipped automatically).
-o, --outOutput path (or output root, for directories).
--removeDelete the plaintext .py file(s) after encrypting.
--trialFixed 48-hour self-destruct — for demos.
--expires-in DURATIONStops decrypting after a duration (e.g. 30d).
--expires-at DATEStops decrypting on a date (e.g. 2026-12-31).
(no binding flag)Default: keyless portable — decrypts on any machine with magiclock installed; no lock, no secret.
--bind-machineMachine-locked artifact: decrypts only on this activated machine. Add --passphrase for a two-factor lock (machine and passphrase).
--passphraseUnlock with a passphrase ($MAGICLOCK_PASSPHRASE or a prompt) — portable on its own, second factor with --bind-machine.
--emit-keyPortable artifact unlocked by a generated key, printed for out-of-band distribution.

--trial/--expires-in/--expires-at are mutually exclusive with each other; --passphrase and --emit-key are mutually exclusive; --emit-key cannot be combined with --bind-machine.

protect-model

Encrypt a model or any other resource into a .enc envelope. Takes the same expiry and binding flags as protect (keyless portable by default, --passphrase/--emit-key, --bind-machine [+ --passphrase]), plus:

FlagDefaultMeaning
PATHThe file to encrypt.
-o, --out<path>.encOutput path.
--feature NAMEai_modelThe license capability required to unlock this artifact.
--removeoffDelete the plaintext file after encrypting.

build

Compile an app to a native binary, inserting the license gate into every module automatically. See Compiled Build for the full walkthrough.

FlagDefaultMeaning
entryEntry-point .py file.
-o, --output-dirdistBuild output directory.
--source-rootthe entry fileProject root to scan/transform.
--moduleonCompile to a single-file native extension.
--standaloneCompile to a self-contained app directory instead. Mutually exclusive with --module.
--no-compileoffScan + inject + embed only, skip the native compile.
--keep-tmpoffKeep the intermediate transform directory.
--model PATHnoneEncrypt and bundle a model (repeatable).
--model-lock-passphraseoffTwo-factor lock for bundled models (needs ≥1 --model and --bind-machine).
--model-trial / --model-expires-in / --model-expires-atnoneExpiry for bundled models — mutually exclusive with each other.
--bind-machineoffMachine-locked build: license gate compiled into every module; runs only under this machine's vault. Default (without it) is a portable build — no gate, runs anywhere, keyless models.
--passphrase / --emit-keyoffPortable builds only: bundled models use a passphrase-derived or generated shared key instead of the keyless default.

run

Run a .py or .pya, gate included.

FlagDefaultMeaning
entryThe file to run.
--app-version1.0.0App version, checked against any max_app_version your license sets.
--passphraseoffPrompt for a decryption passphrase (or read $MAGICLOCK_PASSPHRASE) — for portable or two-factor artifacts.
--key KEYPortable artifact decryption key (base64), or read $MAGICLOCK_DECRYPT_KEY.

deactivate

Remove this machine from your account.

FlagMeaning
--local-onlyClear the local vault without releasing the seat or revoking on the server.
--server URLServer URL for the release call.
--token TOKENBearer token for the release call.

skill

Install a Claude Code skill into this project so an AI coding agent (like Claude Code) knows how to protect it with MagicLock.

shell
magiclock skill [--dir DIR] [--force] [--print]
FlagMeaning
--dir DIRProject root to install into (default: the current directory).
--forceOverwrite an existing SKILL.md.
--printPrint the skill content to stdout instead of writing a file.

Writes .claude/skills/magiclock-protect/SKILL.md, which teaches the agent to pick a protection tier and drive protect/build correctly for your project.

completion

Print a shell tab-completion script.

shell
magiclock completion bash > /etc/bash_completion.d/magiclock
magiclock completion zsh  > "${fpath[1]}/_magiclock"