sc-think-functional
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.
What this skill does
# 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.
```
BEFORE: fetchUser(id) { data = await fetch(url); return validate(data); }
AFTER: validateUser(data) { ... } // pure
fetchUser(id) { data = await fetch(url); return validateUser(data); } // edge
```
### 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.
```typescript
// BEFORE: callee reads localStorage; can't be tested without a DOM mock
function renderTheme(): string {
const prefs = JSON.parse(localStorage.getItem("prefs") ?? "{}");
return prefs.dark ? "dark" : "light";
}
// AFTER: caller reads, callee computes; pure function, trivial test
function renderTheme(prefs: { dark?: boolean }): string {
return prefs.dark ? "dark" : "light";
}
// at the edge:
const prefs = JSON.parse(localStorage.getItem("prefs") ?? "{}");
renderTheme(prefs);
```
### 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.
```typescript
// (a) Branded type + smart constructor — raw strings can't reach UserId-typed APIs
type UserId = string & { readonly __brand: "UserId" };
const UserId = (raw: string): UserId | null =>
/^u_[a-z0-9]{8}$/.test(raw) ? (raw as UserId) : null;
// (b) Result<T, E> — failure is in the return type, not in exceptions
type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };
const parseAge = (s: string): Result<number, "NaN" | "Negative"> => {
if (s.trim() === "") return { ok: false, error: "NaN" }; // Number("") === 0 — guard first
const n = Number(s);
if (Number.isNaN(n)) return { ok: false, error: "NaN" };
if (n < 0) return { ok: false, error: "Negative" };
return { ok: true, value: n };
};
// (c) Exhaustive switch — adding a new variant becomes a compile error
type Shape = { kind: "circle"; r: number } | { kind: "square"; side: number };
const area = (s: Shape): number => {
switch (s.kind) {
case "circle": return Math.PI * s.r ** 2;
case "square": return s.side ** 2;
default: { const _: never = s; throw new Error(`Unhandled: ${JSON.stringify(_)}`); }
}
};
```
### 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.
```jsonc
// .eslintrc.json — inside any *.pure.ts file, block effectful imports
// (modules) AND effectful globals (browser APIs the import rule cannot see).
{
"overrides": [
{
"files": ["**/*.pure.ts"],
"rules": {
"no-restricted-imports": ["error", {
"patterns": ["zustand", "zustand/*", "react", "react-dom",
"**/persistence/*", "**/effects/*"]
}],
"no-restricted-globals": ["error",
"localStorage", "sessionStorage", "fetch",
"document", "window", "navigator"
]
}
}
]
}
```
```js
// .dependency-cruiser.cjs — graph-level rule, run as part of CI. Fails the
// build when any *.pure.ts file pulls in an effectful package or a
// persistence/effect directory, even if lint was bypassed locally.
module.exports = {
forbidden: [
{
name: "no-effects-in-pure",
severity: "error",
from: { path: "\\.pure\\.ts$" },
to: { path: "(node_modules/(zustand|react|react-dom)|/persistence/|/effects/)" }
}
]
};
```
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.
```typescript
// BEFORE: 8 lines, mixes effect + computation, takes whole AgentState
function nextHexLabel(state: AgentState): string {
if (!state.selected) return "";
const hex = state.board.hexes[state.selected.hexId];
if (!hex) return "";
const n = hex.q + hex.r; // <-- the actual computation
return `${hex.q},${hex.r} (#${n})`;
}
// AFTER: pure core takes only what it needs; edge shell does the lookup
const formatHexLabRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.