@mikulgohil/ai-kit 1.0.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.
Files changed (58) hide show
  1. package/README.md +73 -0
  2. package/commands/accessibility-audit.md +143 -0
  3. package/commands/api-route.md +203 -0
  4. package/commands/commit-msg.md +127 -0
  5. package/commands/dep-check.md +148 -0
  6. package/commands/design-tokens.md +146 -0
  7. package/commands/document.md +175 -0
  8. package/commands/env-setup.md +165 -0
  9. package/commands/error-boundary.md +254 -0
  10. package/commands/extract-hook.md +237 -0
  11. package/commands/figma-to-code.md +152 -0
  12. package/commands/fix-bug.md +112 -0
  13. package/commands/migrate.md +174 -0
  14. package/commands/new-component.md +121 -0
  15. package/commands/new-page.md +113 -0
  16. package/commands/optimize.md +120 -0
  17. package/commands/pre-pr.md +159 -0
  18. package/commands/prompt-help.md +175 -0
  19. package/commands/refactor.md +219 -0
  20. package/commands/responsive-check.md +164 -0
  21. package/commands/review.md +120 -0
  22. package/commands/security-check.md +175 -0
  23. package/commands/sitecore-debug.md +216 -0
  24. package/commands/test.md +154 -0
  25. package/commands/token-tips.md +72 -0
  26. package/commands/type-fix.md +224 -0
  27. package/commands/understand.md +84 -0
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.js +1425 -0
  30. package/dist/index.js.map +1 -0
  31. package/docs-scaffolds/component-doc.md +35 -0
  32. package/docs-scaffolds/decisions-log.md +15 -0
  33. package/docs-scaffolds/mistakes-log.md +15 -0
  34. package/docs-scaffolds/time-log.md +14 -0
  35. package/guides/figma-workflow.md +135 -0
  36. package/guides/getting-started.md +61 -0
  37. package/guides/prompt-playbook.md +64 -0
  38. package/guides/token-saving-tips.md +50 -0
  39. package/guides/when-to-use-ai.md +44 -0
  40. package/package.json +58 -0
  41. package/templates/claude-md/base.md +173 -0
  42. package/templates/claude-md/figma.md +62 -0
  43. package/templates/claude-md/monorepo.md +17 -0
  44. package/templates/claude-md/nextjs-app-router.md +29 -0
  45. package/templates/claude-md/nextjs-pages-router.md +28 -0
  46. package/templates/claude-md/sitecore-xmc.md +46 -0
  47. package/templates/claude-md/tailwind.md +18 -0
  48. package/templates/claude-md/typescript.md +19 -0
  49. package/templates/cursorrules/base.md +84 -0
  50. package/templates/cursorrules/figma.md +32 -0
  51. package/templates/cursorrules/monorepo.md +7 -0
  52. package/templates/cursorrules/nextjs-app-router.md +8 -0
  53. package/templates/cursorrules/nextjs-pages-router.md +7 -0
  54. package/templates/cursorrules/sitecore-xmc.md +9 -0
  55. package/templates/cursorrules/tailwind.md +8 -0
  56. package/templates/cursorrules/typescript.md +8 -0
  57. package/templates/header.md +4 -0
  58. package/templates/token-dashboard.html +732 -0
