skills/fp-skills/skills/functional-coding/SKILL.md
Write and refactor code using functional programming principles for fewer bugs and less code. Language-agnostic (TypeScript, Python, Go, Rust, Java, etc.). Activate when writing new functions, refactoring existing code, reviewing code quality, fixing bugs caused by state mutation, building data pipelines, or when the user mentions functional programming, pure functions, immutability, composition, or side effects. Also activate when generating any non-trivial business logic to default to FP patterns.
npx skillsauth add olion500/skills functional-codingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
FP is a thinking style, not a language choice. Pure functions, immutable data, composition.
When writing or modifying code, always prefer:
| Instead of | Use |
|---|---|
| for loop with accumulator | map / filter / reduce |
| Mutating function arguments | Return new data (...spread, replace(), copy) |
| Class with internal state | Pure functions with explicit arguments |
| try/catch for control flow | Result/Either type (errors as values) |
| null/undefined checks | Option/Optional type or explicit union |
| Nested if/else chains | Pattern matching or rule tables |
| Callbacks mixed with logic | Pure core + thin I/O shell at boundary |
input type → output typethis/self, no external state reads, no I/O inside| What you see | Transform to | Prompt pattern |
|---|---|---|
| for loop with accumulator | reduce / comprehension | "Convert to reduce. Initial: X, accumulator: Y" |
| Object mutation in function | Spread/copy returning new object | "Convert to frozen dataclass / readonly" |
| Stateful class | Extract methods as pure functions | "Extract as pure function. Replace self with explicit args" |
| Boolean condition explosion | Rule table + any() / pattern match | "Convert to rule list + any()" |
| try/catch error handling | Result<T,E> return type | "Replace exceptions with Result: Ok(value) / Err(msg)" |
| .push() array building | map / filter pipeline | "Convert to map/filter chain" |
| Mixed I/O + logic | Separate pure core from I/O shell | "Extract pure logic, push I/O to boundary" |
Specificity raises AI success rate from 15.6% to 86.7% (ICSE 2025). Always name the target pattern.
if (x != null) / x?. to Option — adds ceremony without safety gainreduce when sum(), filter(), or map() alone is clearerval, err, Rust's ?, Python's comprehensions)When reviewing code (own or AI-generated):
For compact idiom reference per language, read references/patterns.md.
This skill sets FP defaults. For deeper patterns:
| Tier | Skill | Focus |
|------|-------|-------|
| T2 Core | fp-error-handling | Result/Either, railway-oriented, validation |
| T2 Core | fp-composition | Currying, pipe/flow, building utilities |
| T2 Core | fp-immutability | Immutable updates, lens patterns, readonly |
| T3 Advanced | fp-async-patterns | Lazy eval, async pipelines, retry/fallback |
| T3 Advanced | fp-architecture | Pure core/impure shell, state machines, memoization |
development
Search and query Elasticsearch/Kibana database models using curl API. Use for querying database models, searching Kibana indices, checking Elasticsearch data, investigating data in Kibana, finding records by ID, searching documents. Supports multiple environments (dev, qa, stage, production-us, production-au, production-eu).
development
Search and analyze Datadog logs and metrics using API for cupixworks-api and cupixworks-worker services. Use when debugging errors, investigating issues, searching logs, analyzing worker jobs, checking Sidekiq logs, querying metrics, or finding specific log entries by class/function names. Supports error/warn/info log levels with 14-day retention for logs.
tools
Create, update, search, transition, link, and read comments on Jira issues via CLI. MUST use this skill whenever the user pastes or mentions any atlassian.net URL (Jira issues, Confluence pages, focusedCommentId links, board links — anything from *.atlassian.net). Also use for: TSLA-* ticket references, JQL searches, issue status changes, reading comments, creating bugs, updating descriptions. This is the ONLY way to interact with Jira/Atlassian — there is no MCP Atlassian available.
development
Search Cupix Watch (Kibana/Elasticsearch) application logs at watch.cupix.com. Use when the user asks to search logs, find errors, debug processing issues, or investigate service behavior. Triggers on keywords like "log", "watch", "kibana", "error log", service names (skat, pano, api, worker, vista), or mentions of cupix processing pipelines.