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 and YAML, sections for Markdown, elements for HTML and XML; Markdown JSON dumps include inline nodes.
  • Raw tree-sitter queries when patterns are not enough.
  • 13 languages: Rust, Go, Python, TypeScript, TSX, JavaScript/JSX, Zig, Bash, JSON, YAML, 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 and all grammars are MIT as well; see vendor/tree-sitter/UPSTREAM for the one local patch.

Metadata

Release files for codeedit 1.0.1

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.0.1
File Size Uploaded Provenance Actions
codeedit-1.0.1.tar.gz 290.1 kB With provenance Details for codeedit-1.0.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for codeedit 1.0.1
File Actions
codeedit-1.0.1-cp313-abi3-win_amd64.whl CPython 3.13 abi3 Windows x86-64 Details for codeedit-1.0.1-cp313-abi3-win_amd64.whl
codeedit-1.0.1-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.0.1-cp313-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
codeedit-1.0.1-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 abi3 Linux glibc 2.17+ ARM64 Details for codeedit-1.0.1-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
codeedit-1.0.1-cp313-abi3-macosx_11_0_arm64.whl CPython 3.13 abi3 macOS 11.0+ ARM64 Details for codeedit-1.0.1-cp313-abi3-macosx_11_0_arm64.whl
codeedit-1.0.1-cp313-abi3-macosx_10_12_x86_64.whl CPython 3.13 abi3 macOS 10.12+ x86-64 Details for codeedit-1.0.1-cp313-abi3-macosx_10_12_x86_64.whl

Total release size: 12.6 MB

Release files / codeedit-1.0.1.tar.gz

Download URL codeedit-1.0.1.tar.gz
Size 290.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2cb113c73feaaa87f1b31a5a24703024a0ad236f50265fa88c1181f035312cd9
BLAKE2b-256 checksum
How to use checksums
1ab0fd22bf75ba42e1b8f3f06a5c9016609ae9c87c61b4af4015128851822eab
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 26, 2026.

Transparency log

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

Download URL codeedit-1.0.1-cp313-abi3-win_amd64.whl
Size 2.4 MB
Tags CPython 3.13 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
cc846e3dcf69867b369e30351fa30b7eb839da0dac1da00823f12d280bedbd78
BLAKE2b-256 checksum
How to use checksums
7105cf41c0edcc77a83883979078e57d24bee7fb1a23c81ff18a494d27a22282
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 26, 2026.

Transparency log

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

Download URL codeedit-1.0.1-cp313-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.6 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
3c21bf5c2d5437776dbb238e2b3ff5a2c9597d81ddc53deaf7f9336360087647
BLAKE2b-256 checksum
How to use checksums
fce006f3b4723a7bbd523003d51f25cacd434dab2188c2c9b5fb76f07390caa7
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 26, 2026.

Transparency log

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

Download URL codeedit-1.0.1-cp313-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.5 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
655cb3d8d3e33eb0d0201876ca52ffcd3aa0634a8ca1daad6eb9d7b7683ca34f
BLAKE2b-256 checksum
How to use checksums
cb7a97a175f3720521456efff87df79952a720283fd6e5fc08a30c1e3f609785
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 26, 2026.

Transparency log

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

Download URL codeedit-1.0.1-cp313-abi3-macosx_11_0_arm64.whl
Size 2.4 MB
Tags CPython 3.13 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4461c7970827c0ee38ca18a06f57eeec6af855fb67706d612be9007d30859c47
BLAKE2b-256 checksum
How to use checksums
f7daa435ef20c1026b1ea0ee97a56029ee6a9c2e33fdbcfdf5065b92786f0df1
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 26, 2026.

Transparency log

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

Download URL codeedit-1.0.1-cp313-abi3-macosx_10_12_x86_64.whl
Size 2.5 MB
Tags CPython 3.13 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
155fdfb63bf37615917ec4df7fcf03b662f488658eac7b1f7621b938f8e16116
BLAKE2b-256 checksum
How to use checksums
9b8c9aada613f4774e6b437aba7377958b3c058e388291a61a57c0a1d488d8b2
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 26, 2026.

Transparency log

Security for codeedit 1.0.1

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.0.1.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 26, 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