kylesnowschwartz/simpleclaude/sc-think-functional
Claude Code and agent skill by kylesnowschwartz/simpleclaude
- community
Checking that the SKILL.md file is still in the repository.
Reframe code design through functional programming principles for agent-assisted development. This skill SHOULD be used when the user says "think functional", "think FP", "make this pure", "separate effects", "where should this side effect go", "this function does too much", "how should I structure this for agents", "make this easier to review", "reduce context needed", or when planning module structure, store design, or code that agents will write and humans will review. Applies FP discipline within any language to maximize agent effectiveness and human reviewability.
Install
npx vskill@latest install kylesnowschwartz/simpleclaude/sc-think-functionalSKILL.md
Think Functional
FP discipline for agent-assisted development. Not about switching languages — about structuring code so agents write it well and humans review it fast.
Why FP Matters for Agents
<thesis>
Agents are pattern matchers. They compress training data into a world model, then map between representations: f(pattern_in, context, constraints) => pattern_out. FP makes the patterns explicit.
| FP Property | Agent Benefit | Human Benefit | |
|---|---|---|---|
| Type signatures encode intent | One line = full context. Input, output, effects. No retrieval needed. | Skim signatures, skip bodies | |
| Pure functions are self-contained | Entire function is contiguous text. No hidden state to chase. | Trust pure code, scrutinize edges | |
| Composition is the architecture | Agents pattern-match the wiring, generate the parts | Review wiring, ignore parts | |
| Constraints prevent laziness | Can't introduce side effects where the type system forbids them | Structural enforcement, not convention |
</thesis>
The Reframe
When approaching any design decision:
Instead of: "What object/class should own this behavior?" Ask: "What's the pure transform, and where does the effect happen?"
Every function is one of three things:
| Type | What It Does | Who Reviews | Agent Writes Well? | |
|---|---|---|---|---|
| Pure transform | Data in, data out. No effects. | Skim or skip | Yes — self-contained, testable | |
| Effect at the edge | IO, network, DOM, persistence | Read every line | Needs guidance — effects are contextual | |
| Composition | Wires pure + edge together | This IS the architecture | No — human decides the wiring |
The Toolkit
Apply these operations to any code design problem:
<operations>
Separate: Pure from Impure
Ask: "If I deleted every side effect from this function, what computation remains?"
That computation is your pure core. Extract it. The side effects become a thin shell that calls the pure function and does IO with the result.
Push Effects Outward
Ask: "Can the caller handle this effect instead of the callee?"
Effects belong at the outermost layer possible. Pushing the read out of the callee turns the function pure and lets the caller — who already knows the context — supply the data.
Make Illegal States Unrepresentable
Ask: "Can the type system prevent this bug, or does it rely on runtime discipline?"
Three encodings cover most real bugs — branded types for confusable values, Result<T, E> for fallible computation, and exhaustive switch for finite sums.
Enforce Through Structure, Not Convention
Ask: "If an agent ignores my instructions, does the code still work correctly?"
Agents are lazy. They'll take shortcuts if shortcuts compile. Convention says "don't put side effects here." Structure says "this module physically cannot import the side-effect library." Prefer structure. Stack two real mechanisms — editor-time lint plus a build/CI graph check — so a violation fails before review.
The two configs below sketch the shape of those checks: a per-file glob, a list of forbidden imports, a list of forbidden globals, and a from/to graph constraint. Tooling syntax shifts between releases (ESLint v9 moved to flat config; the depcruise CLI changed across major versions), so verify the exact form against your toolchain's current docs rather than copy-pasting.
The naming convention (.pure.ts) and directory layout are organizational scaffolding — they give the lint and graph rules a stable target to match. Convention catches one agent on a good day; the lint rule catches every agent on every keystroke; the graph rule catches the violations that slip past lint and fails CI. Branded types do the same job at the value level — preventing pixel coords from reaching hex math without a runtime check.
Narrow the Interface
Ask: "What's the minimum this function needs to know?"
A function that takes the whole world hides its real input. Extract a pure core that names exactly what it consumes; let a thin shell handle the rest.
</operations>
Applied to Stores (Zustand, Redux, etc.)
State management is where FP discipline pays off most in frontend code:
| Rule | Why | |
|---|---|---|
| No side effects in actions | Actions become pure state transitions. Testable without mocking. | |
| No cross-store calls in actions | Wire cross-cutting concerns at the composition root. Stores stay independent. | |
| No persistence in store files | Extract to subscription files. Store logic is pure; persistence is an edge effect. | |
| No logging in actions | Event stores or subscriptions handle observability. Actions compute new state, period. |
Store action template:
Applied to Handlers
Handlers dispatch on message type and perform effects. Use dependency injection to keep them testable:
The handler factory is pure (given deps, returns a function). The deps are wired at the composition root. Testing injects mock deps without touching real stores.
File Organization
Make purity visible in the filesystem:
The .pure.ts suffix signals to both agents and reviewers: this file has no side effects, is enforced by linting, and can be trusted if the types check.
Review Protocol
When reviewing agent-written code through an FP lens:
- Architecture (composition): Read this carefully. Does the wiring make sense? Are effects at the edges?
- Edge functions (IO, DOM, network): Read every line. These are where bugs live.
- Pure functions: Check types match. Skim body. If types are right and tests pass, the implementation is almost certainly correct.
- Test summaries: Are edge cases covered? Are pure functions tested with property-based or example-based tests?
Time allocation: 60% on composition + edges, 30% on tests, 10% on pure function bodies.
Anti-Patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/sc-skills/skills/sc-think-functional/SKILL.md
Popularity
- Repository stars
- 103
- Repository forks
- 15
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kylesnowschwartz/simpleclaude/sc-think-functional)