ai-nexus 1.3.8 → 1.3.10
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.ko.md +7 -12
- package/README.md +8 -13
- package/config/commands/debug.md +31 -0
- package/config/commands/refactor.md +30 -0
- package/config/commands/test.md +47 -0
- package/config/contexts/debug.md +35 -0
- package/config/contexts/research.md +33 -0
- package/config/hooks/README.md +3 -7
- package/config/rules/error-handling.md +52 -0
- package/config/rules/naming.md +35 -0
- package/config/rules/testing.md +37 -0
- package/config/rules/typescript.md +38 -0
- package/config/skills/api-design.md +59 -0
- package/config/skills/docker.md +50 -0
- package/config/skills/go.md +43 -0
- package/config/skills/nextjs.md +41 -0
- package/config/skills/python.md +49 -0
- package/config/skills/rust.md +49 -0
- package/config/skills/svelte.md +49 -0
- package/config/skills/vue.md +45 -0
- package/dist/utils/semantic-router.js +32 -2
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -19,14 +19,9 @@ npx ai-nexus install
|
|
|
19
19
|
|
|
20
20
|
## 문제
|
|
21
21
|
|
|
22
|
-
Claude Code에 질문할 때마다 **모든** 룰이
|
|
22
|
+
Claude Code에 질문할 때마다 **모든** 룰이 로드됩니다 — Git 커밋을 물어보는데 React 룰까지, 스타일링을 하는데 보안 룰까지.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
Loading rules... 4,300 lines
|
|
26
|
-
토큰 비용: 요청당 ~5,000 토큰
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Git 커밋에 대해 물어보는데 React 룰까지 로드되는 건 낭비입니다.
|
|
24
|
+
룰을 추가할수록 매 프롬프트마다 낭비되는 토큰이 늘어납니다.
|
|
30
25
|
|
|
31
26
|
## 해결
|
|
32
27
|
|
|
@@ -41,7 +36,7 @@ Semantic Router 활성화:
|
|
|
41
36
|
✗ react.md (건너뜀)
|
|
42
37
|
✗ security.md (건너뜀)
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
룰을 얼마든지 추가하세요 — 필요한 것만 로딩됩니다.
|
|
45
40
|
```
|
|
46
41
|
|
|
47
42
|
---
|
|
@@ -77,11 +72,11 @@ npx ai-nexus install --rules github.com/your-org/team-rules
|
|
|
77
72
|
|
|
78
73
|
## 지원 도구
|
|
79
74
|
|
|
80
|
-
| 도구 | 동작 방식 | 토큰
|
|
75
|
+
| 도구 | 동작 방식 | 토큰 부담 |
|
|
81
76
|
|------|-----------|-----------|
|
|
82
|
-
| **Claude Code** | 시맨틱 라우터가 프롬프트마다 동적으로 룰 교체 |
|
|
83
|
-
| **Cursor** | `.mdc` description 필드를 통한 시맨틱 서치 |
|
|
84
|
-
| **Codex** | 정적 `AGENTS.md` (동적 로딩 없음) |
|
|
77
|
+
| **Claude Code** | 시맨틱 라우터가 프롬프트마다 동적으로 룰 교체 | 필요한 룰만 로딩 |
|
|
78
|
+
| **Cursor** | `.mdc` description 필드를 통한 시맨틱 서치 | Description 기반 필터링 |
|
|
79
|
+
| **Codex** | 정적 `AGENTS.md` (동적 로딩 없음) | 전체 룰 로딩 |
|
|
85
80
|
|
|
86
81
|
---
|
|
87
82
|
|
package/README.md
CHANGED
|
@@ -19,14 +19,9 @@ npx ai-nexus install
|
|
|
19
19
|
|
|
20
20
|
## The Problem
|
|
21
21
|
|
|
22
|
-
Every time you ask Claude Code a question, it loads **all** your rules
|
|
22
|
+
Every time you ask Claude Code a question, it loads **all** your rules — React rules when you're asking about Git commits, security rules when you're styling a button.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
Loading rules... 4,300 lines
|
|
26
|
-
Token cost: ~5,000 tokens per request
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
That's tokens wasted on React rules when you're asking about Git commits.
|
|
24
|
+
The more rules you add, the more tokens get wasted on every single prompt.
|
|
30
25
|
|
|
31
26
|
## The Solution
|
|
32
27
|
|
|
@@ -41,7 +36,7 @@ Semantic Router activates:
|
|
|
41
36
|
✗ react.md (skipped)
|
|
42
37
|
✗ security.md (skipped)
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
Add as many rules as you want — only the relevant ones are loaded.
|
|
45
40
|
```
|
|
46
41
|
|
|
47
42
|
---
|
|
@@ -77,11 +72,11 @@ npx ai-nexus install --rules github.com/your-org/team-rules
|
|
|
77
72
|
|
|
78
73
|
## Supported Tools
|
|
79
74
|
|
|
80
|
-
| Tool | How it works | Token
|
|
81
|
-
|
|
82
|
-
| **Claude Code** | Semantic Router dynamically swaps rules per prompt |
|
|
83
|
-
| **Cursor** | Semantic Search via `.mdc` description fields |
|
|
84
|
-
| **Codex** | Static `AGENTS.md` (no dynamic loading) |
|
|
75
|
+
| Tool | How it works | Token overhead |
|
|
76
|
+
|------|--------------|----------------|
|
|
77
|
+
| **Claude Code** | Semantic Router dynamically swaps rules per prompt | Only relevant rules loaded |
|
|
78
|
+
| **Cursor** | Semantic Search via `.mdc` description fields | Description-based filtering |
|
|
79
|
+
| **Codex** | Static `AGENTS.md` (no dynamic loading) | All rules loaded |
|
|
85
80
|
|
|
86
81
|
---
|
|
87
82
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Debugging slash command
|
|
3
|
+
keywords: [debug, bug, fix, issue, error]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /debug
|
|
7
|
+
|
|
8
|
+
When asked to debug an issue:
|
|
9
|
+
|
|
10
|
+
1. **Reproduce** — Understand the exact steps to trigger the bug
|
|
11
|
+
2. **Read error** — Analyze the full error message and stack trace
|
|
12
|
+
3. **Locate** — Find the exact line/function where the error originates
|
|
13
|
+
4. **Understand** — Read surrounding code to understand intended behavior
|
|
14
|
+
5. **Fix** — Make the minimal change to fix the root cause
|
|
15
|
+
6. **Verify** — Run tests or demonstrate the fix works
|
|
16
|
+
|
|
17
|
+
## Debugging Checklist
|
|
18
|
+
- Read the full error message and stack trace
|
|
19
|
+
- Check recent changes (git diff, git log)
|
|
20
|
+
- Verify inputs at the failure point
|
|
21
|
+
- Check for null/undefined values
|
|
22
|
+
- Check for type mismatches
|
|
23
|
+
- Check async/await and promise handling
|
|
24
|
+
- Check environment variables and config
|
|
25
|
+
|
|
26
|
+
## Rules
|
|
27
|
+
- Fix the root cause, not the symptom
|
|
28
|
+
- Don't add try/catch to hide errors
|
|
29
|
+
- Don't change unrelated code while debugging
|
|
30
|
+
- Write a test that reproduces the bug before fixing
|
|
31
|
+
- Explain what caused the bug and why the fix works
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Code refactoring slash command
|
|
3
|
+
keywords: [refactor, clean, improve, simplify]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /refactor
|
|
7
|
+
|
|
8
|
+
When asked to refactor code:
|
|
9
|
+
|
|
10
|
+
1. **Analyze first** — Read the entire file before making changes
|
|
11
|
+
2. **Identify issues** — List specific problems (duplication, complexity, naming)
|
|
12
|
+
3. **Propose changes** — Explain what you'll change and why
|
|
13
|
+
4. **Preserve behavior** — Refactoring must not change functionality
|
|
14
|
+
5. **Verify** — Run existing tests after refactoring
|
|
15
|
+
|
|
16
|
+
## Refactoring Checklist
|
|
17
|
+
- Extract repeated code into functions
|
|
18
|
+
- Simplify nested conditionals (guard clauses, early returns)
|
|
19
|
+
- Rename unclear variables and functions
|
|
20
|
+
- Split large functions (> 50 lines)
|
|
21
|
+
- Split large files (> 300 lines)
|
|
22
|
+
- Remove dead code
|
|
23
|
+
- Replace magic numbers with named constants
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
- Make one type of change at a time
|
|
27
|
+
- Keep each change small and reviewable
|
|
28
|
+
- Don't add features during refactoring
|
|
29
|
+
- Don't change formatting during logic refactoring
|
|
30
|
+
- If tests don't exist, write them before refactoring
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Test generation slash command
|
|
3
|
+
keywords: [test, generate, spec, unit]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /test
|
|
7
|
+
|
|
8
|
+
When asked to write tests:
|
|
9
|
+
|
|
10
|
+
1. **Read the source** — Understand what the code does before writing tests
|
|
11
|
+
2. **Identify cases** — Happy path, edge cases, error cases
|
|
12
|
+
3. **Write tests** — Use AAA pattern (Arrange, Act, Assert)
|
|
13
|
+
4. **Run tests** — Verify they pass
|
|
14
|
+
5. **Check coverage** — Ensure critical paths are covered
|
|
15
|
+
|
|
16
|
+
## Test Structure
|
|
17
|
+
```typescript
|
|
18
|
+
describe('functionName', () => {
|
|
19
|
+
it('should return X when given Y', () => {
|
|
20
|
+
// Arrange
|
|
21
|
+
const input = createInput();
|
|
22
|
+
|
|
23
|
+
// Act
|
|
24
|
+
const result = functionName(input);
|
|
25
|
+
|
|
26
|
+
// Assert
|
|
27
|
+
expect(result).toBe(expected);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should throw when input is invalid', () => {
|
|
31
|
+
expect(() => functionName(null)).toThrow();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## What to Cover
|
|
37
|
+
- Normal inputs → expected outputs
|
|
38
|
+
- Empty/null/undefined inputs
|
|
39
|
+
- Boundary values (0, -1, MAX)
|
|
40
|
+
- Error conditions and exceptions
|
|
41
|
+
- Async operations (resolve and reject)
|
|
42
|
+
|
|
43
|
+
## Rules
|
|
44
|
+
- One assertion per test (when practical)
|
|
45
|
+
- No test interdependence — each test runs independently
|
|
46
|
+
- Use descriptive names: "should [expected] when [condition]"
|
|
47
|
+
- Don't test private/internal methods directly
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Debug mode — systematic bug investigation
|
|
3
|
+
keywords: [debug, investigate, troubleshoot, diagnose]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debug Mode
|
|
7
|
+
|
|
8
|
+
When in debug mode:
|
|
9
|
+
|
|
10
|
+
## Mindset
|
|
11
|
+
- Be systematic, not random — follow the evidence
|
|
12
|
+
- The bug is in the code, not the framework (usually)
|
|
13
|
+
- Recent changes are the most likely cause
|
|
14
|
+
- Simplify the problem until the cause is obvious
|
|
15
|
+
|
|
16
|
+
## Investigation Steps
|
|
17
|
+
1. **Reproduce** — Get exact steps, inputs, and expected vs actual output
|
|
18
|
+
2. **Isolate** — Narrow down to the smallest reproducible case
|
|
19
|
+
3. **Trace** — Follow execution path from input to error
|
|
20
|
+
4. **Identify** — Find the exact line where behavior diverges
|
|
21
|
+
5. **Verify hypothesis** — Confirm the cause before fixing
|
|
22
|
+
|
|
23
|
+
## Common Causes
|
|
24
|
+
- Null/undefined where a value is expected
|
|
25
|
+
- Off-by-one errors in loops or array access
|
|
26
|
+
- Async race conditions (missing await)
|
|
27
|
+
- Stale closures capturing old values
|
|
28
|
+
- Type coercion surprises (== vs ===)
|
|
29
|
+
- Environment differences (dev vs prod config)
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
- Don't guess — read the code and trace the execution
|
|
33
|
+
- Don't fix multiple things at once
|
|
34
|
+
- Explain the root cause, not just the fix
|
|
35
|
+
- Write a regression test for every bug fixed
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Research mode — explore before implementing
|
|
3
|
+
keywords: [research, explore, investigate, analyze]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Research Mode
|
|
7
|
+
|
|
8
|
+
When in research mode:
|
|
9
|
+
|
|
10
|
+
## Principles
|
|
11
|
+
- Read first, code never — this is a research-only session
|
|
12
|
+
- Explore the codebase thoroughly before drawing conclusions
|
|
13
|
+
- Trust code over documentation — the codebase is the source of truth
|
|
14
|
+
- Exhaust all search methods before saying "not found"
|
|
15
|
+
|
|
16
|
+
## Process
|
|
17
|
+
1. **Map the system** — Identify key files, entry points, and data flow
|
|
18
|
+
2. **Read related code** — Follow imports, function calls, and references
|
|
19
|
+
3. **Check tests** — Tests reveal intended behavior and edge cases
|
|
20
|
+
4. **Check git history** — `git log` and `git blame` show why code exists
|
|
21
|
+
5. **Summarize findings** — Present what you found with file references
|
|
22
|
+
|
|
23
|
+
## Output Format
|
|
24
|
+
- State findings as facts with file:line references
|
|
25
|
+
- List assumptions separately from confirmed facts
|
|
26
|
+
- Identify unknowns and suggest how to investigate further
|
|
27
|
+
- Keep responses concise — bullet points over paragraphs
|
|
28
|
+
|
|
29
|
+
## Rules
|
|
30
|
+
- Don't modify any files
|
|
31
|
+
- Don't suggest changes unless explicitly asked
|
|
32
|
+
- Don't make assumptions — verify by reading code
|
|
33
|
+
- If unsure, say "I need to check X to confirm"
|
package/config/hooks/README.md
CHANGED
|
@@ -18,7 +18,7 @@ The semantic router hook analyzes keywords in prompts to **dynamically activate
|
|
|
18
18
|
↓
|
|
19
19
|
5. Claude Code loads only necessary rules
|
|
20
20
|
↓
|
|
21
|
-
6.
|
|
21
|
+
6. Only relevant rules loaded!
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Installation
|
|
@@ -101,10 +101,6 @@ OPENAI_API_KEY=sk-xxx
|
|
|
101
101
|
ANTHROPIC_API_KEY=sk-ant-xxx
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
## Token
|
|
104
|
+
## Token Efficiency
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|--------|--------------|------------------|
|
|
108
|
-
| Load all | All rules (15) | ~5000 tokens |
|
|
109
|
-
| Semantic Router | Only needed (2-3) | ~800 tokens |
|
|
110
|
-
| **Savings** | | **~84%** |
|
|
106
|
+
Add as many rules as you need — the Semantic Router loads only the relevant ones per prompt, so token usage stays minimal regardless of how many rules you have.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Error handling patterns and best practices
|
|
3
|
+
keywords: [error, exception, handling, try, catch]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Error Handling
|
|
7
|
+
|
|
8
|
+
## Principles
|
|
9
|
+
- Handle errors at the beginning of functions
|
|
10
|
+
- Use early returns for error conditions to avoid deep nesting
|
|
11
|
+
- Place the happy path last for readability
|
|
12
|
+
- Use guard clauses for preconditions and invalid states
|
|
13
|
+
|
|
14
|
+
## Patterns
|
|
15
|
+
- Avoid unnecessary else — use if-return pattern
|
|
16
|
+
- Use custom error types for domain-specific errors
|
|
17
|
+
- Model expected errors as return values, not exceptions
|
|
18
|
+
- Use error boundaries for unexpected errors (React error.tsx)
|
|
19
|
+
|
|
20
|
+
## Do
|
|
21
|
+
```typescript
|
|
22
|
+
function process(input: string): Result {
|
|
23
|
+
if (!input) return { error: 'Input required' };
|
|
24
|
+
if (input.length > MAX) return { error: 'Too long' };
|
|
25
|
+
|
|
26
|
+
// Happy path
|
|
27
|
+
const result = transform(input);
|
|
28
|
+
return { data: result };
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Don't
|
|
33
|
+
```typescript
|
|
34
|
+
function process(input: string): Result {
|
|
35
|
+
if (input) {
|
|
36
|
+
if (input.length <= MAX) {
|
|
37
|
+
const result = transform(input);
|
|
38
|
+
return { data: result };
|
|
39
|
+
} else {
|
|
40
|
+
return { error: 'Too long' };
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
return { error: 'Input required' };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Logging
|
|
49
|
+
- Log errors with enough context to reproduce
|
|
50
|
+
- Include: what failed, input values, stack trace
|
|
51
|
+
- Never log sensitive data (passwords, tokens, PII)
|
|
52
|
+
- Use structured logging (JSON) in production
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Naming conventions for variables, functions, and files
|
|
3
|
+
keywords: [naming, convention, variable, function]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Naming Conventions
|
|
7
|
+
|
|
8
|
+
## Variables
|
|
9
|
+
- Use descriptive names with auxiliary verbs: `isLoading`, `hasError`, `canSubmit`
|
|
10
|
+
- Boolean: prefix with `is`, `has`, `can`, `should`
|
|
11
|
+
- Arrays: use plural nouns (`users`, `items`)
|
|
12
|
+
- Numbers: prefix with `num`, `max`, `min`, `total` (`maxRetries`, `totalCount`)
|
|
13
|
+
|
|
14
|
+
## Functions
|
|
15
|
+
- Use verbs: `getUser`, `createOrder`, `validateInput`
|
|
16
|
+
- Event handlers: `handleClick`, `onSubmit`
|
|
17
|
+
- Return boolean: `isValid`, `hasPermission`, `canAccess`
|
|
18
|
+
- Async functions: describe the result, not the mechanism (`fetchUser`, not `asyncGetUser`)
|
|
19
|
+
|
|
20
|
+
## Files and Directories
|
|
21
|
+
- Use lowercase with dashes: `auth-wizard.ts`, `user-profile/`
|
|
22
|
+
- Component files match component name: `UserProfile.tsx`
|
|
23
|
+
- Test files: `user-profile.test.ts`
|
|
24
|
+
- Types: `user.types.ts` or co-locate with source
|
|
25
|
+
|
|
26
|
+
## Constants
|
|
27
|
+
- UPPER_SNAKE_CASE for true constants: `MAX_RETRIES`, `API_BASE_URL`
|
|
28
|
+
- camelCase for const references: `const defaultConfig = { ... }`
|
|
29
|
+
|
|
30
|
+
## Avoid
|
|
31
|
+
- Single letter names (except `i` in loops, `e` in event handlers)
|
|
32
|
+
- Abbreviations: `btn`, `usr`, `msg` → `button`, `user`, `message`
|
|
33
|
+
- Generic names: `data`, `info`, `item`, `thing`
|
|
34
|
+
- Hungarian notation: `strName`, `bIsActive`
|
|
35
|
+
- Negated booleans: `isNotReady` → `isReady`
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Testing best practices and conventions
|
|
3
|
+
keywords: [test, testing, unit, integration, e2e, vitest, jest]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Testing
|
|
7
|
+
|
|
8
|
+
## Principles
|
|
9
|
+
- Write tests first when fixing bugs (TDD for bug fixes)
|
|
10
|
+
- Test behavior, not implementation details
|
|
11
|
+
- Each test should have a single reason to fail
|
|
12
|
+
- Keep tests independent — no shared mutable state
|
|
13
|
+
|
|
14
|
+
## Structure
|
|
15
|
+
- Use AAA pattern: Arrange → Act → Assert
|
|
16
|
+
- Use descriptive test names: "should return error when input is empty"
|
|
17
|
+
- Group related tests with `describe` blocks
|
|
18
|
+
- Keep test files next to source: `foo.ts` → `foo.test.ts`
|
|
19
|
+
|
|
20
|
+
## What to Test
|
|
21
|
+
- Unit tests for pure functions and utilities
|
|
22
|
+
- Integration tests for API endpoints and database queries
|
|
23
|
+
- E2E tests for critical user flows only
|
|
24
|
+
- Edge cases: empty input, null, boundaries, error paths
|
|
25
|
+
|
|
26
|
+
## What NOT to Test
|
|
27
|
+
- Third-party library internals
|
|
28
|
+
- Trivial getters/setters
|
|
29
|
+
- Framework boilerplate
|
|
30
|
+
- Implementation details that may change
|
|
31
|
+
|
|
32
|
+
## Practices
|
|
33
|
+
- Prefer real objects over mocks when practical
|
|
34
|
+
- Use factories or builders for test data, not fixtures
|
|
35
|
+
- Run single tests during development, full suite in CI
|
|
36
|
+
- Aim for 80% coverage, but don't chase 100%
|
|
37
|
+
- Failing test first, then make it pass, then refactor
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: TypeScript best practices and coding standards
|
|
3
|
+
keywords: [typescript, ts, type, interface]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TypeScript
|
|
7
|
+
|
|
8
|
+
## Key Principles
|
|
9
|
+
- Use TypeScript for all code. Prefer interfaces over types
|
|
10
|
+
- Avoid enums — use const objects or maps instead
|
|
11
|
+
- Use `function` keyword for pure functions
|
|
12
|
+
- Prefer iteration and modularization over duplication
|
|
13
|
+
- Use descriptive variable names with auxiliary verbs (isLoading, hasError)
|
|
14
|
+
|
|
15
|
+
## Types
|
|
16
|
+
- Prefer `interface` for object shapes, `type` for unions/intersections
|
|
17
|
+
- Use `unknown` over `any`. Narrow types with guards
|
|
18
|
+
- Avoid type assertions (`as`) — prefer type narrowing
|
|
19
|
+
- Use `satisfies` operator for type checking without widening
|
|
20
|
+
- Define return types explicitly for public functions
|
|
21
|
+
|
|
22
|
+
## Patterns
|
|
23
|
+
- Use discriminated unions for state modeling
|
|
24
|
+
- Prefer `readonly` arrays and properties where possible
|
|
25
|
+
- Use `Record<K, V>` for dictionary types
|
|
26
|
+
- Avoid `null` — prefer `undefined` for optional values
|
|
27
|
+
- Use optional chaining (`?.`) and nullish coalescing (`??`)
|
|
28
|
+
|
|
29
|
+
## Imports
|
|
30
|
+
- Use ES modules (import/export), not CommonJS (require)
|
|
31
|
+
- Destructure imports when possible
|
|
32
|
+
- Group imports: external → internal → types
|
|
33
|
+
|
|
34
|
+
## File Structure
|
|
35
|
+
- Exported component → subcomponents → helpers → static content → types
|
|
36
|
+
- One concept per file. Keep files under 300 lines
|
|
37
|
+
- Use lowercase with dashes for directories (components/auth-wizard)
|
|
38
|
+
- Favor named exports over default exports
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: REST API design principles and conventions
|
|
3
|
+
keywords: [api, rest, endpoint, http]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Design
|
|
7
|
+
|
|
8
|
+
## URL Conventions
|
|
9
|
+
- Use nouns, not verbs: `/users`, not `/getUsers`
|
|
10
|
+
- Use plural: `/users`, `/orders`
|
|
11
|
+
- Nest for relationships: `/users/:id/orders`
|
|
12
|
+
- Use kebab-case: `/user-profiles`, not `/userProfiles`
|
|
13
|
+
- Keep URLs shallow — max 3 levels deep
|
|
14
|
+
|
|
15
|
+
## HTTP Methods
|
|
16
|
+
- GET: Read (idempotent, cacheable)
|
|
17
|
+
- POST: Create
|
|
18
|
+
- PUT: Full replace
|
|
19
|
+
- PATCH: Partial update
|
|
20
|
+
- DELETE: Remove
|
|
21
|
+
|
|
22
|
+
## Status Codes
|
|
23
|
+
- 200: Success
|
|
24
|
+
- 201: Created
|
|
25
|
+
- 204: No Content (successful delete)
|
|
26
|
+
- 400: Bad Request (validation error)
|
|
27
|
+
- 401: Unauthorized (no/invalid auth)
|
|
28
|
+
- 403: Forbidden (no permission)
|
|
29
|
+
- 404: Not Found
|
|
30
|
+
- 409: Conflict (duplicate)
|
|
31
|
+
- 422: Unprocessable Entity
|
|
32
|
+
- 500: Internal Server Error
|
|
33
|
+
|
|
34
|
+
## Response Format
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"data": { ... },
|
|
38
|
+
"meta": { "page": 1, "total": 100 }
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Error:
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"error": {
|
|
46
|
+
"code": "VALIDATION_ERROR",
|
|
47
|
+
"message": "Email is required",
|
|
48
|
+
"details": [{ "field": "email", "issue": "required" }]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Best Practices
|
|
54
|
+
- Version your API: `/v1/users`
|
|
55
|
+
- Paginate lists: `?page=1&limit=20`
|
|
56
|
+
- Filter with query params: `?status=active`
|
|
57
|
+
- Use consistent date format (ISO 8601)
|
|
58
|
+
- Rate limit all endpoints
|
|
59
|
+
- Validate all inputs at the boundary
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Docker and containerization best practices
|
|
3
|
+
keywords: [docker, container, dockerfile, compose]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Docker
|
|
7
|
+
|
|
8
|
+
## Dockerfile
|
|
9
|
+
- Use multi-stage builds to minimize image size
|
|
10
|
+
- Use specific base image tags, never `latest`
|
|
11
|
+
- Order layers by change frequency (least → most changing)
|
|
12
|
+
- Combine RUN commands to reduce layers
|
|
13
|
+
- Use `.dockerignore` to exclude node_modules, .git, etc.
|
|
14
|
+
|
|
15
|
+
## Security
|
|
16
|
+
- Don't run as root — use `USER` directive
|
|
17
|
+
- Don't store secrets in images — use build args or runtime env
|
|
18
|
+
- Scan images for vulnerabilities (Trivy, Snyk)
|
|
19
|
+
- Use minimal base images (alpine, distroless, slim)
|
|
20
|
+
|
|
21
|
+
## Example (Node.js)
|
|
22
|
+
```dockerfile
|
|
23
|
+
FROM node:20-alpine AS builder
|
|
24
|
+
WORKDIR /app
|
|
25
|
+
COPY package*.json ./
|
|
26
|
+
RUN npm ci --production=false
|
|
27
|
+
COPY . .
|
|
28
|
+
RUN npm run build
|
|
29
|
+
|
|
30
|
+
FROM node:20-alpine
|
|
31
|
+
WORKDIR /app
|
|
32
|
+
COPY --from=builder /app/dist ./dist
|
|
33
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
34
|
+
USER node
|
|
35
|
+
EXPOSE 3000
|
|
36
|
+
CMD ["node", "dist/index.js"]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Docker Compose
|
|
40
|
+
- Use `depends_on` with health checks
|
|
41
|
+
- Use named volumes for persistent data
|
|
42
|
+
- Set resource limits (memory, CPU)
|
|
43
|
+
- Use `.env` file for environment variables
|
|
44
|
+
|
|
45
|
+
## Best Practices
|
|
46
|
+
- One process per container
|
|
47
|
+
- Log to stdout/stderr, not files
|
|
48
|
+
- Use health checks
|
|
49
|
+
- Graceful shutdown with SIGTERM handling
|
|
50
|
+
- Tag images with version, not just `latest`
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Go coding standards and idioms
|
|
3
|
+
keywords: [go, golang]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Go
|
|
7
|
+
|
|
8
|
+
## Style
|
|
9
|
+
- Follow Effective Go and Go Code Review Comments
|
|
10
|
+
- Use `gofmt` / `goimports` — no style debates
|
|
11
|
+
- Keep functions short. If it needs a comment, it's too complex
|
|
12
|
+
- Use meaningful package names — short, lowercase, no underscores
|
|
13
|
+
|
|
14
|
+
## Error Handling
|
|
15
|
+
- Check errors immediately. Never ignore with `_`
|
|
16
|
+
- Return errors, don't panic. Reserve panic for truly unrecoverable
|
|
17
|
+
- Wrap errors with context: `fmt.Errorf("fetch user %d: %w", id, err)`
|
|
18
|
+
- Use `errors.Is` and `errors.As` for error checking
|
|
19
|
+
- Define sentinel errors: `var ErrNotFound = errors.New("not found")`
|
|
20
|
+
|
|
21
|
+
## Patterns
|
|
22
|
+
- Accept interfaces, return structs
|
|
23
|
+
- Use composition over inheritance (embed structs)
|
|
24
|
+
- Use table-driven tests
|
|
25
|
+
- Keep interfaces small (1-3 methods)
|
|
26
|
+
- Use `context.Context` as first parameter for cancellation
|
|
27
|
+
|
|
28
|
+
## Concurrency
|
|
29
|
+
- Don't communicate by sharing memory; share memory by communicating
|
|
30
|
+
- Use channels for coordination, mutexes for state protection
|
|
31
|
+
- Always clean up goroutines (use `context` or `done` channel)
|
|
32
|
+
- Use `sync.WaitGroup` for fan-out patterns
|
|
33
|
+
- Use `errgroup` for concurrent error handling
|
|
34
|
+
|
|
35
|
+
## Project Layout
|
|
36
|
+
```
|
|
37
|
+
cmd/app/main.go
|
|
38
|
+
internal/
|
|
39
|
+
service/
|
|
40
|
+
repository/
|
|
41
|
+
pkg/ # Public libraries only
|
|
42
|
+
go.mod
|
|
43
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Next.js App Router and React best practices
|
|
3
|
+
keywords: [nextjs, next, react, app-router, rsc, server-components]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Next.js / React
|
|
7
|
+
|
|
8
|
+
## Key Principles
|
|
9
|
+
- Use functional components with TypeScript interfaces
|
|
10
|
+
- Minimize `use client` — prefer Server Components and SSR
|
|
11
|
+
- Use `use client` only for Web API access in small components
|
|
12
|
+
- Rely on Next.js App Router for state changes
|
|
13
|
+
|
|
14
|
+
## Components
|
|
15
|
+
- Use `function` keyword, not `const`, for components
|
|
16
|
+
- Place static content and interfaces at file end
|
|
17
|
+
- Wrap client components in Suspense with fallback
|
|
18
|
+
- Use dynamic loading for non-critical components
|
|
19
|
+
|
|
20
|
+
## Data Fetching
|
|
21
|
+
- Fetch data in Server Components, not client
|
|
22
|
+
- Use Server Actions for mutations
|
|
23
|
+
- Model expected errors as return values in Server Actions
|
|
24
|
+
- Avoid `useEffect` for data fetching
|
|
25
|
+
|
|
26
|
+
## State Management
|
|
27
|
+
- Minimize `useEffect` and `setState`
|
|
28
|
+
- Favor RSC (React Server Components) for data
|
|
29
|
+
- Use `useActionState` with react-hook-form for forms
|
|
30
|
+
- Use Zod for form validation
|
|
31
|
+
|
|
32
|
+
## Styling
|
|
33
|
+
- Use Tailwind CSS with mobile-first approach
|
|
34
|
+
- Use Shadcn UI and Radix UI for components
|
|
35
|
+
- Use `cn()` utility for conditional classes
|
|
36
|
+
|
|
37
|
+
## Performance
|
|
38
|
+
- Prioritize Web Vitals (LCP, CLS, FID)
|
|
39
|
+
- Optimize images: WebP format, size data, lazy loading
|
|
40
|
+
- Use `next/image` for all images
|
|
41
|
+
- Use `next/font` for font optimization
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Python coding standards and best practices
|
|
3
|
+
keywords: [python, py, django, fastapi, flask]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
|
|
8
|
+
## Style
|
|
9
|
+
- Follow PEP 8. Use type hints for all function signatures
|
|
10
|
+
- Use f-strings for formatting, not `.format()` or `%`
|
|
11
|
+
- Prefer list/dict/set comprehensions over loops when readable
|
|
12
|
+
- Use `pathlib.Path` over `os.path`
|
|
13
|
+
|
|
14
|
+
## Types
|
|
15
|
+
- Add type hints to all functions: parameters and return types
|
|
16
|
+
- Use `Optional[T]` for nullable values
|
|
17
|
+
- Use `TypedDict` for dictionary shapes
|
|
18
|
+
- Use `Protocol` for structural subtyping (duck typing)
|
|
19
|
+
|
|
20
|
+
## Patterns
|
|
21
|
+
- Use dataclasses or Pydantic models for structured data
|
|
22
|
+
- Prefer `with` statements for resource management
|
|
23
|
+
- Use generators for large datasets (`yield` over building lists)
|
|
24
|
+
- Use `enum.Enum` for fixed choices
|
|
25
|
+
|
|
26
|
+
## Error Handling
|
|
27
|
+
- Use specific exception types, not bare `except`
|
|
28
|
+
- Use `raise ... from` to preserve exception chains
|
|
29
|
+
- Define custom exceptions for domain errors
|
|
30
|
+
- Use `contextlib.suppress()` for expected exceptions
|
|
31
|
+
|
|
32
|
+
## Project Structure
|
|
33
|
+
```
|
|
34
|
+
src/
|
|
35
|
+
__init__.py
|
|
36
|
+
models/
|
|
37
|
+
services/
|
|
38
|
+
api/
|
|
39
|
+
tests/
|
|
40
|
+
conftest.py
|
|
41
|
+
test_models/
|
|
42
|
+
pyproject.toml
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Dependencies
|
|
46
|
+
- Use `pyproject.toml` for project config
|
|
47
|
+
- Pin dependency versions in production
|
|
48
|
+
- Use virtual environments (venv, uv, poetry)
|
|
49
|
+
- Separate dev and production dependencies
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Rust coding patterns and best practices
|
|
3
|
+
keywords: [rust, cargo, rs]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Rust
|
|
7
|
+
|
|
8
|
+
## Style
|
|
9
|
+
- Follow Rust API Guidelines and clippy lints
|
|
10
|
+
- Use `rustfmt` — no manual formatting
|
|
11
|
+
- Prefer `snake_case` for functions/variables, `CamelCase` for types
|
|
12
|
+
- Keep functions under 50 lines
|
|
13
|
+
|
|
14
|
+
## Ownership
|
|
15
|
+
- Prefer borrowing (`&T`, `&mut T`) over ownership transfer
|
|
16
|
+
- Use `Clone` only when necessary — avoid implicit copies
|
|
17
|
+
- Use lifetimes only when the compiler can't infer them
|
|
18
|
+
- Prefer `String` for owned data, `&str` for borrowed
|
|
19
|
+
|
|
20
|
+
## Error Handling
|
|
21
|
+
- Use `Result<T, E>` for recoverable errors
|
|
22
|
+
- Use `?` operator for error propagation
|
|
23
|
+
- Define custom error types with `thiserror`
|
|
24
|
+
- Use `anyhow` for application-level errors
|
|
25
|
+
- Never use `.unwrap()` in production code — use `.expect("reason")`
|
|
26
|
+
|
|
27
|
+
## Patterns
|
|
28
|
+
- Use `enum` with variants for state machines
|
|
29
|
+
- Prefer iterators over manual loops
|
|
30
|
+
- Use `Option` over sentinel values (null, -1)
|
|
31
|
+
- Use builder pattern for complex struct construction
|
|
32
|
+
- Derive traits: `Debug`, `Clone`, `PartialEq` as needed
|
|
33
|
+
|
|
34
|
+
## Project Structure
|
|
35
|
+
```
|
|
36
|
+
src/
|
|
37
|
+
main.rs (or lib.rs)
|
|
38
|
+
models/
|
|
39
|
+
services/
|
|
40
|
+
tests/
|
|
41
|
+
integration/
|
|
42
|
+
Cargo.toml
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Performance
|
|
46
|
+
- Use `&[T]` slices over `Vec<T>` in function parameters
|
|
47
|
+
- Avoid unnecessary allocations — reuse buffers
|
|
48
|
+
- Use `cargo bench` for benchmarking
|
|
49
|
+
- Profile before optimizing
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Svelte 5 and SvelteKit best practices
|
|
3
|
+
keywords: [svelte, sveltekit]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Svelte 5
|
|
7
|
+
|
|
8
|
+
## Key Principles
|
|
9
|
+
- Use runes (`$state`, `$derived`, `$effect`) for reactivity
|
|
10
|
+
- Use TypeScript with `<script lang="ts">`
|
|
11
|
+
- Keep components small — extract logic into modules
|
|
12
|
+
- Use SvelteKit for routing and SSR
|
|
13
|
+
|
|
14
|
+
## Runes (Svelte 5)
|
|
15
|
+
- `$state()` for reactive variables
|
|
16
|
+
- `$derived()` for computed values (replaces `$:`)
|
|
17
|
+
- `$effect()` for side effects (use sparingly)
|
|
18
|
+
- `$props()` for component props
|
|
19
|
+
- `$bindable()` for two-way binding props
|
|
20
|
+
|
|
21
|
+
## Components
|
|
22
|
+
- One component per `.svelte` file
|
|
23
|
+
- Use `{#snippet}` for reusable template fragments
|
|
24
|
+
- Use `{@render}` to render snippets
|
|
25
|
+
- Props: `let { title, count = 0 } = $props()`
|
|
26
|
+
|
|
27
|
+
## SvelteKit
|
|
28
|
+
- Use `+page.svelte` for pages, `+layout.svelte` for layouts
|
|
29
|
+
- Use `+page.server.ts` for server-side data loading
|
|
30
|
+
- Use form actions for mutations
|
|
31
|
+
- Use `$app/navigation` for programmatic navigation
|
|
32
|
+
|
|
33
|
+
## Structure
|
|
34
|
+
```
|
|
35
|
+
src/
|
|
36
|
+
lib/
|
|
37
|
+
components/
|
|
38
|
+
utils/
|
|
39
|
+
routes/
|
|
40
|
+
+page.svelte
|
|
41
|
+
+layout.svelte
|
|
42
|
+
api/
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Best Practices
|
|
46
|
+
- Prefer server-side loading over client-side fetch
|
|
47
|
+
- Use `{#each}` with `key` for lists
|
|
48
|
+
- Avoid `$effect` for derived state — use `$derived`
|
|
49
|
+
- Use CSS scoping (default in Svelte)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Vue 3 Composition API best practices
|
|
3
|
+
keywords: [vue, vuejs, nuxt, composition-api]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Vue 3
|
|
7
|
+
|
|
8
|
+
## Key Principles
|
|
9
|
+
- Use Composition API with `<script setup>` syntax
|
|
10
|
+
- Use TypeScript with `defineProps` and `defineEmits`
|
|
11
|
+
- Keep components small and focused
|
|
12
|
+
- Use composables for reusable logic
|
|
13
|
+
|
|
14
|
+
## Components
|
|
15
|
+
- One component per file (SFC: .vue)
|
|
16
|
+
- Use PascalCase for component names: `UserProfile.vue`
|
|
17
|
+
- Props: use type-safe `defineProps<{ title: string }>()`
|
|
18
|
+
- Emits: use `defineEmits<{ (e: 'update', value: string): void }>()`
|
|
19
|
+
|
|
20
|
+
## Reactivity
|
|
21
|
+
- Use `ref()` for primitives, `reactive()` for objects
|
|
22
|
+
- Use `computed()` for derived state
|
|
23
|
+
- Use `watch()` sparingly — prefer computed
|
|
24
|
+
- Avoid mutating props — emit events instead
|
|
25
|
+
|
|
26
|
+
## Composables
|
|
27
|
+
- Name with `use` prefix: `useAuth`, `useFetch`
|
|
28
|
+
- Return reactive refs and functions
|
|
29
|
+
- Keep composables pure — no side effects in setup
|
|
30
|
+
- Extract shared logic into `/composables/` directory
|
|
31
|
+
|
|
32
|
+
## Structure
|
|
33
|
+
```
|
|
34
|
+
src/
|
|
35
|
+
components/ # Shared components
|
|
36
|
+
composables/ # Reusable logic
|
|
37
|
+
views/ # Page components
|
|
38
|
+
stores/ # Pinia stores
|
|
39
|
+
types/ # TypeScript types
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## State Management
|
|
43
|
+
- Use Pinia for global state
|
|
44
|
+
- Keep stores small and domain-specific
|
|
45
|
+
- Use `storeToRefs()` for destructuring reactive state
|
|
@@ -216,8 +216,38 @@ const KEYWORD_MAP = {
|
|
|
216
216
|
'리뷰': { commands: ['review.md'], skills: ['review.md'], agents: ['review-checklist.md'] },
|
|
217
217
|
'react': { skills: ['react.md'] },
|
|
218
218
|
'리액트': { skills: ['react.md'] },
|
|
219
|
-
'next': { skills: ['
|
|
220
|
-
'nextjs': { skills: ['
|
|
219
|
+
'next': { skills: ['nextjs.md'] },
|
|
220
|
+
'nextjs': { skills: ['nextjs.md'] },
|
|
221
|
+
'typescript': { rules: ['typescript.md'] },
|
|
222
|
+
'ts': { rules: ['typescript.md'] },
|
|
223
|
+
'test': { rules: ['testing.md'], commands: ['test.md'] },
|
|
224
|
+
'testing': { rules: ['testing.md'], commands: ['test.md'] },
|
|
225
|
+
'테스트': { rules: ['testing.md'], commands: ['test.md'] },
|
|
226
|
+
'error': { rules: ['error-handling.md'] },
|
|
227
|
+
'exception': { rules: ['error-handling.md'] },
|
|
228
|
+
'naming': { rules: ['naming.md'] },
|
|
229
|
+
'python': { skills: ['python.md'] },
|
|
230
|
+
'django': { skills: ['python.md'] },
|
|
231
|
+
'fastapi': { skills: ['python.md'] },
|
|
232
|
+
'go': { skills: ['go.md'] },
|
|
233
|
+
'golang': { skills: ['go.md'] },
|
|
234
|
+
'rust': { skills: ['rust.md'] },
|
|
235
|
+
'cargo': { skills: ['rust.md'] },
|
|
236
|
+
'docker': { skills: ['docker.md'] },
|
|
237
|
+
'container': { skills: ['docker.md'] },
|
|
238
|
+
'dockerfile': { skills: ['docker.md'] },
|
|
239
|
+
'api': { skills: ['api-design.md'] },
|
|
240
|
+
'rest': { skills: ['api-design.md'] },
|
|
241
|
+
'endpoint': { skills: ['api-design.md'] },
|
|
242
|
+
'vue': { skills: ['vue.md'] },
|
|
243
|
+
'nuxt': { skills: ['vue.md'] },
|
|
244
|
+
'svelte': { skills: ['svelte.md'] },
|
|
245
|
+
'sveltekit': { skills: ['svelte.md'] },
|
|
246
|
+
'refactor': { commands: ['refactor.md'] },
|
|
247
|
+
'리팩토링': { commands: ['refactor.md'] },
|
|
248
|
+
'debug': { commands: ['debug.md'], contexts: ['debug.md'] },
|
|
249
|
+
'디버그': { commands: ['debug.md'], contexts: ['debug.md'] },
|
|
250
|
+
'bug': { commands: ['debug.md'], contexts: ['debug.md'] },
|
|
221
251
|
'code': { agents: ['code-standards.md'] },
|
|
222
252
|
'코드': { agents: ['code-standards.md'] },
|
|
223
253
|
'standard': { agents: ['code-standards.md'] },
|