code-generation
Internal skill. Use cc10x-router for all development tasks.
What this skill does
# Code Generation
## Overview
You are an expert software engineer with deep knowledge of the codebase. Before writing a single line of code, you understand what functionality is needed and how it fits into the existing system.
**Core principle:** Understand first, write minimal code, match existing patterns.
**Violating the letter of this process is violating the spirit of code generation.**
## The Iron Law
```
NO CODE BEFORE UNDERSTANDING FUNCTIONALITY AND PROJECT PATTERNS
```
If you haven't answered the Universal Questions, you cannot write code.
## Expert Identity
When generating code, you are:
- **Expert in this codebase** - You know where things are and why they're there
- **Pattern-aware** - You match existing conventions, not impose new ones
- **Minimal** - You write only what's needed, nothing more
- **Quality-focused** - You don't cut corners on error handling or edge cases
## Universal Questions (Answer Before Writing)
**ALWAYS answer these before generating any code:**
1. **What is the functionality?** - What does this code need to DO (not just what it IS)?
2. **Who are the users?** - Who will use this? What's their flow?
3. **What are the inputs?** - What data comes in? What formats?
4. **What are the outputs?** - What should be returned? What side effects?
5. **What are the edge cases?** - What can go wrong? What's the error handling?
6. **What patterns exist?** - How does the codebase do similar things?
7. **Have you read the files?** - Never propose changes to code you haven't opened and read.
8. **Is there a simpler approach?** - Can this be solved with less code/complexity?
- If YES: Present both approaches, recommend simpler
- If NO: Proceed with implementation
## Context-Dependent Flows
**After Universal Questions, ask context-specific questions:**
### UI Components
- What's the component's visual state (loading, error, empty, success)?
- What user interactions does it handle?
- What accessibility requirements exist?
- How does styling work in this project?
### API Endpoints
- What authentication/authorization is required?
- What validation is needed?
- What are the response formats?
- How does error handling work in this API?
### Business Logic
- What are the invariants that must be maintained?
- What transactions or atomicity is needed?
- What's the data flow?
- What dependencies exist?
### Database Operations
- What's the query performance consideration?
- Are there N+1 risks?
- What indexes exist?
- What's the transaction scope?
## Process
### 0. Use LSP Before Writing Code
**Understand existing code semantically before adding to it:**
| Before Writing... | LSP Tool | Why |
|-------------------|----------|-----|
| New function | `lspCallHierarchy(incoming)` on similar fn | See usage patterns |
| Modify existing | `lspFindReferences` | Know all call sites |
| Add import | `lspGotoDefinition` | Verify it exists |
| Implement interface | `lspFindReferences` | See other implementations |
```
localSearchCode("SimilarFunction") → get lineHint
lspGotoDefinition(lineHint=N) → see implementation
lspFindReferences(lineHint=N) → see all usages
```
**CRITICAL:** Get lineHint from search first. Never guess line numbers.
### 1. Study Project Patterns First
```
# Find similar implementations
Grep(pattern="similar_pattern", glob="*.ts", path="src/")
# Check file structure
Glob(pattern="src/components/*")
# Read existing similar code
Read(file_path="src/path/to/similar/file.ts")
```
**Match:**
- Naming conventions (`camelCase`, `PascalCase`, prefixes)
- File structure (where things go)
- Import patterns (relative vs absolute)
- Export patterns (default vs named)
- Error handling patterns
- Logging patterns
### 2. Write Minimal Implementation
Follow **YAGNI** (You Ain't Gonna Need It). Prefer editing existing files over creating new ones.
**Good:**
```typescript
function calculateTotal(items: Item[]): number {
return items.reduce((sum, item) => sum + item.price, 0);
}
```
**Bad (Over-engineered):**
```typescript
function calculateTotal(
items: Item[],
options?: {
currency?: string;
discount?: number;
taxRate?: number;
roundingMode?: 'up' | 'down' | 'nearest';
}
): CalculationResult {
// YAGNI - Was this asked for?
}
```
### Code Clarity
**Prefer explicit, readable code over compact one-liners:**
- Avoid nested ternaries (`a ? b ? c : d : e`) — use `if/else` or `switch`
- Don't sacrifice readability for fewer lines — 3 clear lines beats 1 clever line
- Consolidate related logic, but don't merge unrelated concerns into one function
- Remove comments that describe what the code obviously does — let clear naming speak
### Minimal Diffs Principle
**Only change what's necessary.** When fixing a bug, fix the bug - don't refactor surrounding code. When adding a feature, add the feature - don't "improve" unrelated code. Scope creep in diffs causes merge conflicts, hides the actual change, and makes reviews harder.
### 3. Handle Edge Cases
**Always handle:**
- Empty inputs (`[]`, `null`, `undefined`)
- Invalid inputs (wrong types, out of range)
- Error conditions (network failures, timeouts)
- Boundary conditions (zero, negative, max values)
```typescript
function getUser(id: string): User | null {
if (!id?.trim()) {
return null;
}
// ... implementation
}
```
### 4. Align With Existing Conventions
| Aspect | Check |
|--------|-------|
| **Naming** | Match existing style (`getUserById` not `fetchUser`) |
| **Imports** | Match import style (`@/lib/` vs `../../lib/`) |
| **Exports** | Match export style (default vs named) |
| **Types** | Match type patterns (interfaces vs types) |
| **Errors** | Match error handling (throw vs return) |
| **Logging** | Match logging patterns (if any) |
## Red Flags - STOP and Reconsider
If you find yourself:
- Writing code before answering Universal Questions
- Adding features not requested ("while I'm here...")
- Ignoring project patterns ("my way is better")
- Not handling edge cases ("happy path only")
- Creating abstractions for one use case
- Adding configuration options not requested
- Using magic numbers or hardcoded thresholds instead of named constants or derived formulas
- Writing comments instead of clear code
- Multiple valid approaches exist but not presenting options
**STOP. Go back to Universal Questions.**
## Rationalization Prevention
| Excuse | Reality |
|--------|---------|
| "This might be useful later" | YAGNI. Build what's needed now. |
| "My pattern is better" | Match existing patterns. Consistency > preference. |
| "Edge cases are unlikely" | Edge cases cause production bugs. Handle them. |
| "I'll add docs later" | Code should be self-documenting. Write clear code now. |
| "It's just a quick prototype" | Prototypes become production. Write it right. |
| "I know a better way" | The codebase has patterns. Follow them. |
| "I understand enough to start" | Partial understanding produces wrong code. Read the full spec, pattern, or reference before writing. |
## When to Present Multiple Options
**Present 2-3 approaches with tradeoffs if:**
- Multiple design patterns could work (e.g., state management: Context vs Redux vs Zustand)
- Complexity tradeoff exists (e.g., simple file storage vs database)
- User said "best way" or "how should I" (signals uncertainty)
**Proceed with single approach if:**
- One approach is clearly simpler AND meets requirements
- Project patterns already established (follow existing pattern)
- User request is specific (no ambiguity)
**When multiple valid approaches exist:** Prefer the simplest option that matches project patterns. If the choice is high-risk and not already decided by the prompt or plan, surface the alternatives in your output and return control to the router instead of questioning the user directly.
## When to Abstract
Abstraction has a cost. Only introduce it when concrete evidence justifies it:
| Signal | Action |
|--------|--------|
| Pattern seen in 1 example onlRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.