init
Scaffold a project
CLI tools
The BlockML CLI is the toolchain for scaffolding, exploring, checking and compiling Blocks. Bootstrap a repo with npx @blockml/cli init, then invoke npx blockml from the project. BML stays the source of truth — companions such as TypeScript, HTML or XSD are derived.
npx blockml --help
Every command
These are the tools printed by npx blockml --help. Run npx blockml <command> --help for flags, defaults and constraints.
search
Where something is
scan
Which packages or types match
inspect
The Block already resolved
graph
How it connects
new
Create a Block .bml
validate
Parser + semantic check
compile
Render a target
transform
Run a ModelTransformation
Everyday workflow
Discover the model with the CLI first. Generic grep, find and file reads remain allowed — they are not the first way in.
- search / scan Find FQNs
- inspect Read the resolved Block
- graph See structure if needed
- edit BML Smallest change
- validate Check the model
- compile Update companions
Turn a folder into a project
Bootstrap a new repo with npx @blockml/cli init. Afterward use npx blockml. Empty folders get a Node.js package; existing package.json files are merged.
-
initScaffold a BlockML projectWrites a project Library and README for the package FQN, points package.json at that Library, and creates AGENTS.md and CLAUDE.md. Empty folders get package.json with @blockml/core and @blockml/cli. Existing package.json files are updated in place. Does not overwrite existing files. Does not run npm install unless --install is passed.
usage initnpx @blockml/cli init <package-fqn> [--src dir] [--install]New or existing folder examplenpx @blockml/cli init com.acme.testInstall immediately examplenpx @blockml/cli init com.acme.test --installThen validate examplenpm install && npx blockml validate
Find your way in the model
Use these four before opening files. The corpus is the same as validate --all.
-
searchFind FQNsFull-text search over the model. Use this when you know words but not the FQN. A missing or stale .blockml/search/ index is rebuilt automatically.
usage searchnpx blockml search <query> [--json] [--limit n]Find by words examplenpx blockml search lamp brightnessRebuild the index examplenpx blockml search index --force -
scanList packages or typesMatch PackageSelector or TypeSelector tokens. Not full-text search — no score and no index. Quote tokens that contain * or ** so the shell does not expand them. Multiple selectors are OR.
usage scannpx blockml scan package|type <selector>…Exact type examplenpx blockml scan type org.blockml.bml.core.BlockTypes in a package and below examplenpx blockml scan type 'org.blockml.bml.core.**'Direct child packages examplenpx blockml scan package 'org.blockml.bml.*' --json -
inspectResolved Block JSONWhen you already know the FQN, inspect returns compact JSON of the live Block — effective members included. Output is not a write format; do not round-trip it back to BML. Default depth is 1, cap is 3.
usage inspectnpx blockml inspect <fqn> [--depth n]Inspect a type examplenpx blockml inspect org.blockml.bml.core.BlockOne extra hop examplenpx blockml inspect org.blockml.bml.core.Block --depth 2 -
graphInheritance, uses, pathsAsk how Blocks connect. Prefer named operations over Cypher. Rebuild with graph index if the index is missing or stale. path follows outgoing authored edges; reverse questions use used-by.
usage graphnpx blockml graph uses|used-by|neighbors|ancestors|descendants|members <fqn>What this type uses examplenpx blockml graph uses org.blockml.bml.core.BlockWhat uses this type examplenpx blockml graph used-by org.blockml.bml.core.BlockRebuild the graph examplenpx blockml graph index --force
Create, check, compile
Edit BML first. Then validate. Then compile or update companions to match. Do not patch generated output to fix the model.
-
newCreate a BlockWrites a .bml file and exports it from the owning Library. Default baseType is org.blockml.bml.core.Block. Does not overwrite an existing file. Prefer existing Blocks over new duplicates.
usage newnpx blockml new <fqn> [--baseType FQN] [--is text]Create a type examplenpx blockml new com.example.bml.Lamp --is "A lamp with a brightness"Set the base type examplenpx blockml new com.example.bml.Lamp --baseType org.blockml.bml.core.Block -
validateParser + semantic checkOrdinary project work after edits. Default: project sources only, not npm. --all checks the entire reachable corpus, including npm — do not use it as the default after every edit. Validity is parse plus semantic validate; XSD is a compile target, not a checker.
usage validatenpx blockml validate [--all] [<file>]Project sources examplenpx blockml validateOne file examplenpx blockml validate blocks/com/example/bml/Lamp.bmlEntire corpus examplenpx blockml validate --all -
compileRender derived outputWhen a companion is a compile target, change BML first, then recompile. Built-in targets: blockdoc, xsd, fatblock. Custom targets come from targetPackages.
usage compilenpx blockml compile blockdoc|xsd|fatblock [--out dir]Blockdoc examplenpx blockml compile blockdocXSD schemas examplenpx blockml compile xsdFatBlock per package examplenpx blockml compile fatblock --per-package -
transformRun a ModelTransformationParent command; V1 defines apply only. The execution FQN is a pending one-shot, an available template, or a template outside _meta.transform. Only one transform may run at a time in the same Git worktree, and the worktree must be clean.
usage transformnpx blockml transform apply <execution-fqn> [--library path]Apply an execution examplenpx blockml transform apply com.example.bml._meta.transform.RenameTypeTarget Library.bml examplenpx blockml transform apply com.example.bml._meta.transform.RenameType --library ./blocks/com/example/bml/Library.bml
Shared flags
Most commands accept the same corpus and output flags. Exit 0 on success, 1 on diagnostic errors, 2 on usage or configuration errors.
-
--src dirSource directory override -
--libraries a,bExtra Library.bml seeds -
--jsonMachine-readable output -
--help / -hCommand help
Start with init
Run npx @blockml/cli init with a package FQN, then npm install && npx blockml validate. After that, npx blockml is the everyday CLI.