@robosoft/skillhub-cli 0.1.2 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -26
- package/README.md +166 -184
- package/bin/skillhub.mjs +714 -365
- package/docs/skillhub-cli-logic.md +115 -83
- package/package.json +8 -5
- package/skillhub-registry/CHANGELOG.md +65 -0
- package/skillhub-registry/CLAUDE.md +108 -0
- package/skillhub-registry/README.md +196 -16
- package/skillhub-registry/docs/cheat-sheet.md +272 -0
- package/skillhub-registry/docs/contributing.md +166 -0
- package/skillhub-registry/docs/cost-hygiene.md +175 -0
- package/skillhub-registry/docs/customization.md +321 -0
- package/skillhub-registry/docs/exception-process.md +194 -0
- package/skillhub-registry/docs/installation.md +277 -0
- package/skillhub-registry/domain/api.md +303 -0
- package/skillhub-registry/domain/frontend/web-app.md +17 -0
- package/skillhub-registry/domain/frontend-app.md +46 -0
- package/skillhub-registry/domain/frontend-architecture.md +126 -0
- package/skillhub-registry/rules/anti-patterns.md +95 -0
- package/skillhub-registry/rules/code-standards.md +182 -0
- package/skillhub-registry/rules/frontend/antipattern.md +21 -0
- package/skillhub-registry/rules/frontend/component-standards.md +10 -0
- package/skillhub-registry/rules/frontend-app.md +24 -0
- package/skillhub-registry/rules/general.md +51 -0
- package/skillhub-registry/skills/api/SKILL.md +167 -0
- package/skillhub-registry/skills/build/SKILL.md +114 -0
- package/skillhub-registry/skills/fast/SKILL.md +56 -0
- package/skillhub-registry/skills/feature-dev/SKILL.md +166 -0
- package/skillhub-registry/skills/frontend/app/SKILL.md +28 -0
- package/skillhub-registry/skills/frontend/app/rules/main.md +6 -0
- package/skillhub-registry/skills/frontend/app/skill.json +10 -0
- package/skillhub-registry/skills/frontend/app/templates/feature/{{kebabName}}.tsx.hbs +11 -0
- package/skillhub-registry/skills/frontend-app/SKILL.md +48 -0
- package/skillhub-registry/skills/frontend-app/rules/main.md +6 -0
- package/skillhub-registry/skills/frontend-app/skill.json +11 -0
- package/skillhub-registry/skills/frontend-app/templates/feature/{{kebabName}}.tsx.hbs +11 -0
- package/skillhub-registry/skills/performance/SKILL.md +168 -0
- package/skillhub-registry/skills/react/SKILL.md +224 -0
- package/skillhub-registry/skills/refactor/SKILL.md +149 -0
- package/skillhub-registry/skills/review/SKILL.md +199 -0
- package/skillhub-registry/skills/strict/SKILL.md +74 -0
- package/skillhub-registry/skills/testing/SKILL.md +132 -0
- package/skillhub-registry/accessibility-review/1.0.0/SKILL.md +0 -22
- package/skillhub-registry/accessibility-review/1.0.0/checklist/ui-review.md +0 -8
- package/skillhub-registry/accessibility-review/1.0.0/skill.json +0 -9
- package/skillhub-registry/nextjs-clean-architecture/1.0.0/SKILL.md +0 -37
- package/skillhub-registry/nextjs-clean-architecture/1.0.0/checklist/definition-of-done.md +0 -9
- package/skillhub-registry/nextjs-clean-architecture/1.0.0/rules/folder-structure.md +0 -7
- package/skillhub-registry/nextjs-clean-architecture/1.0.0/skill.json +0 -9
- package/skillhub-registry/shadcn-crud-generator/1.0.0/SKILL.md +0 -25
- package/skillhub-registry/shadcn-crud-generator/1.0.0/skill.json +0 -9
- package/skillhub-registry/shadcn-crud-generator/1.0.0/templates/feature/actions.ts.hbs +0 -16
- package/skillhub-registry/shadcn-crud-generator/1.0.0/templates/feature/page.tsx.hbs +0 -13
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Code Standards
|
|
2
|
+
|
|
3
|
+
Status: **Universal — applies to all coding tasks regardless of language**
|
|
4
|
+
Last updated: 2026-05-06
|
|
5
|
+
Owner: [Raj Shah]
|
|
6
|
+
|
|
7
|
+
Concrete, measurable standards for code structure. These apply across all languages. Language-specific rules belong in `skills/` (e.g., `skills/react/SKILL.md`, `skills/python/SKILL.md`).
|
|
8
|
+
|
|
9
|
+
## Function Size
|
|
10
|
+
|
|
11
|
+
- **Maximum ~40 lines per function.**
|
|
12
|
+
- If a function exceeds this, extract logical chunks into named helpers.
|
|
13
|
+
- Exception: declarative configuration objects, route tables, and similar data structures.
|
|
14
|
+
|
|
15
|
+
> **Why:** Functions over 40 lines almost always mix multiple responsibilities. Breaking them up forces clearer naming and makes diffs reviewable.
|
|
16
|
+
|
|
17
|
+
## Nesting Depth
|
|
18
|
+
|
|
19
|
+
- **Maximum 3 levels of nesting** (conditionals, loops, error handling blocks).
|
|
20
|
+
- Use early returns or guard clauses to flatten control flow.
|
|
21
|
+
- Reject the "arrow anti-pattern" — code that drifts rightward across the page.
|
|
22
|
+
|
|
23
|
+
**Pseudocode example:**
|
|
24
|
+
|
|
25
|
+
// ❌ Bad — deeply nested
|
|
26
|
+
function process(user):
|
|
27
|
+
if user exists:
|
|
28
|
+
if user is active:
|
|
29
|
+
if user has permission:
|
|
30
|
+
do_action(user)
|
|
31
|
+
|
|
32
|
+
// ✅ Good — flat with early returns
|
|
33
|
+
function process(user):
|
|
34
|
+
if user does not exist: return
|
|
35
|
+
if user is not active: return
|
|
36
|
+
if user lacks permission: return
|
|
37
|
+
do_action(user)
|
|
38
|
+
|
|
39
|
+
> **Why:** Deep nesting is the strongest predictor of bugs. Early returns are easier to read and easier to modify.
|
|
40
|
+
|
|
41
|
+
## Naming
|
|
42
|
+
|
|
43
|
+
- **Variables and functions:** descriptive, no single letters except short-scope loop counters.
|
|
44
|
+
- **Allowed abbreviations:** universally-understood ones only (`id`, `url`, `db`, `api`, `ctx`).
|
|
45
|
+
- **Booleans:** prefix with `is`, `has`, `should`, `can` (e.g., `isReady`, `hasError`).
|
|
46
|
+
- **Functions:** verb-first (e.g., `getUser`, `validateInput`).
|
|
47
|
+
- **Constants:** language convention — typically `SCREAMING_SNAKE_CASE` for true constants.
|
|
48
|
+
- Match casing conventions of the language (`snake_case` for Python, `camelCase` for JS, etc.).
|
|
49
|
+
|
|
50
|
+
## Magic Values
|
|
51
|
+
|
|
52
|
+
- **No magic numbers or strings.** Extract to named constants.
|
|
53
|
+
- The constant's name must explain *what the value represents*, not just *that it's a value*.
|
|
54
|
+
|
|
55
|
+
**Pseudocode example:**
|
|
56
|
+
|
|
57
|
+
// ❌ Bad
|
|
58
|
+
if user.age > 17: allow_access()
|
|
59
|
+
sleep(5000)
|
|
60
|
+
|
|
61
|
+
// ✅ Good
|
|
62
|
+
MIN_ADULT_AGE = 18
|
|
63
|
+
RETRY_DELAY_MS = 5000
|
|
64
|
+
if user.age >= MIN_ADULT_AGE: allow_access()
|
|
65
|
+
sleep(RETRY_DELAY_MS)
|
|
66
|
+
|
|
67
|
+
> **Why:** Magic values force readers to guess intent. Named constants document the *why*, not just the *what*.
|
|
68
|
+
|
|
69
|
+
## Error Handling
|
|
70
|
+
|
|
71
|
+
- **Handle errors explicitly.** No silent failures, no empty catch blocks.
|
|
72
|
+
- If you catch an error, do exactly one of: log it, transform it, retry, or propagate it. Never swallow it.
|
|
73
|
+
- Errors must carry enough context to debug from logs alone.
|
|
74
|
+
|
|
75
|
+
**Pseudocode example:**
|
|
76
|
+
|
|
77
|
+
// ❌ Bad — silent failure
|
|
78
|
+
try: risky_operation()
|
|
79
|
+
catch: pass
|
|
80
|
+
|
|
81
|
+
// ✅ Good — explicit handling
|
|
82
|
+
try:
|
|
83
|
+
risky_operation()
|
|
84
|
+
catch err:
|
|
85
|
+
logger.error("risky_operation failed", err)
|
|
86
|
+
throw new OperationFailedError("Could not complete X", cause: err)
|
|
87
|
+
|
|
88
|
+
## Environment Variables and Secrets
|
|
89
|
+
|
|
90
|
+
- **Never hardcode** API URLs, base URLs, service endpoints, or environment-dependent values in business logic.
|
|
91
|
+
- **Never commit secrets** (API keys, tokens, passwords, connection strings) to version control — use environment variables, secret managers, or platform-native secret storage.
|
|
92
|
+
- **Centralize config access:**
|
|
93
|
+
- Read environment variables in one place (e.g., a `config` module that exposes typed values).
|
|
94
|
+
- Business logic, components, and services consume from the config module — not from `process.env` / `os.environ` / equivalent directly.
|
|
95
|
+
- This makes the set of expected variables auditable in one place.
|
|
96
|
+
|
|
97
|
+
**Pseudocode example:**
|
|
98
|
+
|
|
99
|
+
// ❌ Bad — env access scattered, no validation
|
|
100
|
+
function fetchUsers() {
|
|
101
|
+
return fetch(process.env.API_URL + "/users")
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ✅ Good — centralized, validated config
|
|
105
|
+
// config.js
|
|
106
|
+
export const config = {
|
|
107
|
+
apiUrl: requireEnv("API_URL"),
|
|
108
|
+
// ... other typed values
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// userService.js
|
|
112
|
+
import { config } from "./config"
|
|
113
|
+
function fetchUsers() {
|
|
114
|
+
return fetch(`${config.apiUrl}/users`)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
> **Why:** Centralized config makes deployments safer (one place to audit required env vars), tests easier (mock the config module), and rotation simpler (change in one place). Scattered env access creates silent failures when a variable is missing in some environments but not others.
|
|
118
|
+
|
|
119
|
+
## Side Effects
|
|
120
|
+
|
|
121
|
+
- **Default to pure functions** — input in, output out, no external state changes.
|
|
122
|
+
- When side effects are necessary (network, file system, database, UI mutation), **isolate them in clearly named functions** (`saveUser`, `fetchOrders`).
|
|
123
|
+
- Avoid mixing pure logic and side effects in the same function.
|
|
124
|
+
|
|
125
|
+
> **Why:** Pure functions are trivially testable. Side-effecting code requires mocks, fixtures, and integration setup.
|
|
126
|
+
|
|
127
|
+
## Duplication
|
|
128
|
+
|
|
129
|
+
- **Rule of three:** extract shared logic on the *third* repetition, not the second.
|
|
130
|
+
- Two similar pieces of code might diverge over time — premature deduplication creates the wrong abstraction.
|
|
131
|
+
- When extracting, the abstraction must capture *shared intent*, not just *shared syntax*.
|
|
132
|
+
|
|
133
|
+
> **Why:** The wrong abstraction costs more than duplication. Wait until the pattern is real.
|
|
134
|
+
|
|
135
|
+
## Comments
|
|
136
|
+
|
|
137
|
+
- **Explain *why*, not *what*.** Code already shows what it does.
|
|
138
|
+
- Delete commented-out code. Use version control history instead.
|
|
139
|
+
- `TODO` / `FIXME` comments must include context: who wrote it, when, and why.
|
|
140
|
+
|
|
141
|
+
**Pseudocode example:**
|
|
142
|
+
|
|
143
|
+
// ❌ Bad — restates the code
|
|
144
|
+
// Increment counter
|
|
145
|
+
counter += 1
|
|
146
|
+
|
|
147
|
+
// ✅ Good — explains a non-obvious decision
|
|
148
|
+
// Counter resets at midnight UTC to align with billing cycle.
|
|
149
|
+
counter += 1
|
|
150
|
+
|
|
151
|
+
## Logging
|
|
152
|
+
|
|
153
|
+
- **No debug prints in production paths.** `console.log`, `print()`, `dump()`, equivalents — these are debugging artifacts, not production logging.
|
|
154
|
+
- **Use a real logging library** with levels (debug, info, warn, error). What gets logged where, and at what verbosity, becomes configurable per environment.
|
|
155
|
+
- **Log structured data, not concatenated strings.** Logs that include data as fields (`{ user_id: 123, action: "login" }`) are searchable; logs as concatenated text (`"user 123 did login"`) are not.
|
|
156
|
+
- **Don't log secrets.** Never log passwords, tokens, full credit card numbers, or other sensitive fields. Mask or omit them.
|
|
157
|
+
- **Don't log noise.** Successful happy-path operations rarely need INFO logs in production — they fill log storage and obscure real issues.
|
|
158
|
+
|
|
159
|
+
**Pseudocode example:**
|
|
160
|
+
|
|
161
|
+
// ❌ Bad — debug print, unstructured, leaks data
|
|
162
|
+
console.log("user logged in: " + user.email + " token: " + token)
|
|
163
|
+
|
|
164
|
+
// ✅ Good — structured, intentional level, no secret leakage
|
|
165
|
+
logger.info("user_login_succeeded", {
|
|
166
|
+
user_id: user.id,
|
|
167
|
+
// email and token deliberately omitted
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
> **Why:** Production logs are a debugging tool, a security surface, and a cost line item. Debug prints fail all three: they're inconsistent, can leak secrets, and pile up storage costs. Structured logging with discipline makes incidents debuggable without making them expensive or risky.
|
|
171
|
+
|
|
172
|
+
## Imports / Dependencies
|
|
173
|
+
|
|
174
|
+
- Group imports logically: external libraries → internal modules → local files.
|
|
175
|
+
- Remove unused imports before finishing.
|
|
176
|
+
- Don't add a dependency without confirming it's necessary and not already available.
|
|
177
|
+
|
|
178
|
+
## File Organization
|
|
179
|
+
|
|
180
|
+
- One primary export per file when the language supports it.
|
|
181
|
+
- File name should match the primary export.
|
|
182
|
+
- Co-locate tightly coupled code (tests next to source, types next to implementation) when conventional for the language.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Frontend Anti-Patterns
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Use this rule file when reviewing or generating frontend application code.
|
|
6
|
+
|
|
7
|
+
## Avoid
|
|
8
|
+
|
|
9
|
+
- Putting API calls directly inside presentational components.
|
|
10
|
+
- Mixing business logic, validation, and JSX in one large component.
|
|
11
|
+
- Creating untyped `any` data contracts for API responses.
|
|
12
|
+
- Using client components by default in Next.js App Router.
|
|
13
|
+
- Ignoring loading, empty, error, and permission states.
|
|
14
|
+
- Creating duplicated form logic instead of reusable hooks or schema helpers.
|
|
15
|
+
- Mutating shared state directly.
|
|
16
|
+
- Adding UI libraries without checking project conventions.
|
|
17
|
+
- Shipping inaccessible controls without labels, focus states, or keyboard support.
|
|
18
|
+
|
|
19
|
+
## Required Review
|
|
20
|
+
|
|
21
|
+
Before final output, check whether the implementation follows existing project structure, naming rules, TypeScript typing, accessibility basics, and error handling.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Frontend Component Standards
|
|
2
|
+
|
|
3
|
+
## Rules
|
|
4
|
+
|
|
5
|
+
- Keep UI components small, typed, and composable.
|
|
6
|
+
- Prefer server components unless interactivity is needed.
|
|
7
|
+
- Keep feature-specific components inside the feature folder.
|
|
8
|
+
- Keep reusable primitives under shared components.
|
|
9
|
+
- Use clear prop names and avoid boolean-prop explosions.
|
|
10
|
+
- Handle loading, empty, and error states close to the UI boundary.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Frontend App Rules
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Use these always-on rules when building frontend features.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
- Match the existing frontend architecture before adding new structure.
|
|
10
|
+
- Use feature folders for medium and large applications.
|
|
11
|
+
- Keep API clients, validation schemas, and UI components separate.
|
|
12
|
+
- Every user-facing async state must handle loading, empty, error, and success.
|
|
13
|
+
- Accessibility is not optional decoration. Buttons need names, forms need labels, focus must be visible.
|
|
14
|
+
- Do not add a new package when the project already has an equivalent solution.
|
|
15
|
+
- Do not invent APIs or assume backend payloads. Confirm with types, schema, docs, or existing calls.
|
|
16
|
+
|
|
17
|
+
## Review Checklist
|
|
18
|
+
|
|
19
|
+
- [ ] Types are explicit
|
|
20
|
+
- [ ] Component names are clear
|
|
21
|
+
- [ ] No business logic buried in JSX
|
|
22
|
+
- [ ] No hardcoded secrets or environment-specific URLs
|
|
23
|
+
- [ ] UI works on mobile and desktop
|
|
24
|
+
- [ ] Error messages are human-readable
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# General Coding Rules
|
|
2
|
+
|
|
3
|
+
Status: **Universal — applies to all coding tasks**
|
|
4
|
+
Last updated: 2026-05-06
|
|
5
|
+
Owner: [Raj Shah]
|
|
6
|
+
|
|
7
|
+
These are the non-negotiable foundations. They apply to every language, every project, every developer using Claude with this template. Exceptions require a documented case via the [exception process](../docs/exception-process.md).
|
|
8
|
+
|
|
9
|
+
## The Four Foundations
|
|
10
|
+
|
|
11
|
+
### 1. Match the existing codebase before applying these rules
|
|
12
|
+
When editing existing code, follow the conventions of that codebase — even if they conflict with rules below. Consistency within a project is more valuable than consistency with this template.
|
|
13
|
+
|
|
14
|
+
> **Why:** Mixing styles within a single file is harder to read than either style alone. The cost of converting a whole codebase is rarely worth the benefit.
|
|
15
|
+
|
|
16
|
+
### 2. Never invent APIs, library functions, or syntax
|
|
17
|
+
If you are not certain a function/method/library exists, say so explicitly. Do not produce plausible-looking code that might not work. Better to ask "does your project use lodash?" than to call `_.cloneDeepWith()` and hope.
|
|
18
|
+
|
|
19
|
+
> **Why:** Hallucinated code is the #1 cause of wasted time when using AI assistants. Saying "I don't know" is faster than debugging fake APIs.
|
|
20
|
+
|
|
21
|
+
### 3. Ask one clarifying question when the request is ambiguous
|
|
22
|
+
If the requirement could reasonably be interpreted two ways, ask before coding. One short question now saves a full rewrite later. Limit yourself to **one** question — don't interrogate.
|
|
23
|
+
|
|
24
|
+
> **Why:** Silent assumptions are the most expensive mistakes. They look right until they aren't.
|
|
25
|
+
|
|
26
|
+
### 4. Prefer the simplest solution that fully solves the problem
|
|
27
|
+
Default to the most boring, obvious approach. Add complexity only when a *current* requirement forces it — never for imagined future needs.
|
|
28
|
+
|
|
29
|
+
> **Why:** Speculative complexity ages badly. The "flexibility" you build today usually doesn't match what you actually need tomorrow.
|
|
30
|
+
|
|
31
|
+
## When You're Uncertain
|
|
32
|
+
|
|
33
|
+
State uncertainty explicitly:
|
|
34
|
+
- ✅ "I'm not sure if your project uses TypeScript strict mode — can you confirm?"
|
|
35
|
+
- ❌ Producing code that assumes one way and silently fails the other
|
|
36
|
+
|
|
37
|
+
State limitations explicitly:
|
|
38
|
+
- ✅ "I can't run the tests, but here's what I'd expect to pass."
|
|
39
|
+
- ❌ "All tests pass." (when you didn't run them)
|
|
40
|
+
|
|
41
|
+
## Scope Discipline
|
|
42
|
+
|
|
43
|
+
Do exactly what was asked. Do not:
|
|
44
|
+
- Refactor unrelated code "while you're there"
|
|
45
|
+
- Add features that weren't requested
|
|
46
|
+
- Rename things that work
|
|
47
|
+
- Reformat files beyond your changes
|
|
48
|
+
|
|
49
|
+
If you spot something that *should* be fixed, mention it briefly at the end. Don't fix it unsolicited.
|
|
50
|
+
|
|
51
|
+
> **Why:** Scope creep in AI-assisted edits creates massive review burden and merges get rejected. Stay in your lane.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api
|
|
3
|
+
description: Universal API design and implementation standards covering naming, input validation, error responses, versioning, pagination, idempotency, authentication, rate limiting, and contract design for REST, GraphQL, RPC, and internal service APIs. Use this skill whenever the user works on API endpoints, designs API contracts, modifies API responses, debugs API issues, writes API handlers, defines API schemas, mentions REST, GraphQL, gRPC, RPC, OpenAPI, Swagger, JSON Schema, status codes, HTTP methods, request/response shapes, API versioning, or backend services. Apply when reviewing API code, building new endpoints, refactoring API surfaces, integrating external APIs, designing webhooks, or discussing API architecture. Trigger when the user mentions endpoints, routes, handlers, controllers, or any HTTP-related work. Also load `domain/api.md` for org-specific conventions when working in this codebase.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Skill
|
|
7
|
+
|
|
8
|
+
This skill applies universal API design standards. It loads whenever the user works on API design or implementation.
|
|
9
|
+
|
|
10
|
+
These rules layer on top of `rules/general.md`, `rules/code-standards.md`, and `rules/anti-patterns.md`.
|
|
11
|
+
|
|
12
|
+
**Important:** This skill covers universal best practices. Org-specific conventions (your envelope shape, your auth header, your pagination style) live in `domain/api.md` — read both when working in this codebase.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Naming
|
|
17
|
+
|
|
18
|
+
- **Resources are nouns, not verbs.** ✅ `/users` ❌ `/getUsers`
|
|
19
|
+
- **Plural for collections, singular for single resources.** ✅ `/users/123` ❌ `/user/123`
|
|
20
|
+
- **Lowercase with hyphens for path segments.** ✅ `/user-profiles` ❌ `/userProfiles` or `/user_profiles`
|
|
21
|
+
- **camelCase or snake_case for JSON fields** — pick one and stay consistent across the entire API
|
|
22
|
+
- **Verbs only for actions that don't fit CRUD** — ✅ `POST /orders/123/cancel` when "cancel" isn't a normal update
|
|
23
|
+
|
|
24
|
+
## HTTP Methods (REST)
|
|
25
|
+
|
|
26
|
+
| Method | Use for | Idempotent? | Body? |
|
|
27
|
+
|---|---|---|---|
|
|
28
|
+
| `GET` | Read | Yes | No |
|
|
29
|
+
| `POST` | Create, or actions that don't fit CRUD | No | Yes |
|
|
30
|
+
| `PUT` | Replace entire resource | Yes | Yes |
|
|
31
|
+
| `PATCH` | Partial update | Usually | Yes |
|
|
32
|
+
| `DELETE` | Remove | Yes | No |
|
|
33
|
+
|
|
34
|
+
- **Don't use `GET` for state changes.** Browsers, caches, and crawlers replay GETs freely.
|
|
35
|
+
- **`PUT` requires the full resource.** If the client sends a partial, use `PATCH`.
|
|
36
|
+
|
|
37
|
+
## Status Codes
|
|
38
|
+
|
|
39
|
+
Use the standard ones; don't invent meaning:
|
|
40
|
+
|
|
41
|
+
| Code | When |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `200` | Success with body |
|
|
44
|
+
| `201` | Created (return the resource or its location) |
|
|
45
|
+
| `204` | Success, no body |
|
|
46
|
+
| `400` | Client sent malformed/invalid data |
|
|
47
|
+
| `401` | Not authenticated |
|
|
48
|
+
| `403` | Authenticated but not authorized |
|
|
49
|
+
| `404` | Resource doesn't exist |
|
|
50
|
+
| `409` | Conflict (e.g., duplicate, version mismatch) |
|
|
51
|
+
| `422` | Semantically invalid (validation failed) |
|
|
52
|
+
| `429` | Rate limited |
|
|
53
|
+
| `500` | Server error (your bug) |
|
|
54
|
+
| `502/503/504` | Upstream / availability issues |
|
|
55
|
+
|
|
56
|
+
- **Don't return `200 OK` with an error in the body.** That breaks every HTTP-aware tool.
|
|
57
|
+
- **Don't use `404` to hide authorization failures.** Use `403`. (Exception: when leaking existence is itself a security risk — but document that decision.)
|
|
58
|
+
|
|
59
|
+
## Request Validation
|
|
60
|
+
|
|
61
|
+
- **Validate at the boundary.** Reject invalid requests *before* business logic runs.
|
|
62
|
+
- **Use a schema validator** (Zod, Yup, JSON Schema, Pydantic, etc.) — not hand-rolled `if` checks.
|
|
63
|
+
- **Reject early, reject specifically.** Tell the client what was wrong, not just that it was wrong.
|
|
64
|
+
- **Whitelist allowed fields.** Don't accept arbitrary fields and let the database sort it out.
|
|
65
|
+
- **Validate types AND constraints.** A string is not enough — is it a non-empty string? A valid email? A length-bounded string?
|
|
66
|
+
|
|
67
|
+
## Error Response Shape
|
|
68
|
+
|
|
69
|
+
Pick **one** error envelope and use it everywhere. A common shape:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
"error": {
|
|
75
|
+
"code": "VALIDATION_FAILED",
|
|
76
|
+
"message": "Human-readable summary",
|
|
77
|
+
"details": [
|
|
78
|
+
{ "field": "email", "issue": "must be a valid email address" }
|
|
79
|
+
],
|
|
80
|
+
"request_id": "req_abc123"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Rules:
|
|
85
|
+
|
|
86
|
+
- **`code` is a stable machine-readable identifier.** Clients pattern-match on this. Never change it without versioning.
|
|
87
|
+
- **`message` is for humans.** Can be localized, can be reworded freely.
|
|
88
|
+
- **`details` for field-level issues.** Lets clients display per-field errors.
|
|
89
|
+
- **`request_id` for support.** Lets users report errors and engineers trace them in logs.
|
|
90
|
+
- **Don't leak internals.** No stack traces, no SQL fragments, no internal service names.
|
|
91
|
+
|
|
92
|
+
## Pagination
|
|
93
|
+
|
|
94
|
+
For any list endpoint that could return >100 items:
|
|
95
|
+
|
|
96
|
+
- **Cursor-based** is preferred for stable, scalable pagination. Returns `next_cursor` to continue.
|
|
97
|
+
- **Offset-based** is acceptable for small, stable data sets but breaks with concurrent inserts.
|
|
98
|
+
- **Always paginate.** Never return unbounded result sets, even if "currently it's small."
|
|
99
|
+
- **Document the default and max page size.** Clients shouldn't have to guess.
|
|
100
|
+
|
|
101
|
+
## Versioning
|
|
102
|
+
|
|
103
|
+
- **Version the API from day one.** ✅ `/v1/users` — even if v2 doesn't exist yet.
|
|
104
|
+
- **Pick one strategy:** URI path (`/v1/`), header (`API-Version: 1`), or accept header (`application/vnd.org.v1+json`). Don't mix.
|
|
105
|
+
- **Breaking changes require a new version.** Adding a field is not breaking. Removing or changing one is.
|
|
106
|
+
- **Maintain old versions for a stated deprecation window** — communicate the timeline.
|
|
107
|
+
|
|
108
|
+
## Idempotency
|
|
109
|
+
|
|
110
|
+
- **`GET`, `PUT`, `DELETE` are naturally idempotent.** Same request, same effect.
|
|
111
|
+
- **`POST` is naturally not idempotent.** For payment-like or critical operations, accept an `Idempotency-Key` header so retries don't double-charge.
|
|
112
|
+
- **Document idempotency expectations** for every mutating endpoint. Clients need to know what's safe to retry.
|
|
113
|
+
|
|
114
|
+
## Authentication & Authorization
|
|
115
|
+
|
|
116
|
+
- **Authentication answers "who are you?"** — handled by middleware, before the handler runs.
|
|
117
|
+
- **Authorization answers "are you allowed?"** — handled inside the handler, with awareness of the specific resource.
|
|
118
|
+
- **Never trust the client's assertion of identity.** Validate tokens server-side every time.
|
|
119
|
+
- **Authorize on the data, not just the route.** A user passing route-level auth might still not own *this specific* resource.
|
|
120
|
+
- **Don't include sensitive data in URLs.** URLs end up in logs, browser history, referrer headers.
|
|
121
|
+
- **Use HTTPS only.** No exceptions for "internal" services that might leak.
|
|
122
|
+
|
|
123
|
+
## Rate Limiting
|
|
124
|
+
|
|
125
|
+
- **Rate-limit every public endpoint.** Even reads. Even authenticated.
|
|
126
|
+
- **Return `429 Too Many Requests`** with a `Retry-After` header.
|
|
127
|
+
- **Different limits for different endpoints** — login attempts should be stricter than reads.
|
|
128
|
+
- **Per-user, per-IP, per-key.** Layered limits catch different abuse patterns.
|
|
129
|
+
|
|
130
|
+
## Caching
|
|
131
|
+
|
|
132
|
+
- **Cache `GET` aggressively** with `Cache-Control` headers — `public`, `private`, `max-age`, `no-store` mean specific things; use them deliberately.
|
|
133
|
+
- **`ETag` and `If-None-Match`** to enable conditional requests.
|
|
134
|
+
- **Never cache responses that contain user-specific data** in a shared cache.
|
|
135
|
+
- **Invalidate on writes** — a `PUT` to `/users/123` should bust the cache for that resource.
|
|
136
|
+
|
|
137
|
+
## Avoiding Over- and Under-Fetching
|
|
138
|
+
|
|
139
|
+
- **Don't return what the client doesn't need** — extra fields cost bandwidth and leak info.
|
|
140
|
+
- **Don't force the client to make N follow-up calls** — design endpoints around the client's actual needs.
|
|
141
|
+
- **GraphQL solves this natively.** REST APIs use sparse fieldsets (`?fields=id,name`) or expansion params (`?expand=author`).
|
|
142
|
+
|
|
143
|
+
## Webhooks (If Applicable)
|
|
144
|
+
|
|
145
|
+
- **Sign every webhook payload.** HMAC with a shared secret. The receiver must verify.
|
|
146
|
+
- **Make webhooks idempotent.** Retries will happen.
|
|
147
|
+
- **Include event ID and timestamp** in every payload for dedup and ordering.
|
|
148
|
+
- **Document retry policy** — receivers need to know what `2xx` means and what triggers a retry.
|
|
149
|
+
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
- **Spec-first or code-first** — pick one (OpenAPI, GraphQL Schema, Protobuf) and keep it in sync with reality.
|
|
153
|
+
- **Examples for every endpoint.** Real request/response samples. Not just type definitions.
|
|
154
|
+
- **Document error cases.** What `code` values can this endpoint return, under what conditions.
|
|
155
|
+
|
|
156
|
+
## When You're Unsure
|
|
157
|
+
|
|
158
|
+
- **Check `domain/api.md`** for org-specific conventions before applying universal defaults.
|
|
159
|
+
- **Match existing endpoints in the codebase.** Consistency within an API beats theoretical purity.
|
|
160
|
+
- **Ask before introducing a new pattern.** If your suggested error shape differs from the codebase's, surface that.
|
|
161
|
+
|
|
162
|
+
## What This Skill Does NOT Cover
|
|
163
|
+
|
|
164
|
+
- **Database design** — that's a separate concern
|
|
165
|
+
- **Frontend integration with APIs** — see `skills/react` for client-side patterns
|
|
166
|
+
- **Deployment and infrastructure** — separate domain
|
|
167
|
+
- **Org-specific decisions** (envelope shape, header names, auth flow) → see `domain/api.md`
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build
|
|
3
|
+
description: Structured implementation workflow for building new features, components, functions, modules, or any net-new code. Use this skill whenever the user invokes /build, asks to "build", "implement", "create", "add", "write", or "make" something — a feature, function, component, endpoint, module, page, hook, utility, service, or class. Apply when the user is starting fresh code rather than modifying existing code (use /refactor for that) or evaluating existing code (use /review for that). Trigger when the user says things like "build me a X", "implement Y", "I need a function that does Z", "add a feature for W", or "create a component for V".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build Skill
|
|
7
|
+
|
|
8
|
+
This skill applies the org's standard implementation workflow. It loads when the user is creating new code.
|
|
9
|
+
|
|
10
|
+
These rules layer on top of `rules/general.md`, `rules/code-standards.md`, and `rules/anti-patterns.md`. If a domain skill (`react`, `testing`, `performance`) also triggers, apply both.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## The Build Workflow
|
|
15
|
+
|
|
16
|
+
Follow these steps in order. Don't skip steps unless a step is genuinely irrelevant to the task.
|
|
17
|
+
|
|
18
|
+
### Step 1: Understand the Task
|
|
19
|
+
|
|
20
|
+
Restate the requirement in your own words. Specifically clarify:
|
|
21
|
+
|
|
22
|
+
- **What is the user-visible behavior?** (the *what*)
|
|
23
|
+
- **What inputs does it accept?**
|
|
24
|
+
- **What outputs does it produce?**
|
|
25
|
+
- **What does success look like?**
|
|
26
|
+
- **What's explicitly out of scope?**
|
|
27
|
+
|
|
28
|
+
If any of these are unclear, ask **one** clarifying question before continuing. Don't write code based on assumptions.
|
|
29
|
+
|
|
30
|
+
### Step 2: Identify Edge Cases
|
|
31
|
+
|
|
32
|
+
Before writing code, list the edge cases that matter:
|
|
33
|
+
|
|
34
|
+
- Empty input (`""`, `[]`, `{}`, `null`, `undefined`)
|
|
35
|
+
- Boundary values (zero, negative, max-size)
|
|
36
|
+
- Invalid types
|
|
37
|
+
- Network / IO failures (if applicable)
|
|
38
|
+
- Concurrent access (if applicable)
|
|
39
|
+
- Permission / authorization edge cases
|
|
40
|
+
- Already-existing entity / non-existent entity
|
|
41
|
+
|
|
42
|
+
State which ones you're handling and which ones you're explicitly *not* handling (and why).
|
|
43
|
+
|
|
44
|
+
### Step 3: Plan Briefly
|
|
45
|
+
|
|
46
|
+
State the approach in 2-4 bullets. For non-trivial tasks, also note:
|
|
47
|
+
|
|
48
|
+
- One alternative you considered
|
|
49
|
+
- Why you rejected it
|
|
50
|
+
|
|
51
|
+
This is not architecture documentation — it's a sanity check that you've thought about it. Keep it short.
|
|
52
|
+
|
|
53
|
+
### Step 4: Write the Code
|
|
54
|
+
|
|
55
|
+
Apply all loaded rules and skills:
|
|
56
|
+
|
|
57
|
+
- Match the existing codebase style first
|
|
58
|
+
- Apply `rules/code-standards.md` (function size, nesting, naming, errors)
|
|
59
|
+
- Avoid every anti-pattern in `rules/anti-patterns.md`
|
|
60
|
+
- If a domain skill is active, apply its rules too
|
|
61
|
+
|
|
62
|
+
### Step 5: Refactor for Clarity
|
|
63
|
+
|
|
64
|
+
Before declaring done, re-read the code as if you were a reviewer:
|
|
65
|
+
|
|
66
|
+
- Are all variables / functions named meaningfully?
|
|
67
|
+
- Is anything nested deeper than 3 levels?
|
|
68
|
+
- Are there any magic values?
|
|
69
|
+
- Are there any silent error swallows?
|
|
70
|
+
- Does the code do anything beyond the stated scope? (Remove if so.)
|
|
71
|
+
|
|
72
|
+
### Step 6: Validate Against Requirements
|
|
73
|
+
|
|
74
|
+
Walk through the original requirements one more time:
|
|
75
|
+
|
|
76
|
+
- Does the code actually do what was asked?
|
|
77
|
+
- Are the edge cases from Step 2 actually handled?
|
|
78
|
+
- Are there any obvious test cases that would currently fail?
|
|
79
|
+
|
|
80
|
+
## Output Format
|
|
81
|
+
|
|
82
|
+
For build tasks, structure the response as:
|
|
83
|
+
|
|
84
|
+
[Optional: 1-2 sentence summary of the approach taken — only if non-obvious]
|
|
85
|
+
[The code]
|
|
86
|
+
[Optional: notes on edge cases not handled, follow-up TODOs, or assumptions made — only if relevant]
|
|
87
|
+
|
|
88
|
+
Skip empty sections. Don't include "Here's the code:" preambles or closing summaries that just restate what the code does.
|
|
89
|
+
|
|
90
|
+
## Tests
|
|
91
|
+
|
|
92
|
+
If a domain demands tests (covered by `rules/general.md` and `skills/testing`), include them. If you're skipping tests deliberately (Fast Mode, prototype, user said no tests), state that briefly.
|
|
93
|
+
|
|
94
|
+
## When to Ask Before Building
|
|
95
|
+
|
|
96
|
+
Ask one clarifying question, then build, when:
|
|
97
|
+
|
|
98
|
+
- The requirement could reasonably be interpreted two ways
|
|
99
|
+
- The task implies design decisions (where does this file go? what's the API shape?)
|
|
100
|
+
- The task touches an unfamiliar part of the codebase
|
|
101
|
+
|
|
102
|
+
Don't ask, just build, when:
|
|
103
|
+
|
|
104
|
+
- The requirement is concrete and unambiguous
|
|
105
|
+
- The codebase pattern is clear from context
|
|
106
|
+
- It's a trivial, isolated piece of code
|
|
107
|
+
|
|
108
|
+
## What This Skill Does NOT Cover
|
|
109
|
+
|
|
110
|
+
- **Modifying existing code** → use `/refactor`
|
|
111
|
+
- **Reviewing existing code** → use `/review`
|
|
112
|
+
- **Multi-step features that span multiple files** → use `/feature-dev` workflow
|
|
113
|
+
|
|
114
|
+
If the user asks for something that spans skills, apply all relevant ones together.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fast
|
|
3
|
+
description: Activates Fast Mode for quick prototyping and rapid iteration. Use this skill whenever the user invokes /fast, says "fast mode", "quick and dirty", "just hack it together", "I need this fast", "rough version", "MVP version", "throwaway code", "prototype this", or otherwise signals they want speed over polish. Apply when the user explicitly prioritizes shipping over quality, when iterating on an idea that may be discarded, or when exploring a solution before committing to one. Do NOT trigger this for production code, code marked for review, or when the user requests "clean", "production-ready", "robust", or "thorough".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Fast Mode
|
|
7
|
+
|
|
8
|
+
This skill switches Claude into rapid-iteration mode. It explicitly relaxes some `rules/` constraints in exchange for speed.
|
|
9
|
+
|
|
10
|
+
This is a deliberate trade-off — Fast Mode is for prototyping, not production.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What Changes in Fast Mode
|
|
15
|
+
|
|
16
|
+
### Relaxed
|
|
17
|
+
- ✅ Skip exhaustive edge case analysis
|
|
18
|
+
- ✅ Skip over-engineering (no abstractions, no flexibility hooks)
|
|
19
|
+
- ✅ Minimal explanation in output
|
|
20
|
+
- ✅ "Good enough" beats "perfect"
|
|
21
|
+
- ✅ Inline ad-hoc constants instead of extracting them
|
|
22
|
+
- ✅ Skip writing tests unless explicitly requested
|
|
23
|
+
- ✅ Don't refactor existing code while adding features
|
|
24
|
+
|
|
25
|
+
### Still Enforced
|
|
26
|
+
- 🔒 No hallucinated APIs or libraries (`rules/general.md` — non-negotiable)
|
|
27
|
+
- 🔒 No silent error swallowing (failures must surface)
|
|
28
|
+
- 🔒 Match existing codebase style (don't introduce inconsistency)
|
|
29
|
+
- 🔒 No security shortcuts (auth, secrets, input validation stay strict)
|
|
30
|
+
- 🔒 No deletion or destructive operations without confirmation
|
|
31
|
+
|
|
32
|
+
## Behavior
|
|
33
|
+
|
|
34
|
+
- **Lead with the code.** Skip preamble, skip recap.
|
|
35
|
+
- **Pick obvious solutions.** Don't deliberate between approaches.
|
|
36
|
+
- **Don't optimize anything.** Premature optimization wastes the point of Fast Mode.
|
|
37
|
+
- **Flag debt explicitly.** End with one short line: `// FIXME(fast-mode): explain X edge case if this becomes real code`.
|
|
38
|
+
- **Don't apologize for not testing / not handling all cases.** The user knows.
|
|
39
|
+
|
|
40
|
+
## When the User Might Misuse This Mode
|
|
41
|
+
|
|
42
|
+
If the user invokes `/fast` for something that looks like:
|
|
43
|
+
- Production code
|
|
44
|
+
- Security-sensitive code (auth, payment, PII)
|
|
45
|
+
- Code that will be merged to main
|
|
46
|
+
- Database migrations or destructive operations
|
|
47
|
+
|
|
48
|
+
→ **Briefly confirm:** "Fast mode for production code is risky — confirm you want speed over correctness here?" Then proceed if confirmed.
|
|
49
|
+
|
|
50
|
+
## Output Format in Fast Mode
|
|
51
|
+
|
|
52
|
+
- Code first, talking later
|
|
53
|
+
- No "Here's the code:" preamble
|
|
54
|
+
- No closing summary
|
|
55
|
+
- One-line FIXME comments only where critical
|
|
56
|
+
- Skip the "I considered alternatives" reasoning
|