Skip to main content

Functional programming rule enforcement for AI coding harnesses: validation hooks, curated pattern packs, and agent skills for Cursor, Claude, Codex, and Antigravity.

Project description

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.

Project details


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.0.tar.gz (41.7 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.0-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fp_enforcer-0.3.0.tar.gz
  • Upload date:
  • Size: 41.7 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.0.tar.gz
Algorithm Hash digest
SHA256 1d73656a09234cb6cf95985cec8c0199df351d84993ad65ba1dbb02ee5a89e65
MD5 348d133ab124446bf4616c685248a804
BLAKE2b-256 5bcf1ad2ea4f19c10dd87b0373faf5a7c86d1bcf9a681f64c27d3debb3e2a2b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_enforcer-0.3.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: fp_enforcer-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 38.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b46dc8d7a4874180df0621452b0a4954785fd2ee76c22b631f0f9baae13bb00
MD5 d4257da06d8eb704f0b2884972173bbb
BLAKE2b-256 9c295bc1ec52e6575a1007a3dbb860586bc45b66d4356581bf19bf0d680c94ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_enforcer-0.3.0-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