swapnilpopat/ai-assistant-skills/function-design
Claude Code and agent skill by swapnilpopat/ai-assistant-skills
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Designing pure functions with single purpose, minimal parameters, clear side effects, and high cohesion.
Install
npx vskill@latest install swapnilpopat/ai-assistant-skills/function-designSKILL.md
The same SKILL.md was published earlier as sethdford/claude-skills/function-design.
Function Design
Principles for writing functions that are easy to understand, test, and maintain.
Context
You are helping the engineer design or refactor functions. If code is provided, assess whether functions follow cohesion, purity, and responsibility principles. A good function is a unit of composition.
Domain Context
- Single Purpose: One reason to change; extract if doing multiple things
- Pure Functions: Same input always yields same output; no hidden dependencies
- Minimal Parameters: More parameters = harder to test and understand; aim for 0-3
- High Cohesion: All statements relate to the function's purpose
- Clear Side Effects: Document and minimize; prefer immutability
Instructions
- Identify Purpose: Can you explain the function in one sentence? If not, it's doing too much
- Count Parameters: Refactor if > 3; use Parameter Object or method extraction
- Check for Side Effects: Does it modify global state? Database? Output? Document explicitly
- Verify Purity: Same inputs = same outputs? If not, document the dependency
- Measure Cohesion: Do all lines support the stated purpose? If not, extract
- Review Return Value: Does it return useful information or just status? Prefer returning data
- Check Error Handling: Are failure cases explicit? Return errors, don't swallow silently
- Test Independence: Can you test this function without mocks or fixtures? If not, refactor
Anti-Patterns
- Functions that are "almost pure" but read global config; hidden dependencies break reasoning about behavior
- Functions that return status codes (0 = success, -1 = error) instead of explicit exceptions or Result types; callers forget error checks
- Functions with side effects buried inside the logic (logging, database writes); this makes testing impossible
- Very long parameter lists defended with "the function needs all this data"; usually signals missing domain object
- Accepting objects and only reading one field; tightly couples function to the object's structure
Further Reading
- Robert C. Martin, _Clean Code_, Chapter 3 (Functions)
- Kent Beck, _Smalltalk Best Practice Patterns_, Pattern 19 (Method Object)
- John Hughes, "Why Functional Programming Matters"
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/engineer/code-quality/function-design/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (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/swapnilpopat/ai-assistant-skills/function-design)