Skip to main content

codeedit

codeedit

Structural code edits for coding agents: a better sed that reads the syntax tree.

CI release PyPI Python 3.13+ Rust 2024 MIT

Install · Usage · Python · Agent skill · Performance


Agents edit code with sed and hand-counted line ranges, and break it. codeedit parses the file with tree-sitter, finds code by symbol or by a pattern written as code, and applies the edit only if it is fresh, does not overlap another edit, and adds no syntax error. Every edit comes back as a unified diff. One Rust core sits behind the codeedit CLI and the codeedit Python package.

Highlights

  • Edit by symbol: replace, insert, delete, rename and add-import address Greeter.greet, impl Point or List.Push, with decorators, attributes and doc comments attached.
  • Edit by pattern: $E.unwrap() → $E? across a directory; $A matches one node, $$$A any number, where filters by regex or node type.
  • Safe by default: stale, overlapping or syntax-breaking edits are rejected; multi-file changes are written all or nothing.
  • Syntax tree as JSON: every node with type, field, position, byte range and text; also S-expression, XML and Graphviz.
  • Structure beyond code: outlines and key edits for JSON, YAML, TOML, INI, Nix and Terraform, sections for Markdown, elements for HTML and XML, tables and columns for SQL, rules for CSS; Markdown JSON dumps include inline nodes.
  • Raw tree-sitter queries when patterns are not enough.
  • 40 languages: Rust, Go, Python, TypeScript, TSX, JavaScript/JSX, Java, Kotlin, Scala, Swift, C, C++, C#, Dart, Ruby, Crystal, PHP, Lua, Elixir, Haskell, OCaml, Zig, Bash, SQL, Terraform/HCL, Nix, Protobuf, GraphQL, CSS, SCSS, JSON, YAML, TOML, INI, Dockerfile, Makefile, CMake, XML, HTML, Markdown.

Install

pip install codeedit                                            # Python package, abi3 wheels for 3.13+
cargo install --git https://github.com/4thel00z/codeedit codeedit-cli   # the `codeedit` binary

Prebuilt codeedit binaries for Linux, macOS and Windows are attached to every release.

Usage

codeedit outline src/app.py                          # classes, functions, methods as JSON
codeedit get     src/app.py Greeter.greet            # one symbol and its source
codeedit replace src/app.py Greeter.greet --body -c 'return f"hi {self.name}"'
codeedit insert  src/app.py Greeter.greet --position after -c 'def bye(self): ...'
codeedit delete  src/app.py old_helper
codeedit add-import src/app.py 'from pathlib import Path'
codeedit rename  src --from fetch --to load -n       # -n previews the diff

codeedit find    src -p 'print($$$ARGS)'             # matches and bindings as JSON
codeedit rewrite src -p '$E.unwrap()' -r '$E?'
codeedit query   src -q '(call_expression function: (identifier) @f)'
codeedit parse   src/lib.rs -f json                  # or sexp, xml, dot

Batches go in as JSON and are checked together before anything is written:

codeedit edit - <<'EOF'
[{"op": "replace_body", "file": "a.py", "symbol": "f", "code": "return 1"},
 {"op": "add_import", "file": "a.py", "import": "import os"}]
EOF

Python

import codeedit

tree = codeedit.parse("def f(): return 1", "python")            # syntax tree as dicts
codeedit.outline("src/app.py")                                  # symbols
codeedit.replace_body("src/app.py", "Greeter.greet", "return 'hi'")
codeedit.rewrite("src", "$E.unwrap()", "$E?", dry_run=True)     # list of {file, diff, ...}
change = codeedit.rewrite_source("foo(1)\n", "python", "foo($A)", "bar($A)")

Agent skill

.claude/skills/codeedit/SKILL.md teaches a coding agent every command and its pitfalls. Link it into your agent's skill directory:

ln -s "$PWD/.claude/skills/codeedit" ~/.claude/skills/codeedit

Performance

Release build on an Apple M3 Pro:

Task Time
Parse a 4,159-line Rust file and print the tree as JSON 20 ms
find '$E.unwrap()' over 120 files, 36k lines 20 ms
rewrite -n of 4,025 call matches over the same files 70 ms

Development

uv sync                                  # builds the extension into .venv
uv run pytest
cargo test --workspace --exclude codeedit-python
cargo clippy --workspace --all-targets -- -D warnings

