CLI Commands
This page is a compact reference for the main Targo CLI workflows.
Core Commands
| Command | Use it for |
|---|---|
targo init | initialize or refresh declarations and project state |
targo install | install Go packages and generate type declarations |
targo build | compile Targo to Go |
targo check | run type and config checks without emitting code |
targo run | build and run the project |
targo test | compile and run tests |
targo bind | generate declarations for Go packages |
targo generate | run configured generation workflows |
targo agents-md | generate or refresh AGENTS.md and .targo-docs/ |
Installing Go Packages
targo install wraps go get and automatically generates .d.ts declarations so you can import Go packages from Targo source.
bash
# Install a single package
targo install github.com/fatih/color
# Install a package and all its sub-packages (recursive binding)
targo install github.com/cloudwego/kitex/...
# Or use --recursive flag
targo install --recursive github.com/cloudwego/kitex
# Install all dependencies from go.mod (no arguments)
targo installUnder the hood:
targo install <pkg>runsgo get <pkg>, then invokes the binder to generate.d.tsdeclarations- The
/...suffix (or--recursive) tells the binder to generate declarations for all sub-packages in the module, not just the root package - Without arguments, it reads
go.modand installs declarations for all listed dependencies - Standard library packages use pre-bundled declarations — just
importthem directly and runtargo initif missing
Common Workflows
First-time setup
bash
targo init
targo check
targo buildAfter adding a new Go dependency
bash
targo install github.com/some/package
targo checkAfter dependency or import changes
bash
targo init
targo checkTest iteration
bash
targo test --run <pattern>
targo test --bench <pattern>Notes:
--runmaps directly togo test -run=<pattern>.--benchmaps directly togo test -bench=<pattern>.- Both flags use Go test regex semantics, not shell globs.
--runfilters which tests execute, buttargo teststill type-checks and compiles the project before invokinggo test, so it is not the same as a file-scopedtargo check.- To run all benchmarks, use
targo test --bench .. - To focus on benchmarks without running ordinary tests, use the same pattern you would use with Go:
targo test --run '^$' --bench ..
Agent docs refresh
bash
targo agents-md
targo agents-md --checkPractical Rules
- Use
checkwhen you want diagnostics without codegen. - Use
buildwhen emitted Go output matters. - Use
initafter declaration-affecting changes. - Use
agents-mdto materialize version-matched agent guidance into a project.