Skip to main content

fp-enforcer

Version Python Dependencies Tests Paradigm Changelog

Real-time enforcement of the functional programming paradigm for agent-driven codebases. fp-enforcer ships a canonical rule set, a violation scanner, agent hooks, and skills that let coding agents enforce, validate, repair, and learn functional programming discipline on any project.

Install

Install the runtime once per machine from PyPI:

pipx install fp-enforcer
# or: uv tool install fp-enforcer

Then wire it into a project:

fp-enforcer wire --client cursor --dest /path/to/project
fp-enforcer wire --client all --dest /path/to/project
fp-enforcer unwire --dest /path/to/project

Update is a two-step remote refresh:

pipx upgrade fp-enforcer
fp-enforcer wire --client all --dest /path/to/project

Marketplace installs (agent-facing layer)

  • Claude Code: /plugin marketplace add theocarranza/fp-enforcer, then /plugin install fp-enforcer@fp-enforcer.
  • Codex: codex plugin marketplace add theocarranza/fp-enforcer, then codex plugin add fp-enforcer@fp-enforcer.
  • Cursor: via the Cursor Marketplace (pending listing).

Marketplace plugins deliver the skills and rules; the fp-wire skill then installs the runtime from PyPI and wires the project (hooks included).

What it does

Capability Mechanism
Enforce Vendor hooks (post-edit and completion gates) inject violation reports into the agent loop in real time.
Validate fp-enforcer validate lints files, unified diffs, or entire trees against machine-readable pattern packs.
Repair The fp-repair skill converts a validation report into an ordered, rule-linked fix procedure the agent executes.
Learn fp-enforcer learn detects FP libraries in a project (dartz, fpdart, rxdart, fp-ts, ...) and generates agent-facing knowledge profiles.
Assimilate fp-enforcer assimilate activates curated library/language-feature pattern packs detected in the project, gated by embedded self-tests.

Design

  • Generic sources, vendor adapters. Rules (fp_enforcer/rules/), pattern packs (fp_enforcer/rules/patterns/), and the Python core are vendor-neutral and ship inside the PyPI package. wire renders the vendor-specific harness (Cursor, Claude, Codex, Antigravity) into the target project. Nothing is ever written to host-global folders.
  • Stdlib only. The runtime is Python 3.10+ standard library, written in the functional style the product enforces: frozen dataclasses, pure functions, pattern matching, effects at the edges.
  • Skills follow the Agent Skills open standard; marketplace manifests are optional adapters (Claude Code, Codex, Cursor) on top of the PyPI distribution.

Wiring a project

fp-enforcer wire:

  1. Vendors the runtime into <dest>/.fp-enforcer/ (package, rules, launcher).
  2. Renders rules for the client (.cursor/rules/*.mdc, .agent/rules/*.md, ...).
  3. Merges hook wiring non-destructively into existing hooks.json / settings.json files (existing entries are preserved; ours are tagged by the .fp-enforcer/run_hook.py command and are idempotent).
  4. Records everything in <dest>/.fp-enforcer/install_manifest.json so unwire reverses only what was installed.

Validate and learn

# Scan paths (files or directories)
fp-enforcer validate path/to/lib

# Scan only the added lines of a diff
git diff | fp-enforcer validate --diff -

# Generate FP library knowledge profiles for agents
fp-enforcer learn --dest /path/to/project

# Activate curated pattern packs for detected FP libraries/features
fp-enforcer assimilate --dest /path/to/project

Suppressing a justified exception

Tripwire patterns can over-fire on constructs the rules themselves permit (e.g. CompositeSubscription.add, edge throws). Waive a pattern inline with a directive naming the pattern ids — on the violating line or the comment line directly above it:

// fp-allow: no-collection-mutation — disposal binding, fp-rxdart memory 1
composite.add(subscription);

Every suppression is grep-able (grep -r "fp-allow"), keeping exceptions explicit and auditable, as fp-core requires.

Layout

fp_enforcer/           python stdlib core: validate, hook_runtime, adapters, learn, install
fp_enforcer/rules/     canonical rule set (vendor-neutral markdown + manifest.json)
fp_enforcer/rules/patterns/  machine-readable violation patterns per language
fp_enforcer/skills/    fp-validate, fp-repair, fp-learn, fp-assimilate, fp-wire (SKILL.md)
hooks/hooks.json       plugin-level hook wiring template
tests/                 stdlib unittest suite
.github/workflows/     CI + tag-triggered PyPI release (trusted publishing)

Development

Run from a checkout without installing:

python3 -m unittest discover -s tests -v
python3 -m fp_enforcer validate .        # module form works from the repo root

The repository dogfoods itself: its own .cursor/ harness is generated by its own installer.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fp_enforcer-0.3.1.tar.gz (43.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fp_enforcer-0.3.1-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file fp_enforcer-0.3.1.tar.gz.

File metadata

  • Download URL: fp_enforcer-0.3.1.tar.gz
  • Upload date:
  • Size: 43.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fp_enforcer-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9b8798bf75e849fdd598372f5db1b6dd8d8c7bf8e9be3eaa36f952772ef99137
MD5 986ab54a081ba95c3f81e4effc588ee5
BLAKE2b-256 f9c580575a33baa3491c6098dc679e86353b032f5ac9c85ef32d4c195e2e1345

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_enforcer-0.3.1.tar.gz:

Publisher: release.yml on theocarranza/fp-enforcer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fp_enforcer-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: fp_enforcer-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fp_enforcer-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f3958aa6451abe0780d80a5a800074c1b515727cb3ba13251edfdaf6257d08a
MD5 3494badd1e5ab9b4fb89ca833b50692c
BLAKE2b-256 e79911c5aa135d8198d1f8195f55341e3fd88cba5d0cbae11b0992401de15227

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_enforcer-0.3.1-py3-none-any.whl:

Publisher: release.yml on theocarranza/fp-enforcer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page