Skip to main content

BytePlan

PyPI - Version PyPI - Python Version

Plan in code. Track in one place.

BytePlan is a source-first task tracker for Python projects. You write # TODO: where the work is, or leave a function unfinished, and BytePlan does the rest:

  • gives each obligation a permanent four-character ID, written back into the source (# TODO[7fa2]:)
  • keeps status, priority, owner, notes and history in a Git-versioned registry, .byteplan/tasks.json
  • reconciles the two on every scan

It never decides that work is done. If a TODO disappears, its task is marked missing, not resolved. Only you resolve tasks.

Status: alpha, in active development. Everything described here works today:

  • the CLI, scanner and registry, for Python, Markdown and JSON
  • Git integration: IDs added at commit time, staged and CI checks, and the registry merge driver
  • the committed byteplan.md task list
  • decorator mode (byteplan sync)
  • the Hatch hook

Test linking and verification, test scaffolding, release stripping and an MCP server are planned. See the implementation plan and the changelog.

Contents

Installation

pip install byteplan

BytePlan needs Python 3.11+ and has one runtime dependency, pathspec. The optional byteplan-runtime package (Python 3.8+, no dependencies) provides the @todo and @verifies decorators. It's only needed if you use them.

Quick start

$ byteplan init                      # adds [tool.byteplan], creates .byteplan/tasks.json
$ byteplan scan --dry-run            # preview: nothing is written
$ byteplan scan                      # write IDs into source and update the registry
BytePlan: 3 files scanned
  3 annotations · 3 tracked tasks
  +3 added · ~0 relocated · !0 missing · !0 duplicate · 0 stale

Annotated:
  + [33b4] TODO  src/pkg/rip.py:2  Implement route poisoning
  + [dc20] FIXME src/pkg/rip.py:5  ARP entries outlive interfaces
  + [243a] TODO  src/pkg/rip.py:22  Implement Router.withdraw (detected stub)
$ byteplan list
$ byteplan edit 33b4 --priority high --assignee sam --label routing
$ byteplan status 33b4 in_progress
$ byteplan resolve 33b4 --note "shipped in 1.2"

Commit .byteplan/tasks.json along with your code. init keeps .byteplan/ out of Hatch sdists and ignores BytePlan's working files (.byteplan/txn/, .byteplan/scan.lock).

What BytePlan tracks

Tagged comments. TODO, FIXME, HACK and XXX (case-insensitive, configurable) at the start of a comment. An indented comment line directly below becomes the description:

# TODO: Implement route poisoning
#   Support split horizon and poisoned reverse.
  • Continuation lines: a line continues the description only if it's directly below, in the same column, and has at least two spaces after #. A blank line, code, another tag or an ordinary comment ends it.
  • Ignored on purpose: comments are found with tokenize, so strings, docstrings and commented-out code such as # x = f() # TODO are never tasks.
  • Trailing comments: x = 1 # TODO: ... counts too.

Unfinished implementations (stubs). These are found with ast:

  • functions and methods whose body is pass, ..., only a docstring, or raise NotImplementedError
  • empty classes

Excluded automatically:

  • @abstractmethod, @overload
  • Protocol classes and their methods
  • deliberately empty classes: exceptions, enums, TypedDict, NamedTuple

Interfaces and overrides aren't stubs. BytePlan looks at the whole project's class hierarchy:

  • Base-class interface methods: a base class method that raises NotImplementedError (or is pass/...) isn't reported when a subclass, at any depth, implements it.
  • No-op overrides: a method that overrides one inherited from a project base class isn't reported either.
  • Duck-typed hooks: a no-op that no shared base declares can't be told apart from unfinished work, so mark it # byteplan: ignore.

A stub that already has a TODO above it or inside it, or a @todo, is the same task, not a second one. Otherwise BytePlan adds # TODO[id]: Implement Router.withdraw (detected stub) above it. One-line stubs like def f(): pass are reported for review instead of edited. Mark intentional no-ops with # byteplan: ignore on the def or decorator line.

Decorators (optional, with byteplan-runtime):

from byteplan_runtime import todo

@todo("Implement poisoned reverse", tests=("tests/test_routing.py::test_poisoned_reverse",))
def advertise_routes(self):
    raise NotImplementedError
  • Runtime behaviour: the decorators do nothing at all; they return the function unchanged.
  • How BytePlan reads them: statically, never by importing your code, and adds id="…" on the first scan.
  • What counts: only names really imported from byteplan_runtime, or a shim module you list in runtime_modules. A local or shadowed todo is ignored.
  • No new dependency? byteplan init --runtime-shim src/pkg/_byteplan.py writes an inert todo/verifies module and registers it in runtime_modules.

Decorator mode: byteplan sync. With mode = "decorator", BytePlan can rewrite tasks into decorators for you. It's opt-in, and it's never done by scan:

[tool.byteplan.annotations]
mode = "decorator"
convert_attached_comments = true   # a tagged comment right above a def/class becomes @todo(...)
auto_decorate_stubs = true         # unowned stubs get @todo("Implement <name>", id=...)
$ byteplan scan                     # IDs first
$ byteplan sync                     # preview
  ~ [a83f] FIXME src/routes.py:9  comment -> @todo: Withdraw routes on link loss
  + [65ea] TODO  src/routes.py:14  @todo on stub Router.advertise: Implement Router.advertise
$ byteplan sync --apply             # write (journaled), update the registry
  • What converts: only a comment block that ends directly above a def or class, in the same column with no blank line, becomes @todo(title, id=..., kind=..., description=...), the outermost decorator. Module-level, trailing, in-body and separated comments stay comments and are reported as conversion_needs_review. --only ID limits the rewrite.
  • Runtime import: from byteplan_runtime import todo is added after the docstring and __future__ imports, but only if byteplan-runtime is in [project].dependencies or a configured shim exists. An existing import (or import byteplan_runtime as br) is reused.
  • Safe by construction:
    • Each file must parse to the same AST once BytePlan's own decorators and imports are removed, and must re-scan to the same tasks.
    • Shebangs, encoding cookies, BOM, CRLF and a missing final newline are kept.
    • Task IDs, kinds and descriptions never change.
  • Scan in preserve and decorator modes still writes IDs into comments, but it reports unowned stubs (stub_needs_review) instead of adding # TODO lines for them.

Markdown and JSON. Add them to include (for example "**/*.md", "config/**/*.json") and BytePlan tracks tags there too, with the same IDs, registry and Git integration:

<!-- TODO: Document the merge driver
     Show the .gitattributes line and a conflict example. -->
{
  // FIXME: Turn on strict mode once the legacy modules are typed
  "strict": false,
  "scripts": { "todo": "TODO: pin the release script's version" }
}
  • Markdown: tags in HTML comments, so they don't render. The first line is the title and the rest of the comment is the description. Prose and code (fenced blocks, inline code) are never scanned. The symbol is the nearest heading.
  • Fully hidden Markdown comments: [//]: # (TODO: title) is an unused link definition, so it's missing even from the generated HTML. Any label works, the title can use (), "" or '', and following [//]: # ( more) lines indented two spaces are the description. Like any link definition it can't interrupt a paragraph, so leave a blank line (or a heading) above it.
  • JSON (.json, .jsonc): // and /* */ comments, as in tsconfig.json. Strict JSON can't hold comments, so a string value that starts with TODO: (case-sensitive, colon required) is tracked too, and its ID goes inside the string. Turn that off with json_string_values = false. The symbol is a JSON Pointer such as /scripts/todo.
  • Not applicable: stubs and decorators are Python-only. Other file types are never scanned, even if include matches them.

Suppression.

  • # byteplan: ignore inside a tag comment skips that tag (in any format).
  • # byteplan: ignore-file in a file's first five lines skips the whole file (<!-- byteplan: ignore-file --> in Markdown, // byteplan: ignore-file in JSON).

Status, presence and resolution

Every task has two independent dimensions:

Values Changed by
status open, in_progress, blocked, resolved, dismissed only you: status, resolve
presence present, missing, unknown scans
  • Missing: when the annotation disappears, the task becomes missing and keeps its status and history.
  • Reappeared: if the annotation comes back (same ID), the task becomes present again.
  • Stale annotation: a resolved task whose annotation is still in source is reported, never removed for you.
  • implementation_changed: when a tracked stub gets a real body, BytePlan reports it once. It doesn't resolve the task.

IDs never change and are never reused. Line numbers, file paths and function names are only metadata, so moving or renaming code keeps the same task.

Commands

Command What it does
byteplan init [--runtime-shim PATH] add configuration and an empty registry (safe to re-run); optionally write an inert runtime shim
byteplan sync [--apply] [--only ID] decorator mode: rewrite attached comments and unowned stubs to @todo(...) (preview by default)
byteplan scan [PATHS] [--dry-run] [--staged] discover, add IDs, reconcile, report. With paths, the scan is narrowed and never marks anything missing. --staged --dry-run previews against the Git index
byteplan scan --staged --apply add IDs to the staged commit (index and working tree) before it's finalized; what the pre-commit hook runs
byteplan check [--staged | --commit REV] read-only validation, with policy-based exit code. --staged checks exactly what's staged (pre-commit); --commit HEAD checks a commit (CI)
byteplan list [--status S] [--presence P] [--kind K] list tasks
byteplan show ID details, location and history
byteplan status ID STATUS [--note] change lifecycle status
byteplan resolve ID [--note] mark resolved (never edits source)
byteplan edit ID [--priority] [--assignee/--unassign] [--label] [--remove-label] [--notes/--add-note] [--title/--clear-title] managed fields; scans never overwrite them
byteplan missing tasks no longer found in source
byteplan duplicates the same ID on more than one annotation
byteplan report [--format text|json|markdown] summary by status, presence, kind and priority, plus findings
byteplan repair --import ID register an ID found in source but not in the registry
byteplan repair --reassign PATH:LINE give a duplicated ID's copy a fresh ID
byteplan git install-merge-driver merge the registry by task ID in Git merges (per clone)
byteplan git install-hooks [--mode reconcile|check|scan] direct pre-commit hook (default reconcile: IDs at commit time); never replaces a hook it didn't write
byteplan git hooks-status show the pre-commit framework hook, direct hook and merge driver
byteplan merge-registry BASE OURS THEIRS [PATH] the merge driver itself; Git runs it, you don't
  • Common options: --project PATH and --format json go after the command.
  • Output streams: stdout carries only the result (pure JSON with --format json); diagnostics go to stderr.
  • Exit codes: 0 OK, 1 findings that fail your [tool.byteplan.check] policy (duplicate IDs by default), 2 errors (bad config, unreadable registry, a file that won't parse).

Configuration

Everything lives in pyproject.toml. These are the defaults:

[tool.byteplan]
registry = ".byteplan/tasks.json"
include = ["**/*.py"]         # add "**/*.md", "**/*.json", ... to track those too
exclude = ["**/.venv/**", "**/venv/**", "**/__pycache__/**", "**/build/**", "**/dist/**",
           "**/.tox/**", "**/.nox/**", "**/node_modules/**", "**/*.pyi"]
respect_gitignore = true
auto_annotate = true          # false: only track comments that already carry an ID
missing_policy = "warn"       # or "ignore"
report_file = ""              # e.g. "byteplan.md": a committed Markdown view of the registry

[tool.byteplan.detect]
todo_tags = ["TODO", "FIXME", "HACK", "XXX"]
pass_stubs = true
ellipsis_stubs = true
not_implemented_stubs = true
empty_classes = true
respect_overrides = true       # interface methods and no-op overrides aren't stubs (see below)
json_string_values = true      # JSON strings starting with "TODO:" are tasks

[tool.byteplan.check]
fail_on_duplicate_ids = true
fail_on_missing = false
fail_on_stale_annotations = false
fail_on_stale_report = false  # report_file not matching the registry is a warning by default

[tool.byteplan.annotations]
mode = "comment"                   # or "preserve" / "decorator" (see `byteplan sync`)
convert_attached_comments = false  # decorator mode: sync turns attached comments into @todo
auto_decorate_stubs = false        # decorator mode: sync puts @todo on unowned stubs
runtime_modules = ["byteplan_runtime"]   # add a project shim module here
  • Paths and patterns: paths are relative to the project root (the directory with pyproject.toml), not your current directory. Patterns use .gitignore syntax.
  • Strictness: unknown keys are errors, so typos don't silently do nothing.

Hatch integration

BytePlan ships a Hatchling build hook. Enable it in the project that uses BytePlan:

[build-system]
requires = ["hatchling", "byteplan"]
build-backend = "hatchling.build"

[tool.hatch.build.hooks.byteplan]
scan = true            # set false to disable without removing the table
write_source = false   # false | true | "editable"
fail_build = false     # fail the build on findings that fail [tool.byteplan.check]
allow_in_ci = false    # write_source still won't write when $CI is set, unless this is true
  • Read-only by default. A build runs byteplan check and prints its findings. Your checkout is never modified, so release builds and CI stay reproducible.
  • Writes are opt-in. With write_source = true, every local hatch build runs byteplan scan before packaging. New IDs land in your source, so you'll see Git changes after a build. That's the point of this mode, but don't enable it unless you want it.
    • write_source = "editable" writes only for editable installs (pip install -e, Hatch dev environments).
    • With $CI set, writes are refused unless allow_in_ci = true.
  • Building from an sdist: there's no registry in an unpacked sdist, so the hook does nothing.
  • Registry packaging: the hook warns if the sdist would include .byteplan/.
  • Without the plugin: examples/hatch_build.py is a minimal custom hook ([tool.hatch.build.hooks.custom]) that does the read-only check.
  • Without Hatch: byteplan scan and byteplan check work in CI, pre-commit hooks and editor tasks.

IDs at commit time

Install the hook once per clone, and every new TODO gets its ID as you commit:

$ byteplan git install-hooks
$ echo '# FIXME: Handle withdrawn routes' >> src/rip.py
$ git add . && git commit -m "Document route withdrawal bug"
byteplan: annotated 2 staged file(s)
  [a83f] FIXME src/rip.py:42  Handle withdrawn routes
$ git show HEAD:src/rip.py | tail -1
# FIXME[a83f]: Handle withdrawn routes

What it writes. Only BytePlan's own annotations ([id], id="…", stub comments) and .byteplan/tasks.json. They go into both the staged copy and your working tree, so nothing is left behind as an unstaged diff.

What it refuses. If a file has unstaged changes as well as staged ones (partial_stage_conflict), or the registry has unstaged edits, it writes nothing and the commit stops. It never stages anything you didn't, and never runs git add on your files.

If anything goes wrong mid-way, everything it changed is undone, and an interrupted run is finished or undone by the next one.

Commit modes:

  • git commit, -a, --include and --amend all work.
  • git commit <paths> uses a temporary index BytePlan can't safely update, so it only checks in that mode and tells you why.

Settings and alternatives:

  • Review first: set [tool.byteplan.git] on_reconcile = "stop" to review annotations before the commit proceeds.
  • pre-commit framework: the byteplan-reconcile hook works like a formatter. It annotates the files and fails, and after git add the next commit passes.

Git hooks and CI

The committed backlog should describe the committed code. Three read-only commands check that, with the same rules everywhere:

$ byteplan check --staged          # pre-commit: exactly what's staged, never the working tree
$ byteplan check --commit HEAD     # CI: the checked-out commit
$ byteplan scan --staged --dry-run # preview what the staged snapshot still needs

What fails a snapshot check:

  • a TODO without an ID (new_unregistered)
  • source staged without the updated registry (registry_not_staged)
  • a registry that doesn't reflect its code (registry_out_of_sync)
  • IDs that aren't registered anywhere

What doesn't: line numbers that merely shifted (position_drift) are informational.

How it reads the snapshot:

  • Git objects only. It never reads the working tree, so a broken unstaged file can't block a valid commit.
  • Read-only. It never changes .git/index, never runs your tests, and never imports your code.

Setup:

  • pre-commit framework: use the hook byteplan-check from this repository.
  • Direct hook: byteplan git install-hooks.
  • CI recipe: see docs/ci.md.

The hooks are a convenience and can be skipped with --no-verify; CI is where to enforce.

A committed task list: report_file

Set report_file = "byteplan.md" and BytePlan keeps a readable task list next to your code, with open work first and each location linked to the file and line. It's what reviewers and GitHub visitors see without installing anything.

  • Always current: it's rendered from the registry alone, and every command that writes the registry (scan, resolve, status, edit, repair) rewrites it. The commit hook (scan --staged --apply) stages it with the registry, so each commit carries a matching copy.
  • Checked: check --staged, check --commit and require_reconciled report report_out_of_sync when it doesn't match the registry. That's a warning unless fail_on_stale_report = true.
  • Merges: two branches both regenerate it, so a text merge would only conflict. byteplan git install-merge-driver also registers byteplan.md merge=byteplan-report, which keeps our copy. The next hooked commit, or byteplan scan, regenerates it from the merged registry; until then check warns that it's stale.
  • Generated, not scanned: the report file is never scanned for TODOs. Don't edit it by hand.

Merging the registry in Git

.byteplan/tasks.json is plain, deterministic JSON, so it diffs and reviews like code. Two branches that each add tasks would still conflict on the shared reserved_ids list under Git's text merge, so BytePlan ships a merge driver that merges by task ID:

$ byteplan git install-merge-driver
byteplan: added `tasks.json merge=byteplan` to .byteplan/.gitattributes (commit this file)
byteplan: set git config merge.byteplan.name (local to this clone)
byteplan: set git config merge.byteplan.driver (local to this clone)

What merges automatically:

  • Reserved IDs and tasks combine (IDs are never reused).
  • Both sides' history events are kept, in order.
  • Labels merge as a set.
  • Fields changed on only one side, such as status on one branch and priority on the other, take that side's value.

What it leaves to you. These fall back to Git's normal text merge with conflict markers, plus an explanation:

  • the same field changed differently on both sides
  • the same ID created on both branches for different work
  • a task removed on one side and changed on the other

If both branches moved the same annotation, the merged registry keeps our location and asks you to run byteplan scan, which refreshes it from the merged code.

Per clone, and safe to skip. Commit .byteplan/.gitattributes (and, with a report_file, the .gitattributes next to it). Each clone runs byteplan git install-merge-driver once, because Git doesn't version merge-driver configuration. A clone that hasn't installed the driver just gets Git's ordinary text merge. The driver is recorded as <this Python> -m byteplan, so it works even when Git runs outside your virtualenv; re-run the installer if you recreate that environment.

Linters

Ruff's flake8-todos rule TD004 ("missing colon in TODO") expects the colon directly after the tag, so it flags BytePlan's annotated form # TODO[a6b2]: .... Hatch's default ruff rules enable TD004. If you lint with them, ignore that one rule:

[tool.ruff]
lint.extend-ignore = ["TD004"]

Use lint.extend-ignore rather than extend-ignore. Hatch skips its default ruff configuration for a [tool.ruff] table containing a line that starts with extend. The other flake8-todos rules aren't affected.

Safety guarantees and tradeoffs

What BytePlan guarantees.

  • Scans are idempotent: a second scan of unchanged code changes nothing, not even timestamps.
  • Edits are minimal: each edit inserts only the ID text, and must leave the parsed program unchanged apart from added decorator id= keywords.
  • Encodings and formatting survive: BOMs, coding cookies, CRLF, tabs, shebangs and a missing final newline are all preserved byte-for-byte.
  • Writes are journaled and crash-safe: a multi-file update is staged under a lock and journaled before anything is replaced. Each file is replaced atomically with its permissions kept, and the registry goes last.
  • Interrupted writes finish safely: the next write command completes them. If a file was changed by something else in the meantime, BytePlan stops instead of overwriting it.
  • Failures stop the scan cleanly: a file that can't be read or parsed, or a directory that can't be listed, fails the whole scan before anything is reconciled.

Tradeoffs worth knowing.

  • No cross-file atomicity. Filesystems have no multi-file atomic rename. The journal guarantees completion (roll-forward), not that all files change at the same instant.
  • A small race window remains. Each file's content is re-checked immediately before it's replaced, but nothing portable can close the gap between that check and the rename.
  • Symlinks are never followed. That prevents scanning a file twice or reaching outside the project.
  • Only .gitignore files are honoured. .git/info/exclude and global Git excludes aren't read.
  • Stub detection is a heuristic. It reports candidates; # byteplan: ignore and the [tool.byteplan.detect] switches are there for intentional no-ops.
  • Duplicate IDs block all writes until you resolve them, so nothing ambiguous is ever rewritten.

License

byteplan is distributed under the terms of the MIT license.

Metadata

Release files for byteplan 0.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 byteplan 0.2.0
File Size Uploaded Provenance Actions
byteplan-0.2.0.tar.gz 194.1 kB Without provenance Details for byteplan-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for byteplan 0.2.0
File Interpreter ABI Platform Actions
byteplan-0.2.0-py3-none-any.whl Python 3 none any Details for byteplan-0.2.0-py3-none-any.whl

Total release size: 313.1 kB

Release files / byteplan-0.2.0.tar.gz

Download URL byteplan-0.2.0.tar.gz
Size 194.1 kB
Tags Source
SHA-256 checksum
How to use checksums
708c227b54cfed3e4f9f331a7ad330c24206440e337b9f97ad7092d6521e4704
BLAKE2b-256 checksum
How to use checksums
4f7297ddf029542871ef04897e9704e4c957aaeb5a0d11e704730f70e7da1eae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.0

Release files / byteplan-0.2.0-py3-none-any.whl

Download URL byteplan-0.2.0-py3-none-any.whl
Size 119.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9dad97bf0a02e34723710b261094093dcca8c280b0a2a268b34b427e76e88d31
BLAKE2b-256 checksum
How to use checksums
4887c057db58d07d9c0c02bd369cb83a37828a3b2a4b2d049818a8668c1dd110
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.0

Security for byteplan 0.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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