tellstrip
Code with no tells.
tellstrip finds the stuff AI assistants leave behind in Python code and removes
what it safely can. That means comments that narrate the next line
(# Loop through the items), chat residue (# Updated as requested), emoji,
# Example usage: blocks, and the hedging that comes from models being trained
to never crash: except Exception: return None, guessing at
customer_id / customerId, code that checks whether pytest is running.
It's a static tool. No AI APIs, no network, no dependencies outside the standard library. Checking a typical change takes under a second. The first run in a big repo takes longer, because the duplicate check fingerprints every function once (about 7 s for CPython's 2,000-file standard library, cached after that). A full scan of 300,000 lines of the standard library takes about 20 s.
The goal is code that's cheaper to read and maintain, not code that "passes" as human. tellstrip won't fake quirks or reshuffle whitespace. docs/research.md explains where each tell comes from and why the rules look the way they do.
Install
Python 3.11 or newer.
pip install tellstrip
# or the latest from GitHub:
pip install "tellstrip @ git+https://github.com/jam2342/tellstrip@main"
Use it
tellstrip # check the lines you've changed (staged, unstaged, untracked)
tellstrip --dry-run # same, plus a diff of what --fix would do
tellstrip --fix # apply the safe fixes in place
tellstrip --staged # check the lines about to be committed, as staged
tellstrip --since origin/main # check the lines this branch changed
tellstrip src/ scripts/x.py # check whole files
tellstrip --all # the whole project
The git modes only judge lines you added or changed. If you fix a typo in a
five-year-old file, you hear about your typo, not about the file's history.
Add --whole-file to see everything in the files you touched. Untracked files
count as entirely new.
Output looks like this:
orders.py:31:5: TS102 narration-comment comment repeats the line below it [fixable]
orders.py:42:12: TS303 guessing-fallback tries several keys ('customer_id', 'customerId') for one value; pick the real one
orders.py:54:9: TS301 swallowed-exception except Exception swallows the error, so callers can't tell failure from an empty result
Other formats: --format markdown (PR comments), --format github (inline
annotations in Actions), --format json.
Exit codes: 1 when there are fixable issues or errors (TS304) left,
0 otherwise. Warnings alone don't fail unless you pass --strict.
--exit-zero always returns 0, and 2 means tellstrip itself hit a problem
(bad config, unreadable file, a fix it refused to apply).
Rules
Run tellstrip --list-rules for the full list.
| Code | What it catches | Action |
|---|---|---|
| TS101 | Chat residue: # Step 1:, # Updated to use X, # as requested. "Now we..." / "Let's..." is flagged but kept |
fix |
| TS102 | A filler verb plus words the code already says: # Initialize the counter over counter = 0 |
fix |
| TS103 | Emoji in comments | fix |
| TS104 | Emoji in strings (log lines, CLI output) | warn, opt-in |
| TS105 | Placeholders: # TODO: implement, # In a real app you would... |
warn |
| TS201 | Docstring that only restates the name: """Get the user by id.""" |
warn |
| TS202 | Args/Returns docstring longer than the function it documents | warn |
| TS301 | Broad except that logs or returns None and carries on |
warn |
| TS302 | try around code that can't raise |
warn |
| TS303 | Guessing key spellings: d.get("user_id") or d.get("userId") |
warn |
| TS304 | Special-casing tests: if "pytest" in sys.modules, # hardcoded so the test passes |
error |
| TS305 | get_user = fetch_user aliases |
warn, opt-in |
| TS306 | try: import requests / except ImportError when requests is a required dependency |
warn |
| TS307 | Guards the code already rules out: isinstance(x, str) on x: str, if name is None on name: str, hasattr(self, "x") when __init__ always sets it |
warn |
| TS308 | A test that builds mocks, asserts on them, and never calls the code it's meant to test | warn |
| TS401 | Generic names: processed_list, data2 anywhere; data, result in long functions |
warn, opt-in |
| TS501 | A function that only forwards its arguments to another call, used once | warn, opt-in |
| TS502 | Constant used once | warn, opt-in |
| TS503 | A change that makes a file over max-file-lines (1,000) even longer |
warn, opt-in |
| TS601 | # Example usage: block at the end of a module |
fix |
| TS602 | if __name__ == "__main__": that only demos the module |
fix with --strip-main |
| TS701 | A function whose body already exists elsewhere in the repo, apart from names | warn |
Opt-in rules fire about as often on human code as on AI code, by the
benchmark. They can still be worth running as house style;
turn them on with extend-select.
What it leaves alone
Comments that explain why (because, so that, otherwise, workaround, a ticket
or URL), linter directives (noqa, type: ignore, pragma, fmt: off),
license and authorship headers, TODOs that say something specific, comments
that document a constant or attribute, and commented-out code (that's ruff's
ERA001). A __main__ block that reads sys.argv or calls main() is a
real entry point and isn't touched.
How fixes stay safe
Every fix is checked before it's written. tellstrip re-parses the result and compares its AST with the original. Removing comments must leave the AST identical; removing an example block must remove exactly those statements and nothing else. If either check fails, the file isn't written and you get an error. Example blocks are only removed when nothing above them uses a name they define. Encoding, BOM and line endings are preserved.
Run it before every commit
With pre-commit, add this to .pre-commit-config.yaml:
repos:
- repo: https://github.com/jam2342/tellstrip
rev: v0.1.0
hooks:
- id: tellstrip # blocks the commit on fixable issues in staged lines
# - id: tellstrip-fix # or: fix them automatically
# - id: tellstrip-files # whole files, for `pre-commit run --all-files`
Without the framework, use the plain git hook:
cp hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
It checks the staged version of each file (not your working copy) and blocks
the commit when there's something fixable. To clear it, run
tellstrip --staged --fix, then git add and commit again. tellstrip --staged --fix
won't touch a file that also has unstaged edits, so it can't mix them into the
commit. git commit --no-verify skips the hook once.
Run it on pull requests
tellstrip ships as a GitHub Action. It checks the lines each PR changes, adds
inline annotations, writes a job summary, and keeps a single comment on the PR
up to date with counts by rule, findings per file and the diff --fix would
apply. It never pushes changes.
name: tellstrip
on: pull_request
permissions:
contents: read
pull-requests: write
jobs:
tellstrip:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: jam2342/tellstrip@v0.1.0
with:
fail-on: none # or "fixable", or "any"
# args: --ignore TS202
Inputs: since (defaults to the PR's base branch), args (extra tellstrip
flags), comment (true), fail-on (none), python-version (3.12).
Outputs: findings and fixable counts.
GitHub shows at most 10 inline annotations of each kind per step, so tellstrip
uses all three kinds: errors for TS304, warnings for anything --fix can fix,
notices for judgement calls. If there are still more, a note says how many were
left out, and the comment lists everything. PRs from forks get a read-only
token, so there's no comment on those; the annotations and summary still show up.
Configure
In pyproject.toml (or a .tellstrip.toml without the [tool.tellstrip] header):
[tool.tellstrip]
exclude = ["migrations/", "vendor/", "*_generated.py"] # dirs end with "/"
ignore = ["TS202"] # skip rules (prefixes work: "TS2")
extend-select = ["TS401", "TS502"] # turn on opt-in rules
select = ["TS1"] # or run only these
generic-names = ["payload", "blob"] # more names for TS401
allowed-names = ["data"] # names TS401 should accept
strip-main = false # let --fix remove demo __main__ blocks
narration-threshold = 0.6 # how much of a comment the code must already say
max-file-lines = 1000 # TS503 limit
.venv/, node_modules/, build/, dist/, __pycache__/, *.egg-info/
and protobuf output are always excluded. Excluded paths stay excluded even when
you pass them by name.
To silence one line, add # tellstrip: ignore (every rule) or
# tellstrip: ignore[TS401,TS301] to it.
Limits
- Python only for now. JS/TS would need a real parser (tree-sitter) to tell comments from regex and template literals, so it's not a regex hack away.
- The rules are heuristics, and tellstrip is a linter, not an AI detector. bench/ measures each rule two ways. On raw model output (competitive-programming datasets) the gap is huge: narration comments are about 800x more common in AI code. On real merged commits it's much smaller, because people review and clean up what the model wrote. Across 2,800 commits, the default rules fire about twice as often on AI-labelled commits as on human commits from before AI assistants, and swallowed exceptions (TS301) about four times as often. Those numbers are also why six rules are opt-in.
- TS501/TS502 count names across the whole repo by plain word matching. That overcounts, so they miss some cases rather than flag code that's used elsewhere.
- TS306 reads
[project].dependencies, Poetry's dependencies andrequirements.txtat the project root. Optional extras and requirements with an environment marker don't count, and neither doesfrom pkg import name, since names move between versions. - TS307 trusts annotations it can see: builtins and classes in the same file.
A type alias imported from elsewhere might include None, so it's skipped.
assert isinstance(...)andif not isinstance(...): raise TypeErrorare deliberate (type narrowing, input validation), so they're left alone too. - TS503 needs a git scope (
--staged,--changed,--since), because "this change makes the file longer" means nothing for a plain path. - TS701 only catches copies that match once locals are renamed and the
docstring and annotations are dropped. A copy with one extra line, or a
different constant, slips through. Functions under 4 statements or 5 lines
don't count, and neither do test files, which repeat setup on purpose. It
only reports new or edited functions, but checking them means fingerprinting
the repo. The fingerprints are cached in
.tellstrip_cache/, which ignores itself in git. On CPython's standard library (1,836 files) a full TS701 scan takes about 19 s cold and 13 s warm, and finds 48 copies, all real.
Development
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/pytest
.venv/bin/tellstrip tellstrip/ # it should pass on its own code
To release: bump __version__ in tellstrip/__init__.py, tag vX.Y.Z, and
publish a GitHub release for the tag. release.yml
checks the tag matches the version, builds, and uploads to PyPI with trusted
publishing.
License
MIT. See LICENSE.
Metadata
Release files for tellstrip 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tellstrip-0.1.0.tar.gz | 60.7 kB | With provenance | Details for tellstrip-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tellstrip-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tellstrip-0.1.0-py3-none-any.whl |
Total release size: 116.9 kB
Release files / tellstrip-0.1.0.tar.gz
| Download URL | tellstrip-0.1.0.tar.gz |
|---|---|
| Size | 60.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
797b99bfd993cd1c61d6aa6bdef3cb8f29e0f5d82cc96f7e6d591dfe3d60c701
|
|
BLAKE2b-256 checksum How to use checksums |
8bb7c2a173f651ddb5e1802677f1d8a9d95e0aa4414e3178fee37d6f5a7dbf2c
|
| 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 Dec 5, 2026.
Transparency logRelease files / tellstrip-0.1.0-py3-none-any.whl
| Download URL | tellstrip-0.1.0-py3-none-any.whl |
|---|---|
| Size | 56.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3301dd78f1f71d978970edbba3c27b564635462eb92d2aa97525d948e0135a98
|
|
BLAKE2b-256 checksum How to use checksums |
ac73fc4c3d04b065aad88808c6c7768ea8df43c873885ccebb33f24af6e3eb44
|
| 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 Dec 5, 2026.
Transparency logSecurity for tellstrip 0.1.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
Both files in this release have been uploaded with provenance metadata.
Attestation for tellstrip-0.1.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 Dec 5, 2026.
Transparency logA 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.