Skip to content

CLI Commands

This page is a compact reference for the main Targo CLI workflows.

Core Commands

CommandUse it for
targo initinitialize or refresh declarations and project state
targo installinstall Go packages and generate type declarations
targo buildcompile Targo to Go
targo checkrun type and config checks without emitting code
targo runbuild and run the project
targo testcompile and run tests
targo bindgenerate declarations for Go packages
targo generaterun configured generation workflows
targo agents-mdgenerate 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 install

Under the hood:

  • targo install <pkg> runs go get <pkg>, then invokes the binder to generate .d.ts declarations
  • 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.mod and installs declarations for all listed dependencies
  • Standard library packages use pre-bundled declarations — just import them directly and run targo init if missing

Common Workflows

First-time setup

bash
targo init
targo check
targo build

After adding a new Go dependency

bash
targo install github.com/some/package
targo check

After dependency or import changes

bash
targo init
targo check

Test iteration

bash
targo test --run <pattern>
targo test --bench <pattern>

Notes:

  • --run maps directly to go test -run=<pattern>.
  • --bench maps directly to go test -bench=<pattern>.
  • Both flags use Go test regex semantics, not shell globs.
  • --run filters which tests execute, but targo test still type-checks and compiles the project before invoking go test, so it is not the same as a file-scoped targo 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 --check

Practical Rules

  • Use check when you want diagnostics without codegen.
  • Use build when emitted Go output matters.
  • Use init after declaration-affecting changes.
  • Use agents-md to materialize version-matched agent guidance into a project.