home / skills / splitleaseteam / splitlease_monorepo / fp-rater

fp-rater skill

/.claude/skills/fp-rater

This skill analyzes a code file for functional programming adherence and outputs a minimalist FP score out of 10.

npx playbooks add skill splitleaseteam/splitlease_monorepo --skill fp-rater

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.8 KB
---
name: fp-rater
description: |
  Automatically rates functional programming adherence after editing or creating code files. Use when: (1) A code file has been edited or created, (2) The file contains programming logic (JavaScript/TypeScript, Python, etc.). Output a minimalist rating table showing FP score out of 10.
---

# Functional Programming Rating

After editing or creating a code file, output a minimalist rating of its adherence to functional programming principles.

## When to Rate

Rate files containing programming logic after:
- Creating new code files
- Editing existing code files

Do NOT rate:
- Configuration files (JSON, YAML, etc.)
- Markup files (HTML, CSS, Markdown, .md files)
- Data files
- Documentation files

## Rating Criteria

Evaluate the file against these 7 principles (score out of 10):

1. **PURITY** - Pure functions (same inputs → same outputs, no side effects)
2. **IMMUTABILITY** - No mutations (use spread operators, return new values)
3. **EXPLICIT DEPENDENCIES** - Dependencies as parameters, not globals
4. **EFFECTS AT EDGES** - I/O and side effects at boundaries, not mixed with logic
5. **ERRORS AS VALUES** - Result/Either types instead of exceptions for expected failures
6. **DECLARATIVE STYLE** - map/filter/reduce over imperative loops
7. **COMPOSITION** - Small, focused, composable functions

## Scoring Guidelines

- **9-10**: Exemplary FP - follows nearly all principles
- **7-8**: Strong FP - follows most principles with minor violations
- **5-6**: Mixed approach - some FP patterns, some imperative
- **3-4**: Mostly imperative - minimal FP adherence
- **1-2**: Non-functional - direct violations of most principles

## Output Format

After completing file edits, append this exact table format at the bottom of your response:

```
Allegiance to Functional Programming
┌─────────────────────────┬───────┐
│ File                    │ Score │
├─────────────────────────┼───────┤
│ filename.ext            │ X/10  │
└─────────────────────────┴───────┘
```

Replace `filename.ext` with the actual file name and X with the numeric score. Include ONLY this table - no explanations, no breakdown, no additional commentary.

## Example

After editing `userService.ts`, append:

```
Allegiance to Functional Programming
┌─────────────────────────┬───────┐
│ File                    │ Score │
├─────────────────────────┼───────┤
│ userService.ts          │ 7/10  │
└─────────────────────────┴───────┘
```

Overview

This skill automatically rates how well a modified or newly created code file follows functional programming principles. It provides a concise numeric assessment so developers can quickly gauge FP adherence and decide if refactors are needed.

How this skill works

After a file containing programming logic is created or edited, the skill analyses the code against seven FP principles: purity, immutability, explicit dependencies, effects at edges, errors-as-values, declarative style, and composition. It computes a single FP score out of 10 and outputs a minimalist rating table referencing the file name and score.

When to use it

  • After creating a new code file with programming logic (JavaScript/TypeScript, Python, etc.)
  • After editing an existing code file that contains executable logic
  • When you want a quick, objective snapshot of FP adherence before a code review
  • As a gate check in developer workflows to spot large imperative patterns early
  • During refactors to measure improvement in FP characteristics

Best practices

  • Run only on source code files; skip configs, markup, documentation, and data files
  • Keep functions small and single-purpose to boost composition scores
  • Favor pure functions and return new data structures instead of mutating inputs
  • Isolate side effects at the application boundaries (I/O separate from core logic)
  • Use explicit parameters for dependencies rather than relying on globals
  • Represent expected failures as values (Result/Either) instead of throwing exceptions

Example use cases

  • Developer edits a service file and wants a quick FP compliance score before submitting a pull request
  • Automated check after saving a file to highlight when imperative patterns dominate
  • Measure FP improvements after a targeted refactor across utility modules
  • Spot regressions when integrating third-party code or legacy snippets into the codebase
  • Use in pairing sessions to teach FP trade-offs with immediate feedback

FAQ

Which file types are scored?

Files with programming logic such as JavaScript, TypeScript, Python, and similar languages are scored. Config, markup, data, and documentation files are ignored.

What does the score represent?

A single 0–10 score summarizing adherence to seven FP principles. Higher scores indicate stronger functional style across purity, immutability, composition, and related dimensions.