CI runs clippy, tests on Linux and macOS, pytest, a wheel and a binary smoke test. Releases are cut by release-please from conventional commits: merging its release PR tags the version, attaches codeedit binaries, and publishes wheels to PyPI through trusted publishing.

License

MIT. The vendored tree-sitter runtime, the vendored Dockerfile and SCSS grammars and all other grammars are MIT as well; each vendor/*/UPSTREAM file lists the commit and local patches.

Metadata

Release files for codeedit 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codeedit 1.2.0
File Size Uploaded Provenance Actions
codeedit-1.2.0.tar.gz 412.1 kB With provenance Details for codeedit-1.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for codeedit 1.2.0
File Actions
codeedit-1.2.0-cp313-abi3-win_amd64.whl CPython 3.13 abi3 Windows x86-64 Details for codeedit-1.2.0-cp313-abi3-win_amd64.whl
codeedit-1.2.0-cp313-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 abi3 Linux glibc 2.17+ x86-64 Details for codeedit-1.2.0-cp313-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
codeedit-1.2.0-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 abi3 Linux glibc 2.17+ ARM64 Details for codeedit-1.2.0-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
codeedit-1.2.0-cp313-abi3-macosx_11_0_arm64.whl CPython 3.13 abi3 macOS 11.0+ ARM64 Details for codeedit-1.2.0-cp313-abi3-macosx_11_0_arm64.whl
codeedit-1.2.0-cp313-abi3-macosx_10_12_x86_64.whl CPython 3.13 abi3 macOS 10.12+ x86-64 Details for codeedit-1.2.0-cp313-abi3-macosx_10_12_x86_64.whl

Total release size: 34.6 MB

Release files / codeedit-1.2.0.tar.gz

Download URL codeedit-1.2.0.tar.gz
Size 412.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b7b1ffa258e55d1c90836e8856f6ec10560a1db79f153e00480ec119b8dc9e67
BLAKE2b-256 checksum
How to use checksums
57465ba4b79a9ec022a951943e3e0f9405498e1e21db32d2772dd1e4c131864a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / codeedit-1.2.0-cp313-abi3-win_amd64.whl

Download URL codeedit-1.2.0-cp313-abi3-win_amd64.whl
Size 6.7 MB
Tags CPython 3.13 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e687c8899c1508701a1bec399deb92ab60245395abb3948a1ebd31fe80671b9b
BLAKE2b-256 checksum
How to use checksums
0f4a25ab4c6a823bfd11140079d613f81c3ec22f4892c4bbcdc18272fc6cf18b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / codeedit-1.2.0-cp313-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL codeedit-1.2.0-cp313-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 6.9 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a0efe0639fa5ede9d674e105b818d9521b542b143f418d2dc845f93b02e43e44
BLAKE2b-256 checksum
How to use checksums
531b2162365594e757e24438a7299894a7347d5c2a278b29335e85476381b0d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / codeedit-1.2.0-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL codeedit-1.2.0-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 6.8 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
394aad69ac227677e50b23ae6786e398cd4d0a5b01c8047a766d26d8b7e70952
BLAKE2b-256 checksum
How to use checksums
1ecd6e6c0f9f4c6884c453dc953d851e855c1ad664f28a2abbe85c6092260d5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / codeedit-1.2.0-cp313-abi3-macosx_11_0_arm64.whl

Download URL codeedit-1.2.0-cp313-abi3-macosx_11_0_arm64.whl
Size 7.0 MB
Tags CPython 3.13 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6c5d2b09f53ae4b4de77c027b1b5d3268de08c45b5390504f14a2598575285ee
BLAKE2b-256 checksum
How to use checksums
adc086101f41f3fd327e8daf5f467892d52a00c3a1e055f315ed24ec250ffaac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / codeedit-1.2.0-cp313-abi3-macosx_10_12_x86_64.whl

Download URL codeedit-1.2.0-cp313-abi3-macosx_10_12_x86_64.whl
Size 6.8 MB
Tags CPython 3.13 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ff8f6686702aa60e44c0fe72b703418dac4bfdc48e8b59a7695c7889f753aa59
BLAKE2b-256 checksum
How to use checksums
8a232f51db2cd2226bbb652df22261e3ee0e1c746b4e6b3f09e785dea32668b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for codeedit 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for codeedit-1.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page