smartedit is a small CLI for language-aware code exploration and compact source edits.
It is built primarily for AI-agent workflows: inspect code structure without reading full files, identify narrow edit targets, and apply small deterministic changes with less token usage than whole-file reads and rewrites. It is also useful for humans who want scriptable, narrow edits.
smartedit currently centers on three capabilities:
smartedit ast-printfor fast structural exploration of Rust, Python, JavaScript, TypeScript, Go, Java, C/C++, C#, Ruby, PHP, and more.smartedit applyfor compact line-, text-, and file-oriented editssmartedit install-skillfor installing the bundled agent skill
For command syntax and detailed manual usage, see docs/ast-print.md, docs/text-format.md, skill/SKILL.md, and smartedit --help.
Use smartedit when an agent or operator should:
- inspect file structure before reading full source
- locate whole-line edit ranges with
--loc, including warnings when items share boundary lines - scan signatures or docs across many files
- apply narrow edits instead of rewriting entire files
- bias an agent toward token-efficient exploration and editing in a repo
You can download a release binary from the latest Github release at: https://github.com/theduke/smartedit/releases
Install the prebuilt binary globally with mise, and automatically install the bundled user skill:
mise use --global --postinstall "smartedit install-skill --user" \
github:theduke/smartedit@latestOr add this to your mise.toml or global ~/.config/mise/config.toml, then run mise install:
[tools."github:theduke/smartedit"]
version = "latest"
postinstall = "smartedit install-skill --user"The tool's postinstall command writes the skill to ~/.agents/skills/smartedit/SKILL.md after each installation or upgrade, replacing the previous bundled skill. Omit the post-install hook to install only the CLI.
Install directly from Git:
cargo install --git https://github.com/theduke/smartedit --locked smartedit-cliInstall from a checkout:
cargo install --path .Install the default package from the flake:
nix profile install github:theduke/smarteditRun it without installing:
nix run github:theduke/smarteditThe repo ships a bundled smartedit skill for agent environments that support .agents/skills.
Install it for your user home:
smartedit install-skill --userInstall it for the current repository:
smartedit install-skill --repoInstall it into a specific directory:
smartedit install-skill --dir path/to/projectThis writes SKILL.md to .agents/skills/smartedit under the chosen root.
The intended loop is:
- Use
smartedit ast-printto get structure, signatures, docs, or line locations. - Decide on a small target span instead of editing a whole file.
- Use
smartedit applywith an inline edit program or.smeditfile.
Typical agent scenarios:
- A coding agent needs the outline of a Rust, TypeScript, or Go file before deciding what to read next.
- An agent finds a function with
--loc, then replaces only that function body. - An agent scans signatures across a glob to understand a subsystem without paying to read every file in full.
- A repo installs the bundled skill so agents default to
smarteditfirst and fall back only when needed.
GitHub Actions uses release-plz via .github/workflows/release-plz.yml.
Published CLI releases then trigger .github/workflows/release-binaries.yml to build and attach smartedit binaries for Linux, Windows, and macOS.
- On pushes to
main, it opens or updates a release PR with version/changelog changes. - If
CARGO_REGISTRY_TOKENis configured in repository secrets, it also runs publish/release. - The binary upload workflow listens for published releases, so
RELEASE_PLZ_TOKENmust remain a PAT instead of the defaultGITHUB_TOKEN.