# Apply Functional Patterns in TypeScript

Mutable logic and hidden side effects make Node.js services hard to test. This skill shows functional patterns for predictable TypeScript design.

## Install

```bash
npx skillstore add doubleslashse/functional-patterns
```

## Metadata

- Status: approved
- Slug: doubleslashse-functional-patterns
- Skillstore revision: r1
- Version status: missing
- Tree hash: 513c2ad200d262cfbc62d5456472c307ae0d49de19fd0f670183cef498a3a147
- Author: DoubleslashSE
- GitHub username: DoubleslashSE
- License: MIT
- Repository: https://github.com/DoubleslashSE/claude-workflows/tree/main/Plugins/node-tdd/skills/functional-patterns
- Ref: 72d5025b022c77f7a51bdf5c1637c689c80e89d1
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 78
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/doubleslashse-functional-patterns
- Manifest: https://skillstore.pages.dev/api/skills/doubleslashse-functional-patterns/manifest

## Capabilities

- Explains pure functions and the pure core, impure shell pattern.
- Shows immutable object and array update techniques for TypeScript.
- Demonstrates function composition, pipe helpers, and higher-order functions.
- Defines Result and Option patterns for typed errors and missing values.
- Shows dependency injection through function-based service factories and test doubles.

## Use Cases

- Refactor Service Logic: Separate business rules from I/O so service behavior is easier to test and review.
- Teach Testable TypeScript: Use concise examples to explain pure functions, immutability, and composition to a team.
- Design Error Handling: Model recoverable failures with Result and Option patterns instead of hidden exceptions.

## Prompt Templates

### Explain a Pattern

```
Explain the pure core, impure shell pattern for a TypeScript service. Include when to use it and common mistakes.
```

### Refactor a Function

```
Review this TypeScript function and suggest a functional refactor using pure functions and immutable updates: [paste function].
```

### Design a Result Pipeline

```
Design a Result-based pipeline for this request flow. Show validation, processing, formatting, and typed error boundaries: [describe flow].
```

### Review a Service Boundary

```
Analyze this Node.js service boundary for side effects, dependency injection, testability, and functional composition opportunities: [paste summary].
```

## Limitations

- Provides guidance and examples, not a runnable library or package.
- Examples assume TypeScript and Node.js service conventions.
- Does not benchmark performance or compare functional programming libraries.
- Requires adaptation to your domain types, error model, and testing framework.

## Best Practices

- Separate pure business rules from I/O before adding new abstractions.
- Use immutable updates when transforming shared domain objects.
- Model recoverable errors with Result or Option when callers must handle them.

## Anti Patterns

- Hiding database or network calls inside functions expected to be pure.
- Mutating request or domain objects in shared service code.
- Adding functional abstractions that obscure simple logic.

## Security Audit

- Audited at: 2026-07-06T11:24:53.948\+00:00
- Summary: All static findings are false positives caused by Markdown code fences, TypeScript template literals, and illustrative logging examples. No prompt injection, command execution intent, data exfiltration, or system reconnaissance behavior was found in SKILL.md.

## Stats

- Views: 237
- Downloads: 10
- Favorites: 0
- Popularity score: 0
