clean-code
The Foundation Skill. LLM Firewall + 2025 Security + Cross-Skill Coordination. Use for ALL code output - prevents hallucinations, enforces security, ensures quality.
What this skill does
<domain_overview>
# π‘οΈ CLEAN CODE: THE FOUNDATION
> **Philosophy:** This skill is the FOUNDATION - it applies to ALL other skills. Every piece of code must pass these gates.
**ALGORITHMIC ELEGANCE MANDATE (CRITICAL):** Never prioritize "clever" code over readable, intent-revealing engineering. AI-generated code often fails by introducing unnecessary abstractions or using vague naming conventions that obscure logic. You MUST use intent-revealing names for every variable and function. Any implementation that increases cognitive complexity without a proportional gain in performance or scalability must be rejected. Avoid "Hype-Driven Development"βproven patterns trump trending but unstable frameworks.
</domain_overview>
<iron_laws>
## π¨ IRON LAWS
```
1. NO HALLUCINATED PACKAGES - Verify before import
2. NO LAZY PLACEHOLDERS - Code must be runnable
3. NO SECURITY SHORTCUTS - Production-ready defaults
4. NO OVER-ENGINEERING - Simplest solution first
```
</iron_laws>
<security_protocols>
## π¦ PROTOCOL 1: SUPPLY CHAIN SECURITY
LLMs hallucinate packages that sound real but don't exist.
1. **Verify before import** - `npm search` or `pip show` for unfamiliar packages
2. **Prefer battle-tested** - lodash, date-fns, zod over obscure alternatives
3. **Check npm audit / pip-audit** before adding new dependencies
4. **Pin versions** in production - no `^` or `~` for critical deps
**2025 AI Package Risks:**
- Never import AI "wrapper" libraries without verification
- LLM SDKs: Use official only (openai, anthropic, google-generativeai)
- Vector DBs: Stick to established (pinecone, weaviate, chromadb)
## π PROTOCOL 2: SECURITY-FIRST DEFAULTS
**Frontend Security:**
| Forbidden | Required |
|-----------|----------|
| `dangerouslySetInnerHTML` | DOMPurify sanitization |
| Inline event handlers | Event delegation |
| `eval()`, `new Function()` | Static code only |
| Storing tokens in localStorage | httpOnly cookies |
**Backend Security:**
| Forbidden | Required |
|-----------|----------|
| `CORS: *` | Explicit origin whitelist |
| Raw SQL strings | Parameterized queries |
| `chmod 777` | Principle of least privilege |
| Hardcoded secrets | Environment variables + validation |
**API Security (2025):**
- Rate limiting on ALL public endpoints
- Input validation at the gate (Zod/Pydantic)
- Output sanitization for AI-generated content
- PASETO > JWT for new projects
</security_protocols>
<modularity_and_placeholder_rules>
## ποΈ PROTOCOL 3: NO LAZY PLACEHOLDERS
**Forbidden Patterns:**
```javascript
// β BANNED
// TODO: Implement this
// ... logic goes here
function placeholder() { }
throw new Error('Not implemented');
```
**Required:**
- Every function must be runnable
- If too complex, break into smaller complete functions
- "Hurry" is not an excuse - write minimal viable implementation
## π PROTOCOL 4: MODULARITY & STRUCTURE
**The 50/300 Rule:**
- Functions > 50 lines β Break down
- Files > 300 lines β Split into modules
**SOLID Principles:**
| Principle | Quick Check |
|-----------|-------------|
| **S**ingle Responsibility | Does this do ONE thing? |
| **O**pen/Closed | Can I extend without modifying? |
| **L**iskov Substitution | Can subtypes replace parent? |
| **I**nterface Segregation | Are interfaces minimal? |
| **D**ependency Inversion | Do I depend on abstractions? |
</modularity_and_placeholder_rules>
<complexity_and_dependencies>
## π― PROTOCOL 5: COMPLEXITY CAP
**Native First:**
```javascript
// β Don't install is-odd
npm install is-odd
// β
Use native
const isOdd = n => n % 2 !== 0;
```
**Anti-Patterns:**
- AbstractFactoryBuilderManager for simple functions
- 10 layers of abstraction for CRUD
- "Future-proofing" for requirements that don't exist
**YAGNI:** You Aren't Gonna Need It. Build for today's requirements.
## π PROTOCOL 6: DEPENDENCY HYGIENE
**Freshness Check:**
```bash
npm outdated # Check for updates
npm audit # Check for vulnerabilities
```
**The CVE Brake:**
- "Latest" is not always "Safest"
- If latest has Critical CVE β Rollback to last secure version
- Security > New Features
**2025 Recommended:**
| Category | Recommended |
|----------|-------------|
| Validation | zod, valibot |
| HTTP | ky, ofetch |
| State | zustand, jotai |
| ORM | drizzle, prisma |
| Auth | lucia, better-auth |
</complexity_and_dependencies>
<ai_era_protocols>
## π€ PROTOCOL 7: AI-ERA CONSIDERATIONS
**When Building AI Features:**
1. **Validate AI outputs** - Never trust raw LLM responses
2. **Rate limit AI calls** - Prevent cost explosions
3. **Sanitize before display** - AI can generate malicious content
4. **Log AI interactions** - For debugging and compliance
**When AI is Writing Code:**
1. **Verify imports exist** - AI hallucinates packages
2. **Check types are correct** - AI guesses at APIs
3. **Test edge cases** - AI misses boundary conditions
4. **Review security** - AI takes shortcuts
</ai_era_protocols>
<audit_and_reference>
## β
QUICK AUDIT CHECKLIST
Before committing ANY code:
- [ ] No hallucinated imports (verified packages exist)
- [ ] No security shortcuts (CORS, eval, hardcoded secrets)
- [ ] No lazy placeholders (// TODO, empty functions)
- [ ] Functions < 50 lines, files < 300 lines
- [ ] Dependencies audited (`npm audit` clean)
- [ ] Types are strict (no `any`)
---
## π CROSS-SKILL INTEGRATION
| When Using... | Clean Code Adds... |
|---------------|-------------------|
| `@frontend-design` | Security defaults, no eval, CSP awareness |
| `@backend-design` | Input validation, no raw SQL, Zero Trust |
| `@tdd-mastery` | No placeholders (tests enforce completeness) |
| `@planning-mastery` | Modularity guides task breakdown |
| `@brainstorming` | SOLID/YAGNI guide architecture decisions |
| `@debug-mastery` | Logging standards, no silent failures |
</audit_and_reference>
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts β single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score β₯ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.