@neyugn/agent-kits 0.5.0 → 0.5.3
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/README.md +66 -81
- package/README.vi.md +79 -52
- package/README.zh.md +69 -88
- package/common/skills/filter-agent/SKILL.md +33 -45
- package/common/skills/filter-skill/SKILL.md +51 -73
- package/common/skills/scan-techstack/SKILL.md +30 -36
- package/dist/cli.js +85 -0
- package/kits/coder/agents/ai-engineer.md +27 -39
- package/kits/coder/agents/backend-specialist.md +31 -45
- package/kits/coder/agents/cloud-architect.md +31 -45
- package/kits/coder/agents/code-reviewer.md +45 -67
- package/kits/coder/agents/data-engineer.md +22 -32
- package/kits/coder/agents/database-specialist.md +30 -44
- package/kits/coder/agents/debugger.md +28 -42
- package/kits/coder/agents/devops-engineer.md +35 -53
- package/kits/coder/agents/documentation-writer.md +48 -68
- package/kits/coder/agents/frontend-specialist.md +30 -46
- package/kits/coder/agents/i18n-specialist.md +37 -51
- package/kits/coder/agents/integration-specialist.md +38 -54
- package/kits/coder/agents/mobile-developer.md +37 -53
- package/kits/coder/agents/multi-tenant-architect.md +25 -37
- package/kits/coder/agents/orchestrator.md +20 -32
- package/kits/coder/agents/performance-analyst.md +43 -65
- package/kits/coder/agents/project-planner.md +25 -39
- package/kits/coder/agents/queue-specialist.md +26 -38
- package/kits/coder/agents/realtime-specialist.md +44 -64
- package/kits/coder/agents/security-auditor.md +44 -64
- package/kits/coder/agents/test-engineer.md +30 -44
- package/kits/coder/agents/ux-researcher.md +26 -38
- package/kits/coder/rules/sections/classifier.md +11 -7
- package/kits/coder/rules/sections/code.md +5 -4
- package/kits/coder/skills/accessibility-patterns/SKILL.md +67 -81
- package/kits/coder/skills/ai-rag-patterns/SKILL.md +27 -23
- package/kits/coder/skills/api-patterns/SKILL.md +40 -43
- package/kits/coder/skills/auth-patterns/SKILL.md +47 -51
- package/kits/coder/skills/aws-patterns/SKILL.md +52 -57
- package/kits/coder/skills/brainstorming/SKILL.md +26 -23
- package/kits/coder/skills/clean-code/SKILL.md +74 -90
- package/kits/coder/skills/database-design/SKILL.md +32 -31
- package/kits/coder/skills/docker-patterns/SKILL.md +46 -49
- package/kits/coder/skills/documentation-templates/SKILL.md +21 -13
- package/kits/coder/skills/e2e-testing/SKILL.md +52 -58
- package/kits/coder/skills/flutter-patterns/SKILL.md +44 -46
- package/kits/coder/skills/frontend-design/SKILL.md +28 -24
- package/kits/coder/skills/github-actions/SKILL.md +43 -45
- package/kits/coder/skills/gitlab-ci-patterns/SKILL.md +35 -33
- package/kits/coder/skills/graphql-patterns/SKILL.md +35 -33
- package/kits/coder/skills/i18n-localization/SKILL.md +37 -35
- package/kits/coder/skills/kubernetes-patterns/SKILL.md +35 -33
- package/kits/coder/skills/mermaid-diagrams/SKILL.md +54 -60
- package/kits/coder/skills/mobile-design/SKILL.md +51 -61
- package/kits/coder/skills/monitoring-observability/SKILL.md +32 -30
- package/kits/coder/skills/multi-tenancy/SKILL.md +16 -8
- package/kits/coder/skills/nodejs-best-practices/SKILL.md +19 -14
- package/kits/coder/skills/performance-profiling/SKILL.md +31 -29
- package/kits/coder/skills/plan-writing/SKILL.md +52 -59
- package/kits/coder/skills/postgres-patterns/SKILL.md +39 -39
- package/kits/coder/skills/prompt-engineering/SKILL.md +40 -42
- package/kits/coder/skills/queue-patterns/SKILL.md +22 -16
- package/kits/coder/skills/react-native-patterns/SKILL.md +35 -33
- package/kits/coder/skills/react-patterns/SKILL.md +46 -52
- package/kits/coder/skills/realtime-patterns/SKILL.md +44 -46
- package/kits/coder/skills/redis-patterns/SKILL.md +35 -33
- package/kits/coder/skills/security-fundamentals/SKILL.md +45 -46
- package/kits/coder/skills/seo-patterns/SKILL.md +56 -62
- package/kits/coder/skills/systematic-debugging/SKILL.md +38 -39
- package/kits/coder/skills/tailwind-patterns/SKILL.md +21 -13
- package/kits/coder/skills/terraform-patterns/SKILL.md +53 -57
- package/kits/coder/skills/testing-patterns/SKILL.md +42 -47
- package/kits/coder/skills/typescript-patterns/SKILL.md +54 -68
- package/kits/coder/skills/ui-ux-pro-max/SKILL.md +362 -364
- package/package.json +1 -1
|
@@ -8,19 +8,27 @@ priority: MEDIUM
|
|
|
8
8
|
|
|
9
9
|
# Accessibility Patterns - Inclusive Design Excellence
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## ⚡ Quick Reference
|
|
12
|
+
|
|
13
|
+
- **Semantic HTML**: `<button>` not `<div onClick>` · `<nav>` `<main>` `<aside>` · `<h1>` → `<h6>` hierarchy
|
|
14
|
+
- **ARIA**: Use only when semantic HTML insufficient · `aria-label` for icon buttons · `aria-live` for dynamic content
|
|
15
|
+
- **Keyboard**: All actions reachable via keyboard · Tab order logical · Focus visible always · `Escape` closes modals
|
|
16
|
+
- **Color**: 4.5:1 contrast ratio (normal text) · 3:1 (large text) · Never color as only indicator
|
|
17
|
+
- **Images**: `alt` always · Empty `alt=""` for decorative · Describe the function not appearance
|
|
18
|
+
- **Forms**: Label every input (`for`/`htmlFor`) · Error messages linked with `aria-describedby` · Required marked
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
12
22
|
|
|
13
23
|
---
|
|
14
24
|
|
|
15
25
|
## 🎯 Core Principles
|
|
16
26
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
| **Robust** | Content must work with assistive technologies |
|
|
23
|
-
| **Inclusive First** | Build accessibility in, don't bolt it on |
|
|
27
|
+
- **Perceivable**: Information must be presentable to all senses
|
|
28
|
+
- **Operable**: UI must be operable by all users
|
|
29
|
+
- **Understandable**: Information and UI must be understandable
|
|
30
|
+
- **Robust**: Content must work with assistive technologies
|
|
31
|
+
- **Inclusive First**: Build accessibility in, don't bolt it on
|
|
24
32
|
|
|
25
33
|
```
|
|
26
34
|
❌ WRONG: Build first, add accessibility later
|
|
@@ -84,13 +92,11 @@ priority: MEDIUM
|
|
|
84
92
|
|
|
85
93
|
### Focus Management
|
|
86
94
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
| Focus trapping in modals | Tab loops within modal |
|
|
93
|
-
| Return focus on modal close | Focus returns to trigger element |
|
|
95
|
+
- All interactive elements: Must be focusable via Tab
|
|
96
|
+
- Logical focus order: Match visual reading order
|
|
97
|
+
- Visible focus indicators: Never `outline: none` without alt
|
|
98
|
+
- Focus trapping in modals: Tab loops within modal
|
|
99
|
+
- Return focus on modal close: Focus returns to trigger element
|
|
94
100
|
|
|
95
101
|
### Focus Indicator Pattern
|
|
96
102
|
|
|
@@ -137,14 +143,12 @@ button:focus:not(:focus-visible) {
|
|
|
137
143
|
|
|
138
144
|
### Semantic HTML
|
|
139
145
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
| `<header>/<footer>` | `<div class="header">` |
|
|
147
|
-
| `<article>` | `<div class="article">` |
|
|
146
|
+
- `<button>`: `<div onclick>`
|
|
147
|
+
- `<a href>`: `<span onclick>`
|
|
148
|
+
- `<nav>`: `<div class="nav">`
|
|
149
|
+
- `<main>`: `<div class="main">`
|
|
150
|
+
- `<header>/<footer>`: `<div class="header">`
|
|
151
|
+
- `<article>`: `<div class="article">`
|
|
148
152
|
|
|
149
153
|
### ARIA Usage Guidelines
|
|
150
154
|
|
|
@@ -172,11 +176,9 @@ button:focus:not(:focus-visible) {
|
|
|
172
176
|
<div role="alert" aria-live="assertive">Error: Unable to save changes</div>
|
|
173
177
|
```
|
|
174
178
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
| `assertive` | Urgent (errors, alerts) |
|
|
179
|
-
| `off` | Don't announce |
|
|
179
|
+
- `polite`: Non-urgent updates (search results)
|
|
180
|
+
- `assertive`: Urgent (errors, alerts)
|
|
181
|
+
- `off`: Don't announce
|
|
180
182
|
|
|
181
183
|
---
|
|
182
184
|
|
|
@@ -216,11 +218,9 @@ button:focus:not(:focus-visible) {
|
|
|
216
218
|
|
|
217
219
|
### Form Validation Pattern
|
|
218
220
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
| On blur | Validate individual field |
|
|
223
|
-
| On fix | Clear error, don't re-announce success |
|
|
221
|
+
- On submit: Announce error count, focus first error
|
|
222
|
+
- On blur: Validate individual field
|
|
223
|
+
- On fix: Clear error, don't re-announce success
|
|
224
224
|
|
|
225
225
|
---
|
|
226
226
|
|
|
@@ -228,12 +228,10 @@ button:focus:not(:focus-visible) {
|
|
|
228
228
|
|
|
229
229
|
### Alt Text Guidelines
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
| Functional (link) | Describe destination/action |
|
|
236
|
-
| Complex (chart) | Brief alt + longer description |
|
|
231
|
+
- Informative: Describe content and purpose
|
|
232
|
+
- Decorative: `alt=""` (empty)
|
|
233
|
+
- Functional (link): Describe destination/action
|
|
234
|
+
- Complex (chart): Brief alt + longer description
|
|
237
235
|
|
|
238
236
|
```html
|
|
239
237
|
<!-- Informative -->
|
|
@@ -251,12 +249,10 @@ button:focus:not(:focus-visible) {
|
|
|
251
249
|
|
|
252
250
|
### Video Accessibility
|
|
253
251
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
| Deafblind users | Transcript |
|
|
259
|
-
| Seizure safety | No flashing >3 times/second |
|
|
252
|
+
- Deaf users: Captions (synchronized text)
|
|
253
|
+
- Blind users: Audio descriptions
|
|
254
|
+
- Deafblind users: Transcript
|
|
255
|
+
- Seizure safety: No flashing >3 times/second
|
|
260
256
|
|
|
261
257
|
---
|
|
262
258
|
|
|
@@ -264,12 +260,10 @@ button:focus:not(:focus-visible) {
|
|
|
264
260
|
|
|
265
261
|
### Touch Target Size
|
|
266
262
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
| Apple HIG | 44x44pt |
|
|
272
|
-
| Material Design | 48x48dp |
|
|
263
|
+
- WCAG 2.2 AA: 24x24px
|
|
264
|
+
- WCAG 2.2 AAA: 44x44px
|
|
265
|
+
- Apple HIG: 44x44pt
|
|
266
|
+
- Material Design: 48x48dp
|
|
273
267
|
|
|
274
268
|
### Spacing Between Targets
|
|
275
269
|
|
|
@@ -287,38 +281,32 @@ button:focus:not(:focus-visible) {
|
|
|
287
281
|
|
|
288
282
|
### Automated Testing
|
|
289
283
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
| **pa11y** | CLI tool for CI/CD |
|
|
296
|
-
| **jest-axe** | Unit test accessibility assertions |
|
|
284
|
+
- **axe DevTools**: Browser extension, CI integration
|
|
285
|
+
- **Lighthouse**: Chrome DevTools, performance + a11y
|
|
286
|
+
- **WAVE**: Browser extension, visual feedback
|
|
287
|
+
- **pa11y**: CLI tool for CI/CD
|
|
288
|
+
- **jest-axe**: Unit test accessibility assertions
|
|
297
289
|
|
|
298
290
|
### Manual Testing
|
|
299
291
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
| Color contrast | Use contrast checker tools |
|
|
306
|
-
| Motion reduced | Test `prefers-reduced-motion` |
|
|
292
|
+
- Keyboard only: Unplug mouse, navigate with Tab
|
|
293
|
+
- Screen reader: VoiceOver (Mac), NVDA/JAWS (Windows)
|
|
294
|
+
- Zoom 200%: Browser zoom, check layout
|
|
295
|
+
- Color contrast: Use contrast checker tools
|
|
296
|
+
- Motion reduced: Test `prefers-reduced-motion`
|
|
307
297
|
|
|
308
298
|
---
|
|
309
299
|
|
|
310
300
|
## 🚨 Anti-Patterns
|
|
311
301
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
| Missing form labels | Associated labels or aria-label |
|
|
321
|
-
| Small touch targets | Minimum 44x44 touch targets |
|
|
302
|
+
- `outline: none` without alt: Custom focus with adequate contrast
|
|
303
|
+
- Color-only indicators: Multiple visual cues
|
|
304
|
+
- Generic link text ("click here"): Descriptive link text
|
|
305
|
+
- Auto-playing media: User-controlled playback
|
|
306
|
+
- Time limits without extension: Allow time extension or removal
|
|
307
|
+
- Mouse-only interactions: Keyboard equivalent for all actions
|
|
308
|
+
- Missing form labels: Associated labels or aria-label
|
|
309
|
+
- Small touch targets: Minimum 44x44 touch targets
|
|
322
310
|
|
|
323
311
|
---
|
|
324
312
|
|
|
@@ -360,12 +348,10 @@ button:focus:not(:focus-visible) {
|
|
|
360
348
|
|
|
361
349
|
## 🔗 Related Skills
|
|
362
350
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
| UX research | UX researcher agent |
|
|
368
|
-
| Performance | `performance-profiling` |
|
|
351
|
+
- SEO implementation: `seo-patterns`
|
|
352
|
+
- Frontend design: `frontend-design`
|
|
353
|
+
- UX research: UX researcher agent
|
|
354
|
+
- Performance: `performance-profiling`
|
|
369
355
|
|
|
370
356
|
---
|
|
371
357
|
|
|
@@ -7,19 +7,27 @@ version: 2.0
|
|
|
7
7
|
|
|
8
8
|
# AI RAG Patterns - Retrieval-Augmented Generation
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## ⚡ Quick Reference
|
|
11
|
+
|
|
12
|
+
- **Chunking**: 512-1024 tokens optimal · Overlap 20% · Respect document boundaries (headings)
|
|
13
|
+
- **Embeddings**: `text-embedding-3-small` for cost · `text-embedding-3-large` for quality · Normalize vectors
|
|
14
|
+
- **Vector DB**: Pinecone (managed) · Pgvector (Postgres) · Chroma (local) · Weaviate (hybrid)
|
|
15
|
+
- **Retrieval**: Top-k=5-10 · Reranker improves precision · Hybrid (dense+sparse) for best recall
|
|
16
|
+
- **Prompt**: System prompt + context + query · Cap context < model limit - response buffer
|
|
17
|
+
- **Evaluation**: Faithfulness · Answer relevancy · Context recall · Use RAGAS for metrics
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
11
21
|
|
|
12
22
|
---
|
|
13
23
|
|
|
14
24
|
## When to Use This Skill
|
|
15
25
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
| Domain-specific knowledge access | Simple keyword search |
|
|
22
|
-
| Document processing pipelines | Real-time streaming data |
|
|
26
|
+
- Building Q&A over documents: Pure generative tasks
|
|
27
|
+
- Semantic search implementation: Dataset too small (<100 docs)
|
|
28
|
+
- Reducing LLM hallucinations: Data privacy restrictions
|
|
29
|
+
- Domain-specific knowledge access: Simple keyword search
|
|
30
|
+
- Document processing pipelines: Real-time streaming data
|
|
23
31
|
|
|
24
32
|
---
|
|
25
33
|
|
|
@@ -403,15 +411,13 @@ langchain.llm_cache = RedisSemanticCache(
|
|
|
403
411
|
|
|
404
412
|
## Anti-Patterns
|
|
405
413
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
| Measure only final answer | Evaluate retrieval separately |
|
|
414
|
-
| Ignore metadata | Add rich metadata for filtering |
|
|
414
|
+
- Fixed-size chunking only: Semantic chunking + structure-aware
|
|
415
|
+
- Pure vector search: Hybrid search (dense + sparse)
|
|
416
|
+
- Use first retrieval results: Rerank before generation
|
|
417
|
+
- Same embedding for all content: Evaluate per content type
|
|
418
|
+
- Cram max context into prompt: Use relevance thresholds
|
|
419
|
+
- Measure only final answer: Evaluate retrieval separately
|
|
420
|
+
- Ignore metadata: Add rich metadata for filtering
|
|
415
421
|
|
|
416
422
|
---
|
|
417
423
|
|
|
@@ -432,12 +438,10 @@ Before deployment:
|
|
|
432
438
|
|
|
433
439
|
## Related Skills
|
|
434
440
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
| Redis caching | `redis-patterns` |
|
|
440
|
-
| API design | `api-patterns` |
|
|
441
|
+
- LLM prompt design: `prompt-engineering`
|
|
442
|
+
- Vector DB (Postgres): `postgres-patterns`
|
|
443
|
+
- Redis caching: `redis-patterns`
|
|
444
|
+
- API design: `api-patterns`
|
|
441
445
|
|
|
442
446
|
---
|
|
443
447
|
|
|
@@ -7,7 +7,16 @@ version: 2.0
|
|
|
7
7
|
|
|
8
8
|
# API Patterns - Design Principles & Decision Making
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## ⚡ Quick Reference
|
|
11
|
+
|
|
12
|
+
- **Style selection**: Public API → REST · Complex UI → GraphQL · TS monorepo internal → tRPC
|
|
13
|
+
- **REST naming**: nouns not verbs · `GET /users` not `GET /getUsers` · HTTP method = action
|
|
14
|
+
- **Status codes**: 200 OK · 201 Created · 204 Delete · 400 Bad · 401 Unauth · 403 Forbidden · 404 NotFound · 422 Validation · 429 RateLimit
|
|
15
|
+
- **Pagination**: `< 1000 rows` → offset · `> 10000 rows / infinite scroll` → cursor
|
|
16
|
+
- **Auth**: JWT (15min access + 7d refresh in httpOnly cookie) · Versioning: URI path `/v1/`
|
|
17
|
+
- **Response envelope**: `{ data: {}, meta: { requestId, timestamp } }` · errors: `{ error: { code, message } }`
|
|
18
|
+
|
|
19
|
+
---
|
|
11
20
|
|
|
12
21
|
---
|
|
13
22
|
|
|
@@ -38,13 +47,11 @@ What are your requirements?
|
|
|
38
47
|
|
|
39
48
|
### Resource Naming
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
| `DELETE /users/:id` | `POST /deleteUser` |
|
|
47
|
-
| `/users/:id/orders` | `/getUserOrders` |
|
|
50
|
+
- `GET /users`: `GET /getUsers`
|
|
51
|
+
- `GET /users/:id`: `GET /user?id=123`
|
|
52
|
+
- `POST /users`: `POST /createUser`
|
|
53
|
+
- `DELETE /users/:id`: `POST /deleteUser`
|
|
54
|
+
- `/users/:id/orders`: `/getUserOrders`
|
|
48
55
|
|
|
49
56
|
### HTTP Methods
|
|
50
57
|
|
|
@@ -108,13 +115,11 @@ What are your requirements?
|
|
|
108
115
|
|
|
109
116
|
### Error Code Naming
|
|
110
117
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
| `PERMISSION_DENIED` | `PERMISSION_DENIED` |
|
|
117
|
-
| `RATE_LIMITED` | `RATE_LIMITED` |
|
|
118
|
+
- `RESOURCE_NOT_FOUND`: `USER_NOT_FOUND`, `ORDER_NOT_FOUND`
|
|
119
|
+
- `RESOURCE_ALREADY_EXISTS`: `EMAIL_ALREADY_EXISTS`
|
|
120
|
+
- `INVALID_FIELD`: `INVALID_EMAIL`, `INVALID_PHONE`
|
|
121
|
+
- `PERMISSION_DENIED`: `PERMISSION_DENIED`
|
|
122
|
+
- `RATE_LIMITED`: `RATE_LIMITED`
|
|
118
123
|
|
|
119
124
|
---
|
|
120
125
|
|
|
@@ -161,14 +166,12 @@ Response:
|
|
|
161
166
|
|
|
162
167
|
### Decision Matrix
|
|
163
168
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
| Infinite scroll UI | Cursor |
|
|
171
|
-
| Table with page numbers | Offset |
|
|
169
|
+
- Small dataset (<1000): Offset
|
|
170
|
+
- Large dataset (>10000): Cursor
|
|
171
|
+
- Frequently changing data: Cursor
|
|
172
|
+
- Random page access needed: Offset
|
|
173
|
+
- Infinite scroll UI: Cursor
|
|
174
|
+
- Table with page numbers: Offset
|
|
172
175
|
|
|
173
176
|
---
|
|
174
177
|
|
|
@@ -218,11 +221,9 @@ v1 (retired) → Returns 410 Gone
|
|
|
218
221
|
|
|
219
222
|
### Strategies
|
|
220
223
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
| **Sliding Window** | Smooth rate control |
|
|
225
|
-
| **Fixed Window** | Simple but allows burst at boundaries |
|
|
224
|
+
- **Token Bucket**: Allows bursts, refills over time
|
|
225
|
+
- **Sliding Window**: Smooth rate control
|
|
226
|
+
- **Fixed Window**: Simple but allows burst at boundaries
|
|
226
227
|
|
|
227
228
|
### Response Headers
|
|
228
229
|
|
|
@@ -274,15 +275,13 @@ When using tRPC (TypeScript-first):
|
|
|
274
275
|
|
|
275
276
|
## Anti-Patterns
|
|
276
277
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
| Version in request body | Version in URL path |
|
|
285
|
-
| Return all fields always | Support field selection |
|
|
278
|
+
- Use verbs in REST endpoints: Use nouns + HTTP methods
|
|
279
|
+
- Return 200 for errors: Use appropriate status codes
|
|
280
|
+
- Expose stack traces: Return structured error codes
|
|
281
|
+
- Skip rate limiting: Implement from day 1
|
|
282
|
+
- Inconsistent response format: Define envelope pattern
|
|
283
|
+
- Version in request body: Version in URL path
|
|
284
|
+
- Return all fields always: Support field selection
|
|
286
285
|
|
|
287
286
|
---
|
|
288
287
|
|
|
@@ -304,12 +303,10 @@ Before implementing:
|
|
|
304
303
|
|
|
305
304
|
## Related Skills
|
|
306
305
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
| Security hardening | `security-fundamentals` |
|
|
312
|
-
| Testing APIs | `testing-patterns` |
|
|
306
|
+
- Backend implementation: `nodejs-best-practices`
|
|
307
|
+
- Database design: `database-design`
|
|
308
|
+
- Security hardening: `security-fundamentals`
|
|
309
|
+
- Testing APIs: `testing-patterns`
|
|
313
310
|
|
|
314
311
|
---
|
|
315
312
|
|
|
@@ -8,19 +8,27 @@ priority: HIGH
|
|
|
8
8
|
|
|
9
9
|
# Auth Patterns - Security-First Access Control
|
|
10
10
|
|
|
11
|
+
## ⚡ Quick Reference
|
|
12
|
+
|
|
13
|
+
- **Password**: bcrypt (cost 12) or Argon2id · Never MD5/SHA1 · No plaintext comparison
|
|
14
|
+
- **JWT**: Access 15min · Refresh 7d in httpOnly SameSite=Strict cookie · RS256 for multi-service
|
|
15
|
+
- **OAuth 2.0**: Authorization Code + PKCE for SPA/mobile · Client Credentials for M2M · Never Implicit flow
|
|
16
|
+
- **Session**: Rotate ID after login · Invalidate on logout · SameSite=Strict cookie
|
|
17
|
+
- **MFA**: TOTP (Authenticator) preferred · SMS as fallback only · Rate limit OTP attempts
|
|
18
|
+
- **Rate limiting**: 5 failed logins → lockout 15min · Per-IP + per-account limits
|
|
19
|
+
|
|
20
|
+
---
|
|
11
21
|
> **Philosophy:** Authentication answers "Who are you?" Authorization answers "What can you do?" Both must be **server-validated**, never trust the client.
|
|
12
22
|
|
|
13
23
|
---
|
|
14
24
|
|
|
15
25
|
## Core Principles
|
|
16
26
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
| **Secure defaults** | Default deny, explicitly grant access |
|
|
23
|
-
| **Audit everything** | Log auth events for security monitoring |
|
|
27
|
+
- **Server-side**: All auth checks happen on server, never just client
|
|
28
|
+
- **Defense in depth**: Multiple layers: HTTPS + tokens + validation + rate limit
|
|
29
|
+
- **Least privilege**: Grant minimum permissions needed
|
|
30
|
+
- **Secure defaults**: Default deny, explicitly grant access
|
|
31
|
+
- **Audit everything**: Log auth events for security monitoring
|
|
24
32
|
|
|
25
33
|
---
|
|
26
34
|
|
|
@@ -124,13 +132,11 @@ async function requireOwnership(req, res, next) {
|
|
|
124
132
|
|
|
125
133
|
## Password Security
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
| **Never log passwords** | Not even errors |
|
|
133
|
-
| **Secure reset flow** | Time-limited token via email |
|
|
135
|
+
- **Hash with bcrypt**: Salt rounds: 12+
|
|
136
|
+
- **Min 12 characters**: + uppercase + lowercase + number + special
|
|
137
|
+
- **Rate limit attempts**: 5 attempts per 15 min
|
|
138
|
+
- **Never log passwords**: Not even errors
|
|
139
|
+
- **Secure reset flow**: Time-limited token via email
|
|
134
140
|
|
|
135
141
|
### Password Flow
|
|
136
142
|
|
|
@@ -166,11 +172,9 @@ res.cookie("token", accessToken, {
|
|
|
166
172
|
|
|
167
173
|
## OAuth2 Simplified
|
|
168
174
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
| **PKCE** | SPAs, mobile apps (public clients) |
|
|
173
|
-
| **Client Credentials** | Service-to-service |
|
|
175
|
+
- **Authorization Code**: Web apps with backend
|
|
176
|
+
- **PKCE**: SPAs, mobile apps (public clients)
|
|
177
|
+
- **Client Credentials**: Service-to-service
|
|
174
178
|
|
|
175
179
|
### Basic OAuth2 Flow
|
|
176
180
|
|
|
@@ -214,53 +218,45 @@ Need access from JavaScript?
|
|
|
214
218
|
|
|
215
219
|
## Anti-Patterns (DON'T)
|
|
216
220
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
| JWT without expiration | Always set `exp` claim |
|
|
226
|
-
| Hardcoded secrets in code | Environment variables |
|
|
221
|
+
- Store JWT in localStorage: httpOnly cookie or memory
|
|
222
|
+
- Plain text passwords in DB: bcrypt hash with salt
|
|
223
|
+
- Long-lived access tokens (24h+): 15 min access + 7d refresh
|
|
224
|
+
- Client-only auth checks: Server validates every request
|
|
225
|
+
- Same secret for access & refresh: Separate secrets
|
|
226
|
+
- No rate limiting on login: 5 attempts / 15 min
|
|
227
|
+
- JWT without expiration: Always set `exp` claim
|
|
228
|
+
- Hardcoded secrets in code: Environment variables
|
|
227
229
|
|
|
228
230
|
---
|
|
229
231
|
|
|
230
232
|
## Security Checklist
|
|
231
233
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
| **Logging** | Auth events logged, no sensitive data |
|
|
240
|
-
| **CORS** | Strict origin whitelist |
|
|
234
|
+
- **Transport**: HTTPS everywhere, HSTS enabled
|
|
235
|
+
- **Passwords**: bcrypt 12+, strong policy enforced
|
|
236
|
+
- **Tokens**: Short-lived, httpOnly, secure cookies
|
|
237
|
+
- **Rate Limit**: Login, registration, password reset
|
|
238
|
+
- **Headers**: CSP, X-Frame-Options, X-Content-Type
|
|
239
|
+
- **Logging**: Auth events logged, no sensitive data
|
|
240
|
+
- **CORS**: Strict origin whitelist
|
|
241
241
|
|
|
242
242
|
---
|
|
243
243
|
|
|
244
244
|
## 🔴 Self-Check Before Completing
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
| ✅ **HTTPS?** | All traffic encrypted? |
|
|
253
|
-
| ✅ **No secrets in code?** | Environment variables only? |
|
|
246
|
+
- ✅ **Server validated?**: All auth happens server-side?
|
|
247
|
+
- ✅ **Tokens secure?**: httpOnly, secure, short-lived?
|
|
248
|
+
- ✅ **Passwords hashed?**: bcrypt with 12+ rounds?
|
|
249
|
+
- ✅ **Rate limited?**: Login endpoint protected?
|
|
250
|
+
- ✅ **HTTPS?**: All traffic encrypted?
|
|
251
|
+
- ✅ **No secrets in code?**: Environment variables only?
|
|
254
252
|
|
|
255
253
|
---
|
|
256
254
|
|
|
257
255
|
## Related Skills
|
|
258
256
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
| Security auditing | `security-fundamentals` |
|
|
263
|
-
| Database design | `database-design` |
|
|
257
|
+
- API design: `api-patterns`
|
|
258
|
+
- Security auditing: `security-fundamentals`
|
|
259
|
+
- Database design: `database-design`
|
|
264
260
|
|
|
265
261
|
---
|
|
266
262
|
|