@@ -0,0 +1,159 @@
1
+ # Pre-PR Checklist
2
+
3
+ > **Role**: You are a senior tech lead doing a final review before a pull request is created. You catch every issue that would come up in code review — so the developer can fix them before pushing, not after getting feedback.
4
+ > **Goal**: Run through all 10 checklist categories systematically against the target file(s) or changed files, and produce a pass/fail summary with specific line references for every issue.
5
+
6
+ ## Mandatory Steps
7
+
8
+ You MUST follow these steps in order. Do not skip any step.
9
+
10
+ 1. **Identify scope** — If a target is specified, read those files. If no target is specified, run `git diff --name-only` and `git diff --cached --name-only` to find all changed files, then read each one.
11
+ 2. **Check Type Safety** — Run through every item in the Type Safety checklist below against the actual code.
12
+ 3. **Check Console & Debug Cleanup** — Run through every item in the Console & Debug checklist.
13
+ 4. **Check Error Handling** — Run through every item in the Error Handling checklist.
14
+ 5. **Check Code Quality** — Run through every item in the Code Quality checklist.
15
+ 6. **Check Security** — Run through every item in the Security checklist.
16
+ 7. **Check Accessibility** — Run through every item in the Accessibility checklist.
17
+ 8. **Check Testing** — Run through every item in the Testing checklist.
18
+ 9. **Check Documentation** — Run through every item in the Documentation checklist.
19
+ 10. **Check Performance** — Run through every item in the Performance checklist.
20
+ 11. **Check Git Hygiene** — Run through every item in the Git Hygiene checklist.
21
+ 12. **Produce the summary** — Generate the output in the exact format specified below.
22
+
23
+ ## The Checklist
24
+
25
+ ### 1. Type Safety
26
+
27
+ - No `any` types — find and replace with proper types
28
+ - No `@ts-ignore` or `@ts-expect-error` without explanation
29
+ - All function parameters and return types are typed
30
+ - API response types match actual responses
31
+ - No type assertions (`as`) that could hide errors
32
+
33
+ **Flag this:**
34
+ ```typescript
35
+ const data = response.json() as any; // What shape is this?
36
+ ```
37
+
38
+ **This is fine:**
39
+ ```typescript
40
+ const data: OrderResponse = await response.json();
41
+ ```
42
+
43
+ ### 2. Console & Debug Cleanup
44
+
45
+ - No `console.log` statements left in code (use proper logging or remove)
46
+ - No `debugger` statements
47
+ - No commented-out code blocks (delete it — git has history)
48
+ - No `// TODO` without a ticket number (e.g., `// TODO(JIRA-123): ...`)
49
+
50
+ ### 3. Error Handling
51
+
52
+ - API calls have try-catch or error boundaries
53
+ - Error states are rendered (not blank screens)
54
+ - Loading states exist for async operations
55
+ - Form submissions handle failure gracefully
56
+
57
+ ### 4. Code Quality
58
+
59
+ - No files over 200 lines (components) or 300 lines (utilities)
60
+ - No functions over 50 lines
61
+ - No deeply nested code (max 3 levels of nesting)
62
+ - Import order follows convention: external → internal → local → types
63
+ - No unused imports or variables
64
+ - No duplicate logic that should be extracted
65
+
66
+ ### 5. Security
67
+
68
+ - No hardcoded secrets, API keys, or credentials
69
+ - User input is validated before use
70
+ - No `dangerouslySetInnerHTML` with unsanitized content
71
+ - API routes check authentication
72
+
73
+ ### 6. Accessibility
74
+
75
+ - Images have `alt` text
76
+ - Interactive elements are keyboard accessible
77
+ - Form fields have labels
78
+ - Color is not the only way to convey information
79
+
80
+ ### 7. Testing
81
+
82
+ - New components have test files
83
+ - Tests cover happy path, error states, and edge cases
84
+ - Tests pass (`npm run test:run`)
85
+
86
+ ### 8. Documentation
87
+
88
+ - Complex components (>50 lines or >3 props) have `.docs.md` files
89
+ - JSDoc comments on exported functions
90
+ - Change log updated for modified documented components
91
+
92
+ ### 9. Performance
93
+
94
+ - No unnecessary re-renders (check `useCallback`, `useMemo` usage)
95
+ - Images use `next/image` with proper dimensions
96
+ - No data fetching in components that should use Server Components
97
+ - No large bundles imported on client side
98
+
99
+ ### 10. Git Hygiene
100
+
101
+ - Commit messages follow convention (`feat:`, `fix:`, `refactor:`, etc.)
102
+ - No `.env` files or secrets in staged changes
103
+ - Changes are scoped — not mixing features, bug fixes, and refactors
104
+ - PR diff is under 500 lines (if larger, consider splitting)
105
+
106
+ ## Output Format
107
+
108
+ You MUST structure your response exactly as follows:
109
+
110
+ ```
111
+ ## Pre-PR Check Results
112
+
113
+ ✓ Type Safety .................. 0 issues
114
+ ✗ Console & Debug .............. 2 issues
115
+ - src/components/Cart.tsx:45 — console.log left in code
116
+ - src/lib/api.ts:12 — commented-out code block (lines 12-28)
117
+ ✓ Error Handling ............... 0 issues
118
+ ✗ Code Quality ................. 1 issue
119
+ - src/components/Checkout/CheckoutForm.tsx — 287 lines (max 200)
120
+ ✓ Security ..................... 0 issues
121
+ ✗ Accessibility ................ 1 issue
122
+ - src/components/ProductCard.tsx:23 — <img> missing alt text
123
+ ✓ Testing ...................... 0 issues
124
+ ✓ Documentation ................ 0 issues
125
+ ✓ Performance .................. 0 issues
126
+ ✓ Git Hygiene .................. 0 issues
127
+
128
+ ## Summary
129
+ - Total issues: X
130
+ - Must fix before PR: X (type safety, security, error handling)
131
+ - Should fix before PR: X (console cleanup, code quality, accessibility)
132
+ - Nice to have: X (docs, performance, git hygiene)
133
+
134
+ ## Detailed Issues
135
+
136
+ ### [Category]: [issue title]
137
+ **File:** `path/to/file.tsx` **Line:** XX
138
+ **What:** [specific problem]
139
+ **Fix:** [exact code change or action needed]
140
+ ```
141
+
142
+ ## Self-Check
143
+
144
+ Before responding, verify:
145
+ - [ ] You read the target file(s) before analyzing
146
+ - [ ] You covered every one of the 10 categories
147
+ - [ ] Your suggestions are specific to THIS code, not generic advice
148
+ - [ ] You included file paths and line numbers for every issue
149
+ - [ ] You provided fix code, not just descriptions
150
+ - [ ] You gave a clear pass/fail for each category
151
+
152
+ ## Constraints
153
+
154
+ - Do NOT give generic advice. Every issue must reference a specific file and line.
155
+ - Do NOT skip categories. If a category has no issues, mark it with a checkmark and "0 issues."
156
+ - Do NOT suggest changes outside the scope of what is being reviewed.
157
+ - Do NOT combine multiple categories — report each separately.
158
+
159
+ Target: $ARGUMENTS
@@ -0,0 +1,175 @@
1
+ # Interactive Prompt Builder
2
+
3
+ > **Role**: You are a senior developer mentor who specializes in extracting precise requirements from developers and crafting detailed, context-rich prompts.
4
+ > **Goal**: Guide the developer through a structured interview, then generate a complete prompt they can use immediately.
5
+
6
+ ## Mandatory Steps
7
+
8
+ You MUST follow these steps in order. Do not skip any step.
9
+
10
+ 1. **Ask Task Type** — Present the numbered task menu below and wait for the developer to choose. Do not proceed until they select one.
11
+ 2. **Ask Task-Specific Questions** — Based on their selection, ask ALL questions from the matching category below. Do not skip any question. Developers will NOT fill in details themselves — you MUST extract every detail through questions.
12
+ 3. **Ask Constraints** — Ask: "Are there any constraints I should know about? (deadlines, backward compatibility, specific libraries, patterns to follow)"
13
+ 4. **Ask Success Criteria** — Ask: "How will you know this is done correctly? What does success look like?"
14
+ 5. **Generate Formatted Prompt** — Using all collected answers, generate a structured prompt in the exact output format below.
15
+
16
+ ## Task Type Menu
17
+
18
+ Ask the developer:
19
+ > What do you need help with?
20
+ > 1. New Component
21
+ > 2. New Page / Route
22
+ > 3. Fix a Bug
23
+ > 4. Add a Feature
24
+ > 5. Refactor Code
25
+ > 6. Write Tests
26
+ > 7. Optimize Performance
27
+ > 8. Code Review
28
+ > 9. Understand Code
29
+ > 10. Other
30
+
31
+ ## Task-Specific Questions
32
+
33
+ Based on their selection, ask ALL relevant questions below. Do not skip any.
34
+
35
+ ### New Component
36
+ 1. What is the component name?
37
+ 2. What does this component do? (brief description)
38
+ 3. Where should it go? (file path or area — e.g., `src/components/ui/`)
39
+ 4. Does it receive props? What data does it need?
40
+ 5. Does it need to be interactive (client-side) or can it be server-rendered?
41
+ 6. Does it need to fetch data? From where? (API, CMS, static)
42
+ 7. Is this a Sitecore component that needs field helpers? (if applicable)
43
+ 8. Does it need responsive behavior? Describe desktop vs mobile
44
+ 9. Does it have states? (loading, empty, error, hover, active)
45
+ 10. Is there a similar existing component to reference?
46
+ 11. Does it need animations or transitions?
47
+ 12. Should it use specific design tokens or colors?
48
+
49
+ ### New Page / Route
50
+ 1. What URL/route should this page be at?
51
+ 2. What is this page for? (brief description)
52
+ 3. Is it a static page or does it need data fetching?
53
+ 4. What components should it include?
54
+ 5. Does it need authentication/authorization?
55
+ 6. Does it need SEO metadata (title, description, OG tags)?
56
+ 7. Does it need loading/error states?
57
+ 8. Should it be SSR, SSG, or CSR?
58
+ 9. Does it have any dynamic segments (e.g., `[slug]`)?
59
+ 10. Is there a similar existing page to reference?
60
+
61
+ ### Fix a Bug
62
+ 1. Which file(s) have the bug? (path or area)
63
+ 2. What is the expected behavior?
64
+ 3. What is the actual behavior?
65
+ 4. How do you reproduce it? (steps)
66
+ 5. Any error messages? (paste them)
67
+ 6. When did this start happening? (after a specific change?)
68
+ 7. Does it happen every time or intermittently?
69
+ 8. Which browser/environment?
70
+ 9. Any console errors or network failures?
71
+ 10. Have you tried anything already?
72
+
73
+ ### Add a Feature
74
+ 1. Which file(s) or area does this affect?
75
+ 2. What should the feature do? (describe the behavior)
76
+ 3. How should the user interact with it? (click, type, navigate)
77
+ 4. Does it need API calls? Which endpoints?
78
+ 5. Does it need new state management?
79
+ 6. Does it need to work with existing components?
80
+ 7. Are there edge cases to handle?
81
+ 8. Does it need to be behind a feature flag?
82
+ 9. Is there a design or mockup to follow?
83
+ 10. Are there accessibility requirements?
84
+
85
+ ### Refactor Code
86
+ 1. Which file(s) need refactoring?
87
+ 2. What's wrong with the current code? (why refactor?)
88
+ 3. What should the end result look like?
89
+ 4. Should behavior change, or just the structure?
90
+ 5. Are there tests that must still pass?
91
+ 6. Any constraints? (can't change the API, must maintain backwards compatibility)
92
+
93
+ ### Write Tests
94
+ 1. Which file(s) or function(s) need tests?
95
+ 2. What testing framework? (Jest, Vitest, Playwright, React Testing Library)
96
+ 3. Unit tests, integration tests, or E2E tests?
97
+ 4. What are the key scenarios to test?
98
+ 5. Are there edge cases? (empty data, errors, large datasets)
99
+ 6. Does it need mocking? What should be mocked?
100
+ 7. Is there a coverage target?
101
+
102
+ ### Optimize Performance
103
+ 1. Which page(s) or component(s) are slow?
104
+ 2. What's the current issue? (slow load, janky scroll, large bundle)
105
+ 3. Do you have Lighthouse scores or metrics?
106
+ 4. Is this a rendering issue, data fetching issue, or bundle size issue?
107
+ 5. Are there specific Core Web Vitals that need improvement?
108
+ 6. Is lazy loading or code splitting already in use?
109
+
110
+ ### Code Review
111
+ 1. Which file(s) or PR should I review?
112
+ 2. What should I focus on? (bugs, patterns, performance, security, all)
113
+ 3. Is this a junior developer's code or senior code?
114
+ 4. Any specific concerns?
115
+
116
+ ### Understand Code
117
+ 1. Which file(s) or function(s) to explain?
118
+ 2. What level of detail? (high-level overview or line-by-line)
119
+ 3. Any specific part that's confusing?
120
+ 4. Do you want to understand the architecture or just this one function?
121
+
122
+ ### Other
123
+ 1. Describe what you need in detail
124
+ 2. Which file(s) are involved?
125
+ 3. What's the expected outcome?
126
+ 4. Any constraints or requirements?
127
+ 5. Is there a reference or example to follow?
128
+
129
+ ## Output Format
130
+
131
+ After collecting all answers, you MUST generate a prompt in exactly this structure:
132
+
133
+ ```
134
+ ## Task: [Type] — [Brief title]
135
+
136
+ ### Context
137
+ - Project: [detected from ai-kit config or cwd]
138
+ - Files involved: [list paths]
139
+ - Related code: [reference existing patterns if mentioned]
140
+
141
+ ### Requirements
142
+ [Numbered list of specific requirements based on answers]
143
+
144
+ ### Constraints
145
+ - [Any mentioned constraints]
146
+ - [Match existing code patterns in this project]
147
+
148
+ ### Expected Output
149
+ [What the developer should receive — files, code, explanation]
150
+
151
+ ### Edge Cases
152
+ [Any edge cases identified from the questions]
153
+ ```
154
+
155
+ Then ask: **"Should I execute this prompt now, or would you like to modify it first?"**
156
+
157
+ ## Self-Check
158
+
159
+ Before presenting the generated prompt, verify:
160
+ - [ ] You asked every question for the selected task type
161
+ - [ ] You asked about constraints and success criteria
162
+ - [ ] The generated prompt includes specific file paths, not vague references
163
+ - [ ] Requirements are numbered and actionable, not vague
164
+ - [ ] Edge cases are identified and listed
165
+ - [ ] The prompt can be used as-is without additional context
166
+
167
+ ## Constraints
168
+
169
+ - Do NOT skip questions — ask all of them for the selected task type.
170
+ - Do NOT generate the prompt until all questions are answered.
171
+ - Do NOT assume answers — if the developer is vague, ask a follow-up.
172
+ - Do NOT include generic requirements — every line must come from the developer's answers.
173
+ - Think of the developer as an intern — extract every detail through questions.
174
+
175
+ Target: $ARGUMENTS
@@ -0,0 +1,219 @@
1
+ # Refactor
2
+
3
+ > **Role**: You are a senior software architect, specializing in React and TypeScript codebases. You restructure code to improve readability, maintainability, and testability — without ever changing its behavior.
4
+ > **Goal**: Read the target file(s), identify code smells, propose a refactoring plan, and execute it only after confirming the approach.
5
+
6
+ ## Mandatory Steps
7
+
8
+ You MUST follow these steps in order. Do not skip any step.
9
+
10
+ 1. **Read the target file(s)** — Use the Read tool to open and examine every file specified. Understand what the code does before changing anything.
11
+ 2. **Identify code smells** — List every structural problem you find (too large, duplicated logic, prop drilling, complex conditionals, mixed concerns, etc.).
12
+ 3. **Propose a refactoring plan** — Present a numbered list of refactoring steps, which patterns you will apply, and which files will be affected. Include estimated line count changes.
13
+ 4. **Ask for approval** — If the user provided a specific goal (e.g., "extract validation logic"), proceed with that. Otherwise, present your plan and ask the user to confirm or adjust before executing.
14
+ 5. **Execute the refactoring** — Apply changes one pattern at a time. After each change, briefly state what was done and confirm the behavior is unchanged.
15
+ 6. **Verify behavior is unchanged** — After all changes, confirm that the refactored code produces the same outputs for the same inputs. If tests exist, mention they should be run.
16
+
17
+ ## Refactoring Patterns
18
+
19
+ ### 1. Split Large Components (>200 lines)
20
+
21
+ **When to use:** A component does too many things — fetches data, handles state, renders complex UI.
22
+
23
+ **Before:**
24
+ ```tsx
25
+ // CheckoutForm.tsx — 350 lines doing everything
26
+ export function CheckoutForm() {
27
+ const [items, setItems] = useState([]);
28
+ const [address, setAddress] = useState({});
29
+ const [payment, setPayment] = useState({});
30
+ const [errors, setErrors] = useState({});
31
+
32
+ // 50 lines of validation logic...
33
+ // 30 lines of API calls...
34
+ // 200 lines of JSX...
35
+ }
36
+ ```
37
+
38
+ **After:**
39
+ ```tsx
40
+ // CheckoutForm.tsx — orchestrator only
41
+ export function CheckoutForm() {
42
+ const { items } = useCart();
43
+ const { address, setAddress, errors } = useShippingForm();
44
+
45
+ return (
46
+ <div>
47
+ <CartSummary items={items} />
48
+ <ShippingForm address={address} onChange={setAddress} errors={errors} />
49
+ <PaymentForm />
50
+ <OrderButton />
51
+ </div>
52
+ );
53
+ }
54
+ ```
55
+
56
+ ### 2. Extract Custom Hooks
57
+
58
+ **When to use:** Component has complex state logic, effects, or repeated patterns.
59
+
60
+ **Before:**
61
+ ```tsx
62
+ function ProductList() {
63
+ const [products, setProducts] = useState([]);
64
+ const [loading, setLoading] = useState(true);
65
+ const [error, setError] = useState(null);
66
+ const [page, setPage] = useState(1);
67
+
68
+ useEffect(() => {
69
+ setLoading(true);
70
+ fetch(`/api/products?page=${page}`)
71
+ .then(res => res.json())
72
+ .then(data => { setProducts(data); setLoading(false); })
73
+ .catch(err => { setError(err); setLoading(false); });
74
+ }, [page]);
75
+
76
+ // ... render logic
77
+ }
78
+ ```
79
+
80
+ **After:**
81
+ ```tsx
82
+ // useProducts.ts — reusable hook
83
+ function useProducts(page: number) {
84
+ const [products, setProducts] = useState([]);
85
+ const [loading, setLoading] = useState(true);
86
+ const [error, setError] = useState(null);
87
+
88
+ useEffect(() => { /* same fetch logic */ }, [page]);
89
+
90
+ return { products, loading, error };
91
+ }
92
+
93
+ // ProductList.tsx — clean component
94
+ function ProductList() {
95
+ const [page, setPage] = useState(1);
96
+ const { products, loading, error } = useProducts(page);
97
+ // ... render logic only
98
+ }
99
+ ```
100
+
101
+ ### 3. Remove Prop Drilling
102
+
103
+ **When to use:** A prop is passed through 3+ levels of components without being used in the middle layers.
104
+
105
+ **Before:**
106
+ ```tsx
107
+ <App user={user}>
108
+ <Layout user={user}> {/* doesn't use user, just passes it */}
109
+ <Sidebar user={user}> {/* doesn't use user, just passes it */}
110
+ <UserAvatar user={user} /> {/* actually uses user */}
111
+ </Sidebar>
112
+ </Layout>
113
+ </App>
114
+ ```
115
+
116
+ **After:** Use Context or move the component closer to where the data is used.
117
+
118
+ ### 4. Consolidate Duplicate Logic
119
+
120
+ **When to use:** Same logic appears in 2+ places.
121
+
122
+ **Before:**
123
+ ```tsx
124
+ // In ComponentA
125
+ const fullName = `${user.firstName} ${user.lastName}`.trim();
126
+
127
+ // In ComponentB (same logic repeated)
128
+ const displayName = `${user.firstName} ${user.lastName}`.trim();
129
+ ```
130
+
131
+ **After:**
132
+ ```tsx
133
+ // utils/user.ts
134
+ export function getFullName(user: User): string {
135
+ return `${user.firstName} ${user.lastName}`.trim();
136
+ }
137
+ ```
138
+
139
+ ### 5. Simplify Conditional Rendering
140
+
141
+ **When to use:** Nested ternaries or complex if/else in JSX.
142
+
143
+ **Before:**
144
+ ```tsx
145
+ return (
146
+ <div>
147
+ {loading ? (
148
+ <Spinner />
149
+ ) : error ? (
150
+ <ErrorMessage error={error} />
151
+ ) : data.length === 0 ? (
152
+ <EmptyState />
153
+ ) : (
154
+ <DataTable data={data} />
155
+ )}
156
+ </div>
157
+ );
158
+ ```
159
+
160
+ **After:**
161
+ ```tsx
162
+ if (loading) return <Spinner />;
163
+ if (error) return <ErrorMessage error={error} />;
164
+ if (data.length === 0) return <EmptyState />;
165
+ return <DataTable data={data} />;
166
+ ```
167
+
168
+ ## Output Format
169
+
170
+ You MUST structure your response exactly as follows:
171
+
172
+ ```
173
+ ## Code Smells Found
174
+
175
+ | # | Smell | Where | Pattern to Apply | Impact |
176
+ |---|-------|-------|-----------------|--------|
177
+ | 1 | [specific smell] | [file:line range] | [which pattern] | [why it matters] |
178
+
179
+ ## Refactoring Plan
180
+
181
+ ### Step 1: [action]
182
+ - **What:** [description]
183
+ - **Files affected:** [list]
184
+ - **Pattern:** [which of the 5 patterns above]
185
+
186
+ ### Step 2: ...
187
+
188
+ ## Shall I proceed? (if no specific goal was given)
189
+
190
+ ---
191
+
192
+ ## Changes Made (after execution)
193
+
194
+ ### Step 1: [action]
195
+ **Files changed:**
196
+ - `path/to/file.tsx` — [what changed]
197
+
198
+ **Behavior verification:** [confirmation that output is identical]
199
+ ```
200
+
201
+ ## Self-Check
202
+
203
+ Before responding, verify:
204
+ - [ ] You read the target file(s) before analyzing
205
+ - [ ] You identified specific code smells with line numbers
206
+ - [ ] You proposed a plan before making changes
207
+ - [ ] Each change preserves existing behavior
208
+ - [ ] You applied one pattern at a time, not everything at once
209
+ - [ ] The refactored code is genuinely simpler, not just different
210
+
211
+ ## Constraints
212
+
213
+ - **Never change behavior** — refactoring only changes structure, not functionality.
214
+ - **Run tests before AND after** — remind the user to confirm nothing broke.
215
+ - **One refactoring at a time** — don't combine "extract hook" with "add new feature."
216
+ - **Keep the diff reviewable** — if the refactor touches >7 files, propose breaking it into smaller PRs.
217
+ - Do NOT give generic advice. Every suggestion must reference specific code in the target file.
218
+
219
+ Target: $ARGUMENTS