colref
Check whether a database column is still referenced in your codebase before you delete it.
Why
You want to remove a column from a long-running system. The column looks unused, but you're not sure. A full-text search returns hits inside comments, test fixtures, and migration history — noise that makes it hard to tell whether the column is actually read or written in live code.
colref scans your codebase with an AST parser, skips comments and string literals, and tells you where the column is referenced. If it finds nothing, you have a concrete starting point for the deletion decision. The final call is yours.
Installation
pip / pipx (Python users)
If you are working on a Django or Python project, the easiest way to install colref is via pip or pipx. No Go installation required.
pipx install colref
Or with pip:
pip install colref
| OS | x86_64 (Intel/AMD) | arm64 |
|---|---|---|
| macOS | ✓ | ✓ (Apple Silicon) |
| Linux | ✓ | ✓ |
| Windows | ✓ | — |
gem (Ruby users)
If you are working on a Rails or Ruby project, install via gem. No Go installation required.
gem install colref
Homebrew (macOS and Linux)
brew install shinagawa-web/tap/colref
If you prefer to tap first:
brew tap shinagawa-web/tap
brew install colref
One-line installer (Linux and macOS)
curl -fsSL https://raw.githubusercontent.com/shinagawa-web/colref/main/install.sh | sh
Manual download
Pre-built binaries are available on the releases page.
For full installation options, see Getting started.
Usage
colref check --orm <orm> --model <Model> --field <field> [path]
path is the project root to scan (default: current directory).
| Flag | Description |
|---|---|
--orm |
ORM type: django, rails (required) |
--model |
Model name to look up (required) |
--field |
Field name to search for (required) |
--format |
Output format: text (default), json |
Example:
$ colref check --orm django --model Page --field seo_title
Scanning 932 files...
References found for Page.seo_title
wagtail/admin/tests/pages/test_create_page.py:1867 page.seo_title
wagtail/admin/tests/pages/test_create_page.py:1892 page.seo_title
JSON output
Use --format json to emit a structured result you can pipe into other tools. In this mode stdout is pure JSON (no Scanning... preamble), so it is safe to pipe:
$ colref check --orm django --model Page --field seo_title --format json
{
"model": "Page",
"field": "seo_title",
"orm": "django",
"files_scanned": 932,
"reference_count": 2,
"references": [
{ "file": "wagtail/admin/tests/pages/test_create_page.py", "line": 1867, "text": "page.seo_title" },
{ "file": "wagtail/admin/tests/pages/test_create_page.py", "line": 1892, "text": "page.seo_title" }
]
}
When nothing is found, reference_count is 0 and references is an empty array [].
For ORM-specific behavior and more examples, see Django and Rails.
Limitations
colref uses static AST analysis and cannot detect every reference pattern. References where the field name is constructed at runtime (e.g. getattr(obj, field_name)) are out of scope by design.
If colref reports no references, treat it as "none found by the scanner" — not as a guarantee the column is unused.
For the full per-pattern breakdown, see Detection patterns and Limitations.
Roadmap
See issue #74.
License
MIT
Release files for colref 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| colref-0.9.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| colref-0.9.0-py3-none-manylinux_2_34_x86_64.whl | Python 3 | none | Linux glibc 2.34+ x86-64 | Details |
| colref-0.9.0-py3-none-manylinux_2_34_aarch64.whl | Python 3 | none | Linux glibc 2.34+ ARM64 | Details |
| colref-0.9.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| colref-0.9.0-py3-none-macosx_10_9_x86_64.whl | Python 3 | none | macOS 10.9+ x86-64 | Details |
Total release size: 21.8 MB
Release files / colref-0.9.0-py3-none-win_amd64.whl
| Download URL | colref-0.9.0-py3-none-win_amd64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
062abb9d9927fed019b1f7861815312cf22087da01f51189c6b608b101f31e16
|
|
BLAKE2b-256 checksum How to use checksums |
1bf52f559c186653123573093c4a9ae4eebee9c1c6a3af8d10c5e5ef0108145c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 2, 2026.
Transparency logRelease files / colref-0.9.0-py3-none-manylinux_2_34_x86_64.whl
| Download URL | colref-0.9.0-py3-none-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | Linux glibc 2.34+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
06809c074939286140c3626a59aecb7913662afdcab7bd950dfc9cd19a7f1f22
|
|
BLAKE2b-256 checksum How to use checksums |
6ab06d4e8a88d173a7557db913f7a0d5a951b30c17f3deda5488b8bf13e0884a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 2, 2026.
Transparency logRelease files / colref-0.9.0-py3-none-manylinux_2_34_aarch64.whl
| Download URL | colref-0.9.0-py3-none-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | Linux glibc 2.34+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
b9e9ca5c259dc4a9ef6ad6824fe001991703808d62d0e10db6de2eb32798be62
|
|
BLAKE2b-256 checksum How to use checksums |
d53530550d8de65d384cc8b69744df4fcf5162035507e8ea5f4ca03ff88a061d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 2, 2026.
Transparency logRelease files / colref-0.9.0-py3-none-macosx_11_0_arm64.whl
| Download URL | colref-0.9.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
084a8c6176aee5795b451e8bbbcb5abec9cab3207fa3ff010a146eccd2d45a5c
|
|
BLAKE2b-256 checksum How to use checksums |
9de7d1f892b7d968f88c877604d9f74d791fe5e1dc316e28fa09b95cac5a6380
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 2, 2026.
Transparency logRelease files / colref-0.9.0-py3-none-macosx_10_9_x86_64.whl
| Download URL | colref-0.9.0-py3-none-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | Python 3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
4d955b112d05f2315e1f4d03ab6e06943cd5db425dc257b1b07c1125d664aad0
|
|
BLAKE2b-256 checksum How to use checksums |
d5210f51f6dfd0a60a28d038d83b192242d29c3cd02810e899b17f8a4f725362
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 2, 2026.
Transparency log