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
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, thencodex 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.wirerenders 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:
- Vendors the runtime into
<dest>/.fp-enforcer/(package, rules, launcher). - Renders rules for the client (
.cursor/rules/*.mdc,.agent/rules/*.md, ...). - Merges hook wiring non-destructively into existing
hooks.json/settings.jsonfiles (existing entries are preserved; ours are tagged by the.fp-enforcer/run_hook.pycommand and are idempotent). - Records everything in
<dest>/.fp-enforcer/install_manifest.jsonsounwirereverses 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d73656a09234cb6cf95985cec8c0199df351d84993ad65ba1dbb02ee5a89e65
|
|
| MD5 |
348d133ab124446bf4616c685248a804
|
|
| BLAKE2b-256 |
5bcf1ad2ea4f19c10dd87b0373faf5a7c86d1bcf9a681f64c27d3debb3e2a2b3
|
Provenance
The following attestation bundles were made for fp_enforcer-0.3.0.tar.gz:
Publisher:
release.yml on theocarranza/fp-enforcer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fp_enforcer-0.3.0.tar.gz -
Subject digest:
1d73656a09234cb6cf95985cec8c0199df351d84993ad65ba1dbb02ee5a89e65 - Sigstore transparency entry: 2333076678
- Sigstore integration time:
-
Permalink:
theocarranza/fp-enforcer@7ec801fdf26463193682e1f2ff1001fba269dd16 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/theocarranza
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ec801fdf26463193682e1f2ff1001fba269dd16 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b46dc8d7a4874180df0621452b0a4954785fd2ee76c22b631f0f9baae13bb00
|
|
| MD5 |
d4257da06d8eb704f0b2884972173bbb
|
|
| BLAKE2b-256 |
9c295bc1ec52e6575a1007a3dbb860586bc45b66d4356581bf19bf0d680c94ca
|
Provenance
The following attestation bundles were made for fp_enforcer-0.3.0-py3-none-any.whl:
Publisher:
release.yml on theocarranza/fp-enforcer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fp_enforcer-0.3.0-py3-none-any.whl -
Subject digest:
5b46dc8d7a4874180df0621452b0a4954785fd2ee76c22b631f0f9baae13bb00 - Sigstore transparency entry: 2333076701
- Sigstore integration time:
-
Permalink:
theocarranza/fp-enforcer@7ec801fdf26463193682e1f2ff1001fba269dd16 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/theocarranza
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ec801fdf26463193682e1f2ff1001fba269dd16 -
Trigger Event:
push
-
Statement type: