Skip to main content

findfmt Logo

CI Status CodeQL Analysis Documentation Status pre-commit.ci status Coverage OpenSSF Best Practices

PyPI Version Python Versions PyPI Wheel GHCR Container OpenSSF Scorecard License: MIT

uv Ruff Type-checked: ty Docstring Coverage: 100% Conventional Commits Accessibility WCAG 2.1 AA


A .gitignore-aware file discovery and classification suite that locates files by content format, shebang, and MIME tag for automated linting, formatting, and CI pipelines.

1. Why findfmt?

Unlike traditional find or globbing tools that rely strictly on file extensions, findfmt:

  • Understands file content: Identifies format by content, shebang (#!/usr/bin/env python3), and MIME types using the identify engine.
  • Respects Git: Traverses trees hierarchically while pruning .gitignore and .git/info/exclude paths early before descending into large directories (e.g. node_modules/, .venv/).
  • Deterministic: Always returns clean, relative, deterministically sorted paths optimized for subshells, xargs, and automation.

2. Installation

findfmt requires Python 3.11 or newer and is tested on Python 3.11 through 3.15 on Linux, macOS, and Windows. On Python 3.10, pin the 1.0 series with findfmt<1.1; see Upgrading to 1.1.

Run directly with uvx:

uvx findfmt --help

Install globally:

uv tool install findfmt

Or add to your project:

uv add findfmt

2.2. With pip

pip install findfmt

2.3. With Docker / Container

docker pull ghcr.io/bdperkin/findfmt:latest
docker run --rm -v "$(pwd)":/workspace -w /workspace ghcr.io/bdperkin/findfmt:latest -t python

3. Usage

3.1. Locate Files by Tag / Format

# Locate all Python files
findfmt -t python

# Locate all YAML and JSON files
findfmt -t yaml,json

# Locate shell scripts
findfmt -t shell

3.2. Shebang Filtering

# Locate files with bash shebang
findfmt --shebang bash

# Locate scripts executing with python
findfmt --shebang python

3.3. Pipe Safely to Linters and Tools

Use -0 for NUL-delimited output with xargs -0:

# Format discovered Python files
findfmt -t python -0 | xargs -0 ruff format

# Lint shell scripts with shellcheck
findfmt -t shell -0 | xargs -r -0 shellcheck

3.4. Inspect Tags & Summaries

# Print matched files and their classification tags
findfmt --list-tags -t python

# Print summary statistics to stderr
findfmt -s

3.5. Structured Data Serialization

Export discovery results to machine-readable formats for pipelines, analysis, and notebooks:

# Export JSON array of file metadata and filter with jq
findfmt -t python --format json | jq '.[] | .path'

# Stream NDJSON (one JSON record per line)
findfmt -f jsonl

# Generate clean YAML document
findfmt -t yaml -f yaml

# Generate Jupyter Notebook with pandas DataFrame ingestion
findfmt -f ipynb > discovery.ipynb

# Export CSV with header row and process with csvkit
findfmt -f csv | csvcut -c path,tags,size_bytes

# Render aligned CSV table in terminal
findfmt -f csv-table --table-style rounded

# Generate Markdown table
findfmt -t python -f markdown

3.6. File Metadata & Presentation Options

Inspect extended Unix-style attributes and customize file presentation:

# Print permissions, ownership, and human-readable sizes
findfmt -p -u -g -h

# Print modification timestamps, sizes, and file type classification indicators
findfmt -D -h -F

# View accumulated recursive directory disk usage in a hierarchical tree
findfmt --tree --du -h

# Print filenames in double quotes, escaping embedded quotes and non-printables
findfmt -Q -q

3.7. Command Aliases & Entry Points

findfmt installs dedicated executable wrappers for frequent operations:

Command Equivalent To Description
findfiles [PATHS...] findfmt --hidden Traverse all files including hidden files
findfilemime [PATHS...] findfmt --hidden --list-tags List files with MIME & format tags
findfilefmt [TAG] [PATHS...] findfmt --hidden --tag [TAG] Filter files by format tag
findshebang [INTERPRETER] [PATHS...] findfmt --hidden --shebang [INTERPRETER] Filter scripts by shebang pattern
findfmt0 [PATHS...] findfmt --hidden --print0 NUL-delimited output for xargs -0
findsummary [PATHS...] findfmt --hidden --summary Output summary statistics to stderr

3.8. Programmatic Python Library Usage

Integrate findfmt directly into Python scripts and automated pipelines:

from findfmt import FileInfo, TraversalConfig, find_files, get_formatter

# Configure traversal scope and format filtering
config = TraversalConfig(include_tags={"python"}, root_paths=["src"])

# Discover matching files as FileInfo objects
for file_info in find_files(config):
    print(f"{file_info.path}: {file_info.tags} ({file_info.size_bytes} bytes)")

# Format results using any built-in serializer (e.g. table, json, tree, yaml)
formatter = get_formatter("table")
print(formatter.format(find_files(config)))

4. CLI Options

Flag Description
-t, --tag, --type TAG Match files containing specified tag(s)
-e, --exclude, --exclude-tag TAG Exclude files containing specified tag(s)
--all-tags / --no-all-tags Require match against all include tags (AND logic)
--shebang INTERPRETER Match shebang interpreter name or pattern
--no-ignore / --ignore Toggle respecting .gitignore files
--gitignore-file PATH Apply a specific external ignore file across the traversal scope
--from-file, --fromfile PATH Read paths or directory listings from a file, or standard input with -
--offline Classify paths from --from-file input without inspecting the local filesystem
--hidden / --no-hidden Toggle inspecting hidden files and directories
-d, --dirs-only List directories only, suppressing regular file entries
-l, --follow-links / --no-follow-links Follow directory symlinks with loop detection
-x, --one-file-system Confine traversal to starting directory's filesystem device
-L, --max-depth LEVEL Restrict directory traversal descent to maximum depth level
--filelimit LIMIT Skip directories exceeding child entry count threshold
--prune Omit empty directories and directories with zero matching files
-P, --pattern PATTERN Match files against wildcard or glob pattern (supports multiple -P and |)
-I, --exclude-pattern PATTERN Exclude files against wildcard or glob pattern (supports multiple -I and |)
--ignore-case / --no-ignore-case Apply case-insensitive pattern matching across -P and -I
--match-dirs / --no-match-dirs Match directories against patterns; matched directories inherit to child files
--sort CRITERIA Sort entries by name, version, time/mtime, ctime, size, or none
-U, --unsorted Yield entries in raw filesystem order (equivalent to --sort=none)
--dirsfirst, --group-directories-first Group directories before files within each directory level
--filesfirst Group regular files before directories within each directory level
-r, --reverse Reverse the sort order (for example, oldest or smallest first)
-p, --permissions / --no-permissions Print file type and permissions in standard ls -l format
-u, --user / --no-user Print file owner username (or numeric UID)
-g, --group / --no-group Print file owner group name (or numeric GID)
--inodes / --no-inodes Print filesystem inode number (st_ino)
--device / --no-device Print filesystem device number (st_dev)
--size / --no-size Print file size in bytes (st_size)
-h, --human-readable / --no-human-readable Print sizes in human-readable format with binary IEC units (KiB, MiB, GiB, TiB)
--si / --no-si Print sizes in human-readable format with SI metric units (kB, MB, GB, TB)
--du, --accumulate-size / --no-du Recursively calculate and accumulate directory disk usage sizes
-D, --mtime / --no-mtime Print date and time of last modification (st_mtime)
--ctime / --no-ctime Print date and time of last metadata status change (st_ctime)
--time-format, --timefmt FORMAT Custom strftime timestamp format (implies -D)
-F, --classify / --no-classify Append classification indicator (* executable, / dir, @ link, = socket, | FIFO, > door)
-q, --hide-control-chars / --no-hide-control-chars Replace non-printable control characters in filenames with ?
-N, --literal / --no-literal Print non-printable characters literally without masking
-Q, --quote-name / --no-quote-name Enclose filenames in double quotes ("...") with backslash escaping
-f, --format FORMAT Output format (text, json, jsonl, yaml, ipynb, csv, csv-table, tsv, markdown, rst, table, tree, xml, html)
-J, --json / --no-json Render output as structured JSON records (equivalent to --format json)
-X, --xml / --no-xml Render output as a hierarchical XML document (equivalent to --format xml)
-H, --html BASEHREF Render output as an HTML5 document with hyperlinks prefixed by BASEHREF
--intro PATH Prepend a custom HTML fragment file before the listing in HTML mode
--outro PATH Append a custom HTML fragment file after the listing in HTML mode
-T, --title TITLE Set the document <title> and <h1> heading for HTML output
--nolinks / --no-nolinks Render paths as plain text instead of hyperlinks in HTML output
-o, --output PATH Write output to a file (atomically) instead of standard output
--csv-safe / --no-csv-safe Neutralize spreadsheet formula injection in CSV and TSV cells
--tree / --no-tree Toggle hierarchical directory tree view (equivalent to --format tree)
--table-style STYLE Border style (rounded, simple, minimal, double, heavy, markdown, ascii, cp437, square, grid)
--pager / --no-pager Toggle interactive paging (auto-pages on TTY when lines exceed terminal height)
-i, --no-indent / --indent Omit branch indentation in tree view and strip extraneous whitespace in structured formats
-A, --ansi-lines / --no-ansi-lines Use ANSI/VT100 line drawing escapes for tree indentation lines
-S, --cp437 / --no-cp437 Use CP437 console graphics line drawing characters for tree indentation lines
-C, --color / -n, --no-color Force enable or disable ANSI color output across all output channels
--absolute, --full-path / --no-absolute Toggle absolute vs relative output paths
--relative, --relative-path / --no-relative Prepend input search path prefix to relative output paths
--hyperlink / --no-hyperlink Wrap paths in OSC 8 terminal hyperlink escape sequences
--hyperlink-schema SCHEMA URI schema prefix for terminal hyperlinks (default file://)
--hyperlink-authority AUTHORITY Authority or hostname component for terminal hyperlinks
--list-tags / --no-list-tags Display identified classification and MIME tags alongside paths
-s, --summary / --no-summary Output summary frequency statistics to stderr
-0, --print0 / --no-print0 Delimit paths with a NUL (\0) byte for xargs -0
--exit-status / --no-exit-status Exit with status 1 when no files match (default: exit 0)
--config PATH Path to a custom user configuration file overriding default settings
--no-config Suppress discovery and loading of any configuration file
--show-config Display active configuration file and resolved configuration settings
--known-tags List all supported classification tags and exit
--locale, --lang <locale> Set display locale for localized messages and format strings (e.g. es, de, zh_CN)
-v, -V, --version Display version (--verbose adds runtime diagnostics)
--diagnostics Display runtime environment diagnostics and exit
--help-all Display comprehensive manual, env vars, and exit codes
--help Display the categorized help summary and exit
-- [PATHS...] POSIX terminator: treat following tokens strictly as paths

5. Development & Testing

This project enforces 100% test coverage and strict type checking:

# Clone the repository
git clone https://github.com/bdperkin/findfmt.git
cd findfmt

# Install dependencies with uv
uv sync --all-groups

# Run tests and verify 100% coverage
uv run pytest

# Run linting and typing
uv run ruff check
uv run ty check

# Run full verification suite
uv run python tools/verify_quality.py

6. Governance & Community

7. License

MIT License © 2026 Brandon Perkins.

Metadata

Release files for findfmt 1.1.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 findfmt 1.1.0
File Size Uploaded Provenance
findfmt-1.1.0.tar.gz 1.1 MB With provenance Details

Built distribution (wheel)

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

Total release size: 1.2 MB

Release files / findfmt-1.1.0.tar.gz

Download URL findfmt-1.1.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
9ad566a0ddcd2b31e5ce1ec31e37c3dcbec7b35277b505cd05140df2b9bae236
BLAKE2b-256 checksum
How to use checksums
4034685be81d7ec09160f69ea9dd21b1576b05299930d6dec4e37225ff77ccd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 24, 2026.

Transparency log

Release files / findfmt-1.1.0-py3-none-any.whl

Download URL findfmt-1.1.0-py3-none-any.whl
Size 138.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4028f658da4ac4bb5c85b870eab6c5c28b8529c7920e9869c7a1c38036506ff
BLAKE2b-256 checksum
How to use checksums
7d410f298695415f68cfe3fc8d6d921ef38dd6dafe9aabf74f8db38eb88a1710
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 24, 2026.

Transparency log

Security for findfmt 1.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

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

Select from 2 files

Attestation for findfmt-1.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 Oct 24, 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