moicle 1.4.0 → 1.6.0

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.
@@ -0,0 +1,124 @@
1
+ ---
2
+ name: research
3
+ description: Research solutions on the internet for a given topic or the current conversation context. Use when user says "research", "tìm giải pháp", "search solution", "investigate", "find best practice", "so sánh giải pháp".
4
+ args: "[TOPIC]"
5
+ ---
6
+
7
+ # Research Solutions
8
+
9
+ Research solutions on the internet for a specific problem — either from an explicit topic argument or by analyzing the current conversation context.
10
+
11
+ **ARGUMENTS:** (optional) Topic or question to research. If omitted, analyze the current conversation (recent messages, IDE selection, task at hand) to determine what to research.
12
+
13
+ ---
14
+
15
+ ## Step 1: Identify What to Research
16
+
17
+ ### Mode 1: Argument provided
18
+ - Use the argument directly as the research topic.
19
+ - If the argument is too broad, narrow it down using project context (stack, architecture, current task) before searching.
20
+
21
+ ### Mode 2: No argument
22
+ - Analyze the current conversation: recent messages, IDE file selection, active task
23
+ - Identify: what is the user doing, what problem they hit, what solution they need
24
+ - **Summarize the problem back to the user and get confirmation** before burning search budget
25
+
26
+ ---
27
+
28
+ ## Step 2: Detect Project Context
29
+
30
+ Before researching, detect the project's tech stack so results can be filtered for relevance:
31
+
32
+ | File | Stack |
33
+ |------|-------|
34
+ | `go.mod` | Go (note version from `go` directive) |
35
+ | `package.json` | Node.js — inspect dependencies to pick framework (NestJS / Vite+React / Remix / etc.) |
36
+ | `pubspec.yaml` | Flutter / Dart |
37
+ | `composer.json` | PHP / Laravel |
38
+ | `Cargo.toml` | Rust |
39
+ | `pyproject.toml` / `requirements.txt` | Python |
40
+
41
+ Also check `.claude/architecture/` for the architecture doc in use — this shapes which patterns are idiomatic for the project.
42
+
43
+ ---
44
+
45
+ ## Step 3: Research on the Internet
46
+
47
+ Use **WebSearch** and **WebFetch** to find solutions.
48
+
49
+ ### Search strategy
50
+ 1. **Broad first**: Overview, best practices, common approaches
51
+ 2. **Deep dive**: Read official docs, GitHub issues, Stack Overflow, authoritative blog posts
52
+ 3. **Compare alternatives**: If multiple solutions exist, list pros/cons of each
53
+
54
+ ### Source priority
55
+ 1. Official documentation
56
+ 2. GitHub issues / release notes (for quirks and known-bug context)
57
+ 3. Stack Overflow (accepted answers with high scores)
58
+ 4. Authoritative blogs (Anthropic, framework authors, well-known engineers)
59
+ 5. Recent articles > old articles — prefer results within the last 2 years unless the topic is evergreen
60
+
61
+ ### Search tips
62
+ - **Prefer English queries** — results are richer and more recent
63
+ - Include library + version when the topic is version-sensitive (e.g., `nestjs 10 typeorm migrations`)
64
+ - Cross-validate across at least 2–3 independent sources before concluding
65
+ - When results conflict, prefer the most recent + most authoritative source and note the conflict
66
+
67
+ ---
68
+
69
+ ## Step 4: Synthesize Results
70
+
71
+ Present the findings in this format:
72
+
73
+ ```markdown
74
+ ## Problem
75
+ {Short summary of the problem being solved, with project context — stack, constraints, goal}
76
+
77
+ ## Solutions Found
78
+
79
+ ### Solution 1: {Name}
80
+ - **Description:** {How it works}
81
+ - **Pros:** {...}
82
+ - **Cons:** {...}
83
+ - **Fit for this project:** {High / Medium / Low — why}
84
+ - **Source:** {link}
85
+
86
+ ### Solution 2: {Name} (if applicable)
87
+ - ...
88
+
89
+ ## Recommendation
90
+ {Which solution fits best for this project and why — reference architecture doc / stack conventions}
91
+
92
+ ## Code Example (if applicable)
93
+ {Minimal snippet showing the recommended approach, adapted to the project's stack and conventions}
94
+
95
+ ## Caveats / Known Issues
96
+ - {Gotcha 1}
97
+ - {Gotcha 2}
98
+
99
+ ## References
100
+ - {link 1} — {what this source gave us}
101
+ - {link 2} — {...}
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Rules
107
+
108
+ - **Research and propose — do NOT implement.** Wait for user confirmation before touching code.
109
+ - **Consider project context:** tech stack, architecture, conventions. A solution that is idiomatic in one project can be wrong in another.
110
+ - **Narrow scope when too broad:** if the topic is too wide (e.g., "how to do auth"), ask the user to narrow it (e.g., "JWT refresh flow with NestJS + TypeORM").
111
+ - **Flag stale answers:** if the top answers are old (3+ years) and the library has had major versions since, mention it and check release notes.
112
+ - **No hallucinated APIs:** if you're uncertain whether a method/option exists, verify in official docs before recommending.
113
+ - **Cite sources:** every non-trivial claim should have a link.
114
+
115
+ ---
116
+
117
+ ## When to Use Other Skills Instead
118
+
119
+ | Situation | Use instead |
120
+ |-----------|-------------|
121
+ | You're debugging a known bug (not researching options) | `deep-debug` |
122
+ | You want to prototype a chosen approach | `spike` |
123
+ | You already know the approach and want to implement it | `new-feature` / `hotfix` |
124
+ | You want to write up the research as a design doc | `documentation` |
@@ -0,0 +1,312 @@
1
+ ---
2
+ name: review-changes
3
+ description: Review local branch changes for architecture compliance, conventions, and code quality before pushing/PR. Stack-aware — detects the project stack and applies the matching rules. Use when user says "review changes", "review branch", "check branch", "check changes", "review my code", "review before pr".
4
+ args: "[BASE_BRANCH]"
5
+ ---
6
+
7
+ # Review Local Branch Changes
8
+
9
+ Review all code changes on the current branch (vs a base branch) for **architecture compliance**, **stack conventions**, and **code quality**. Focus on changed files only — not the entire codebase. This is the pre-PR companion to `pr-review` (which reviews remote PRs).
10
+
11
+ **ARGUMENTS:** (optional) base branch to compare against. Default: `main` (or `master` if `main` does not exist).
12
+
13
+ ---
14
+
15
+ ## Phase 0: Detect Stack & Load Architecture
16
+
17
+ Before reviewing, detect the project stack and load the matching architecture doc.
18
+
19
+ ### Stack Detection
20
+ | File | Stack | Architecture Doc |
21
+ |------|-------|------------------|
22
+ | `go.mod` | Go | `go-backend.md` |
23
+ | `package.json` + `@nestjs/core` | NestJS | `nodejs-nestjs.md` |
24
+ | `package.json` + `vite.config.*` | React | `react-frontend.md` |
25
+ | `package.json` + `remix.config.*` | Remix | `remix-fullstack.md` |
26
+ | `pubspec.yaml` | Flutter | `flutter-mobile.md` |
27
+ | `composer.json` | Laravel | `laravel-backend.md` |
28
+
29
+ ### Architecture Files Location (in priority order)
30
+ ```
31
+ .claude/architecture/{name}.md # Project-specific
32
+ ~/.claude/architecture/{name}.md # Global
33
+ ```
34
+
35
+ Also read `ddd-architecture.md` / `clean-architecture.md` as the cross-stack baseline.
36
+
37
+ ### Gate
38
+ - [ ] Stack detected (ask user if ambiguous — e.g., multi-stack monorepo)
39
+ - [ ] Architecture doc loaded
40
+ - [ ] Forbidden imports list extracted
41
+
42
+ ---
43
+
44
+ ## Phase 1: Collect Changes
45
+
46
+ ```bash
47
+ # Resolve base branch
48
+ BASE=${1:-main}
49
+ git rev-parse --verify "$BASE" >/dev/null 2>&1 || BASE=master
50
+
51
+ echo "=== Base: $BASE ==="
52
+
53
+ echo "=== Changed files ==="
54
+ git diff "$BASE"...HEAD --name-only --diff-filter=ACMR
55
+
56
+ echo "=== Diff stat ==="
57
+ git diff "$BASE"...HEAD --stat
58
+
59
+ echo "=== Commits ==="
60
+ git log "$BASE"..HEAD --oneline
61
+ ```
62
+
63
+ Categorize changed files by layer (map per architecture doc):
64
+
65
+ | DDD Layer | Typical Paths |
66
+ |-----------|---------------|
67
+ | Domain | `domain/`, `internal/domain/`, `src/domain/`, `lib/domain/` |
68
+ | Application | `application/`, `internal/application/`, `src/application/` |
69
+ | Infrastructure | `infrastructure/`, `internal/infrastructure/`, `src/infrastructure/` |
70
+ | Presentation / UI | `controllers/`, `pages/`, `components/`, `views/`, `ports/http/` |
71
+ | Persistence models | `models/`, `entities/` (ORM), `prisma/`, `migrations/` |
72
+ | Config / Bootstrap | `config/`, `bootstrap/`, `cmd/`, `main.*` |
73
+
74
+ Read ALL changed files before reviewing — never skim.
75
+
76
+ ---
77
+
78
+ ## Phase 2: Build & Lint
79
+
80
+ Run the stack's build + lint commands from the architecture doc:
81
+
82
+ ```bash
83
+ # Go
84
+ go build ./... && go vet ./...
85
+
86
+ # NestJS / TypeScript
87
+ pnpm typecheck || npx tsc --noEmit
88
+ pnpm lint || npx eslint "{src,test}/**/*.ts"
89
+
90
+ # Laravel
91
+ composer dump-autoload && ./vendor/bin/phpstan analyse
92
+
93
+ # Flutter
94
+ dart analyze
95
+
96
+ # React / Remix
97
+ pnpm typecheck && pnpm lint
98
+ ```
99
+
100
+ If build/typecheck/lint fails → report immediately as **CRITICAL**. Stop further review until these pass.
101
+
102
+ ---
103
+
104
+ ## Phase 3: Architecture Checks (on changed files only)
105
+
106
+ Apply the rules from the stack's architecture doc ONLY to changed files. Do not re-review unchanged code.
107
+
108
+ ### 3.1 Domain Layer (if changed)
109
+
110
+ | # | Rule | Check |
111
+ |---|------|-------|
112
+ | D1 | Domain purity | No forbidden imports (ORM, HTTP framework, cache client, queue, auth SDK) |
113
+ | D2 | No cross-domain imports | Domain A must NOT import Domain B (only shared kernel allowed) |
114
+ | D3 | No persistence-model imports | Domain must NOT import ORM entity classes / persistence models |
115
+ | D4 | Entity behavior | Not just data bag — has methods with state transitions |
116
+ | D5 | Entity raises events | Raises/collects events on state change (if architecture uses events) |
117
+ | D6 | Ports in ports/ folder | Interfaces MUST be in `ports/`, NOT inline in use-cases |
118
+ | D7 | One port per file | Each interface in a separate file |
119
+ | D8 | Ports use domain types | Return domain entities/value objects, not raw primitives |
120
+ | D9 | Value objects stdlib only | VOs import only stdlib — no domain/shared, no framework |
121
+ | D10 | Use-case no infra imports | Only entities + ports + events + value-objects |
122
+
123
+ ```bash
124
+ # Generic domain-purity check (adapt FORBIDDEN for stack)
125
+ CHANGED_DOMAIN=$(git diff "$BASE"...HEAD --name-only --diff-filter=ACMR \
126
+ | grep -E '^(src|internal|lib)/domain/' || true)
127
+
128
+ if [ -n "$CHANGED_DOMAIN" ]; then
129
+ # Example forbidden-imports regex — replace per stack from architecture doc
130
+ # Go: '"gorm.io|"github.com/gin|"github.com/redis|"firebase.google.com|"github.com/hibiken'
131
+ # Nest: '"@nestjs/|"typeorm"|"@nestjs/typeorm|"ioredis|"bullmq|"passport'
132
+ # Lara: 'Illuminate\\Database|Illuminate\\Http'
133
+ FORBIDDEN='<PUT STACK FORBIDDEN REGEX HERE>'
134
+ echo "=== D1: Domain purity ==="
135
+ echo "$CHANGED_DOMAIN" | xargs grep -lEn "$FORBIDDEN" 2>/dev/null \
136
+ && echo "FAIL" || echo "PASS"
137
+ fi
138
+ ```
139
+
140
+ ### 3.2 Application Layer (if changed)
141
+
142
+ | # | Rule | Check |
143
+ |---|------|-------|
144
+ | A1 | Handler is thin | No business logic — parse input → call service/use-case → return output |
145
+ | A2 | Service justified | Only when real orchestration exists (multiple use-cases, cross-cutting). Single-use-case forwarders are a smell — inject the use-case directly |
146
+ | A3 | Listener is side-effect only | No business logic — notifications, SSE, queue jobs, analytics only |
147
+ | A4 | Listener registered | Event registered in the registry / `event.emitter` module |
148
+ | A5 | Event names match | Event name string matches registry registration |
149
+ | A6 | DTOs validated at boundary | All controller inputs validated via schema/validator at entry |
150
+ | A7 | Composition root | Handlers/controllers must NOT build dependencies inline — all wiring lives in the composition root (bootstrap/module) |
151
+
152
+ ### 3.3 Infrastructure Layer (if changed)
153
+
154
+ | # | Rule | Check |
155
+ |---|------|-------|
156
+ | I1 | Repository has no business logic | Pure persistence — queries, saves, deletes |
157
+ | I2 | Mappers exist | Explicit mapping between domain entity and ORM/persistence model |
158
+ | I3 | Implements port interface | Returns domain types per port contract |
159
+ | I4 | Context/transaction propagation | Uses project's context/transaction pattern consistently |
160
+
161
+ ### 3.4 Persistence Models (if changed)
162
+
163
+ | # | Rule | Check |
164
+ |---|------|-------|
165
+ | M1 | ORM models outside domain | Persistence models live in infrastructure, NOT in domain |
166
+ | M2 | Migrations added for schema changes | Any schema change has a matching migration file |
167
+ | M3 | JSON / nullable columns correctly typed | Pointer/nullable types used where the column allows NULL |
168
+
169
+ ---
170
+
171
+ ## Phase 4: Stack-Specific Conventions
172
+
173
+ Read the **Conventions** / **Hard Rules** section from the architecture doc and check changed files against them. Common cross-stack checks:
174
+
175
+ | # | Rule | Check |
176
+ |---|------|-------|
177
+ | G1 | No swallowed errors | No empty `catch`/`if err != nil {}` that discards errors — must handle or rethrow |
178
+ | G2 | Goroutine/async context | Fire-and-forget async work uses background context, NOT request context |
179
+ | G3 | API-facing entities have serialization tags | `json:"..."` (Go), class-transformer/serializer decorators, `JsonSerializable`, etc. |
180
+ | G4 | No secrets in code | No hardcoded tokens, keys, passwords |
181
+ | G5 | Parameterized queries | No raw string-interpolated SQL |
182
+ | G6 | Input validation at boundary | All external input validated before touching domain |
183
+
184
+ ---
185
+
186
+ ## Phase 5: Code Quality (Manual)
187
+
188
+ Read the diff carefully. Look for:
189
+
190
+ | # | Area | What to look for |
191
+ |---|------|-----------------|
192
+ | Q1 | Logic correctness | Off-by-one, nil/null deref, wrong condition, missing edge case |
193
+ | Q2 | Error handling | Errors returned/wrapped, not silently ignored |
194
+ | Q3 | Concurrency safety | Race conditions, shared mutable state, goroutine/async leaks |
195
+ | Q4 | Resource leaks | Unclosed connections, HTTP bodies, file handles, subscriptions |
196
+ | Q5 | Naming clarity | Variables/functions clearly describe intent |
197
+ | Q6 | Dead code | Unreachable code, unused variables, commented-out blocks |
198
+ | Q7 | Duplication | Significant copy-paste across changed files |
199
+ | Q8 | Breaking changes | API contract changes, removed fields, changed behavior |
200
+ | Q9 | Over-engineering | Abstractions not justified by the change — fewer layers is usually better |
201
+ | Q10 | Test coverage | New logic has tests; bug fixes have regression tests |
202
+
203
+ ---
204
+
205
+ ## Phase 6: Tests
206
+
207
+ ```bash
208
+ # Run tests for changed domains / features only
209
+ CHANGED_DOMAINS=$(git diff "$BASE"...HEAD --name-only --diff-filter=ACMR \
210
+ | grep -E '/(domain|modules|features)/' \
211
+ | sed -E 's|.*(domain\|modules\|features)/([^/]+)/.*|\2|' \
212
+ | sort -u)
213
+
214
+ for d in $CHANGED_DOMAINS; do
215
+ echo "--- Testing $d ---"
216
+ # Go: go test ./internal/domain/$d/... -v
217
+ # Nest: npx jest src/domain/$d
218
+ # Lara: ./vendor/bin/phpunit --filter $d
219
+ # Flutter: flutter test test/domain/$d
220
+ done
221
+
222
+ echo "=== Full test suite ==="
223
+ # Stack's full test command
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Phase 7: Report
229
+
230
+ ```markdown
231
+ ## Code Review: {branch} → {base}
232
+
233
+ ### Summary
234
+ - **Stack:** {stack}
235
+ - **Architecture doc:** {path}
236
+ - **Commits:** {count}
237
+ - **Files changed:** {count} ({additions}+ / {deletions}-)
238
+ - **Areas affected:** {domain list / feature list}
239
+
240
+ ### Build, Lint, Types
241
+ | Check | Status |
242
+ |-------|--------|
243
+ | Build | PASS/FAIL |
244
+ | Lint | PASS/FAIL |
245
+ | Types | PASS/FAIL |
246
+
247
+ ### Architecture Checks
248
+ | # | Rule | Status | Details |
249
+ |---|------|--------|---------|
250
+ | D1 | Domain purity | PASS/FAIL | {file:line} |
251
+ | ... | ... | ... | ... |
252
+
253
+ ### Conventions
254
+ | # | Rule | Status | Details |
255
+ |---|------|--------|---------|
256
+ | G1 | No swallowed errors | PASS/WARN | {file:line} |
257
+
258
+ ### Code Quality
259
+ | # | Area | Status | Details |
260
+ |---|------|--------|---------|
261
+ | Q1 | Logic correctness | OK/ISSUE | ... |
262
+
263
+ ### Tests
264
+ | Check | Status |
265
+ |-------|--------|
266
+ | Changed area tests | PASS/FAIL |
267
+ | Full test suite | PASS/FAIL |
268
+
269
+ ### Issues Found
270
+ | # | Severity | File:Line | Description | Suggested Fix |
271
+ |---|----------|-----------|-------------|---------------|
272
+ | 1 | CRITICAL/HIGH/MEDIUM/LOW | path:123 | ... | ... |
273
+
274
+ ### Verdict
275
+ {APPROVED / CHANGES REQUESTED}
276
+ ```
277
+
278
+ ---
279
+
280
+ ## Severity Levels
281
+
282
+ | Level | Meaning | Examples |
283
+ |-------|---------|---------|
284
+ | CRITICAL | Build fails, crash, data loss, security hole | Build error, nil deref, SQL injection, circular import, leaked secret |
285
+ | HIGH | Architecture violation, silent bug | Domain imports ORM, cross-domain import, swallowed error, race condition |
286
+ | MEDIUM | Convention violation, code smell | Missing serialization tags, business logic in handler, no tests for new logic |
287
+ | LOW | Style, naming, minor improvement | File naming, redundant code, unclear name |
288
+
289
+ **CRITICAL + HIGH = CHANGES REQUESTED** (must fix before PR)
290
+ **MEDIUM only = CHANGES REQUESTED** (should fix)
291
+ **LOW only = APPROVED with suggestions**
292
+
293
+ ---
294
+
295
+ ## Phase 8: Fix (if user confirms)
296
+
297
+ If user says to fix:
298
+ 1. Fix each issue in order: CRITICAL → HIGH → MEDIUM → LOW
299
+ 2. Re-run build/lint/tests after each batch
300
+ 3. Re-run the full review when all fixed
301
+ 4. Report final status
302
+
303
+ ---
304
+
305
+ ## Relationship to Other Skills
306
+
307
+ | Skill | When to use |
308
+ |-------|-------------|
309
+ | `review-changes` (this) | Local branch changes, pre-push / pre-PR |
310
+ | `pr-review` | Remote PR review via `gh pr` — includes posting feedback to GitHub |
311
+ | `architect-review` | Deep DDD architecture audit of a domain (not just changes) |
312
+ | `fix-pr-comment` | Fix feedback posted on an existing PR |