@silverassist/agents-toolkit 2.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.
- package/LICENSE +135 -0
- package/README.md +388 -0
- package/bin/cli.js +940 -0
- package/package.json +52 -0
- package/src/index.js +58 -0
- package/templates/agents/AGENTS.codex.md +195 -0
- package/templates/agents/AGENTS.md +195 -0
- package/templates/agents/CLAUDE.md +213 -0
- package/templates/agents/copilot-instructions.md +83 -0
- package/templates/shared/instructions/css-styling.instructions.md +142 -0
- package/templates/shared/instructions/documentation-language.instructions.md +216 -0
- package/templates/shared/instructions/github-workflow.instructions.md +245 -0
- package/templates/shared/instructions/php-standards.instructions.md +293 -0
- package/templates/shared/instructions/react-components.instructions.md +196 -0
- package/templates/shared/instructions/server-actions.instructions.md +429 -0
- package/templates/shared/instructions/testing-standards.instructions.md +264 -0
- package/templates/shared/instructions/tests.instructions.md +103 -0
- package/templates/shared/instructions/typescript.instructions.md +106 -0
- package/templates/shared/instructions/wordpress-plugin-architecture.instructions.md +238 -0
- package/templates/shared/prompts/README.md +129 -0
- package/templates/shared/prompts/_partials/README.md +57 -0
- package/templates/shared/prompts/_partials/documentation.md +203 -0
- package/templates/shared/prompts/_partials/git-operations.md +171 -0
- package/templates/shared/prompts/_partials/github-integration.md +100 -0
- package/templates/shared/prompts/_partials/jira-integration.md +155 -0
- package/templates/shared/prompts/_partials/pr-template.md +216 -0
- package/templates/shared/prompts/_partials/validations.md +87 -0
- package/templates/shared/prompts/add-tests.prompt.md +151 -0
- package/templates/shared/prompts/analyze-github-issue.prompt.md +73 -0
- package/templates/shared/prompts/analyze-ticket.prompt.md +63 -0
- package/templates/shared/prompts/create-plan.prompt.md +118 -0
- package/templates/shared/prompts/create-pr.prompt.md +139 -0
- package/templates/shared/prompts/finalize-pr.prompt.md +150 -0
- package/templates/shared/prompts/fix-issues.prompt.md +92 -0
- package/templates/shared/prompts/new-wp-component.prompt.md +51 -0
- package/templates/shared/prompts/new-wp-plugin.prompt.md +46 -0
- package/templates/shared/prompts/prepare-pr.prompt.md +123 -0
- package/templates/shared/prompts/prepare-release.prompt.md +74 -0
- package/templates/shared/prompts/quality-check.prompt.md +45 -0
- package/templates/shared/prompts/review-code.prompt.md +81 -0
- package/templates/shared/prompts/work-github-issue.prompt.md +96 -0
- package/templates/shared/prompts/work-ticket.prompt.md +98 -0
- package/templates/shared/skills/README.md +53 -0
- package/templates/shared/skills/component-architecture/SKILL.md +321 -0
- package/templates/shared/skills/create-component/SKILL.md +714 -0
- package/templates/shared/skills/domain-driven-design/SKILL.md +277 -0
- package/templates/shared/skills/plugin-creation/SKILL.md +1094 -0
- package/templates/shared/skills/quality-checks/SKILL.md +493 -0
- package/templates/shared/skills/release-management/SKILL.md +649 -0
- package/templates/shared/skills/testing/SKILL.md +682 -0
- package/templates/shared/skills/testing-patterns/SKILL.md +243 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: component-architecture
|
|
3
|
+
description: Guide for creating and organizing React components. Use this when creating new components, restructuring folders, or ensuring consistent component patterns.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Component Architecture Skill
|
|
7
|
+
|
|
8
|
+
When creating or modifying React components in this project, follow these strict conventions.
|
|
9
|
+
|
|
10
|
+
## Folder Structure Rules
|
|
11
|
+
|
|
12
|
+
### CRITICAL: Naming Conventions
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
✅ CORRECT (kebab-case folders):
|
|
16
|
+
src/components/user-profile/index.tsx
|
|
17
|
+
src/components/checkout-wizard/index.tsx
|
|
18
|
+
src/components/contact-form/index.tsx
|
|
19
|
+
|
|
20
|
+
❌ INCORRECT (never use):
|
|
21
|
+
src/components/UserProfile.tsx # No standalone files
|
|
22
|
+
src/components/userProfile/index.tsx # No camelCase folders
|
|
23
|
+
src/components/UserProfile/index.tsx # No PascalCase folders
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Component Folder Pattern
|
|
27
|
+
|
|
28
|
+
Every component MUST be in its own folder with `index.tsx`:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
src/components/payment-form/
|
|
32
|
+
├── index.tsx # ONLY the component + props interface
|
|
33
|
+
├── types.ts # Shared types (if multiple)
|
|
34
|
+
├── helpers.ts # Helper functions
|
|
35
|
+
├── constants.ts # Component constants
|
|
36
|
+
└── __tests__/
|
|
37
|
+
└── payment-form.test.tsx
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Component File Template
|
|
41
|
+
|
|
42
|
+
### Server Component (Default)
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// src/components/auth/user-profile/index.tsx
|
|
46
|
+
import { getUserProfile } from "@/data/user";
|
|
47
|
+
|
|
48
|
+
interface UserProfileProps {
|
|
49
|
+
/** User ID to display */
|
|
50
|
+
userId: string;
|
|
51
|
+
/** Additional CSS classes */
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Displays user profile information
|
|
57
|
+
* Server Component - fetches data directly
|
|
58
|
+
*/
|
|
59
|
+
export default async function UserProfile({
|
|
60
|
+
userId,
|
|
61
|
+
className,
|
|
62
|
+
}: UserProfileProps) {
|
|
63
|
+
const user = await getUserProfile(userId);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<div className={className}>
|
|
67
|
+
<h2>{user.name}</h2>
|
|
68
|
+
<p>{user.email}</p>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Client Component (Interactive)
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// src/components/checkout/add-to-cart-button/index.tsx
|
|
78
|
+
"use client";
|
|
79
|
+
|
|
80
|
+
import { useState } from "react";
|
|
81
|
+
import { addToCart } from "@/actions/checkout/add-to-cart";
|
|
82
|
+
|
|
83
|
+
interface AddToCartButtonProps {
|
|
84
|
+
/** Product ID to add */
|
|
85
|
+
productId: string;
|
|
86
|
+
/** Button variant */
|
|
87
|
+
variant?: "primary" | "secondary";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Interactive button to add products to cart
|
|
92
|
+
* Client Component - uses state and event handlers
|
|
93
|
+
*/
|
|
94
|
+
export default function AddToCartButton({
|
|
95
|
+
productId,
|
|
96
|
+
variant = "primary",
|
|
97
|
+
}: AddToCartButtonProps) {
|
|
98
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
99
|
+
|
|
100
|
+
const handleClick = async () => {
|
|
101
|
+
setIsLoading(true);
|
|
102
|
+
await addToCart(productId);
|
|
103
|
+
setIsLoading(false);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<button onClick={handleClick} disabled={isLoading}>
|
|
108
|
+
{isLoading ? "Adding..." : "Add to Cart"}
|
|
109
|
+
</button>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> **Note**: If using Tailwind CSS with shadcn/ui, see `css-styling.instructions.md` for `cn()` utility usage.
|
|
115
|
+
|
|
116
|
+
## Props Interface Rules
|
|
117
|
+
|
|
118
|
+
### MUST Define Inside Component File
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// ✅ CORRECT: Props interface in same file, before component
|
|
122
|
+
interface ContactFormProps {
|
|
123
|
+
onSubmit: (data: FormData) => void;
|
|
124
|
+
initialValues?: Record<string, string>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default function ContactForm({ onSubmit, initialValues }: ContactFormProps) {
|
|
128
|
+
// Implementation
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Props Interface Naming
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// Interface name = ComponentName + "Props"
|
|
136
|
+
interface PaymentFormProps { }
|
|
137
|
+
interface CheckoutWizardProps { }
|
|
138
|
+
interface UserProfileProps { }
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Export Pattern
|
|
142
|
+
|
|
143
|
+
### Components: Default Export
|
|
144
|
+
|
|
145
|
+
Per Next.js recommendation, components use `export default` for better tree-shaking:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
// ✅ CORRECT: Components use default export
|
|
149
|
+
export default function UserProfile() { }
|
|
150
|
+
export default async function ProductList() { } // Server Component
|
|
151
|
+
|
|
152
|
+
// ❌ INCORRECT for components
|
|
153
|
+
export function UserProfile() { } // Named export - worse tree-shaking
|
|
154
|
+
export const UserProfile = () => { } // Arrow functions lose name in stack traces
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Everything Else: Named Exports
|
|
158
|
+
|
|
159
|
+
Helpers, types, utilities, hooks, and actions use named exports:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// ✅ CORRECT: Named exports for non-components
|
|
163
|
+
// helpers.ts
|
|
164
|
+
export function formatDate(date: Date): string { }
|
|
165
|
+
export function validateEmail(email: string): boolean { }
|
|
166
|
+
|
|
167
|
+
// types.ts
|
|
168
|
+
export interface User { }
|
|
169
|
+
export type PaymentStatus = "pending" | "completed";
|
|
170
|
+
|
|
171
|
+
// hooks/use-form-state.ts
|
|
172
|
+
export function useFormState() { }
|
|
173
|
+
|
|
174
|
+
// actions/checkout/create-order.ts
|
|
175
|
+
export async function createOrder(data: FormData) { }
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Barrel Exports for Domains
|
|
179
|
+
|
|
180
|
+
Use barrel exports (`index.ts`) to expose the domain's public API:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
// src/components/auth/index.ts
|
|
184
|
+
export { default as LoginForm } from "./login-form";
|
|
185
|
+
export { default as RegisterForm } from "./register-form";
|
|
186
|
+
export { default as PasswordReset } from "./password-reset";
|
|
187
|
+
|
|
188
|
+
// Usage
|
|
189
|
+
import { LoginForm, RegisterForm } from "@/components/auth";
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Separation of Concerns
|
|
193
|
+
|
|
194
|
+
### When to Create Separate Files
|
|
195
|
+
|
|
196
|
+
| File | When to Create |
|
|
197
|
+
|------|----------------|
|
|
198
|
+
| `types.ts` | Multiple types shared within component folder |
|
|
199
|
+
| `helpers.ts` | Pure utility functions for the component |
|
|
200
|
+
| `constants.ts` | Component-specific constants, configs |
|
|
201
|
+
| `hooks/` | Component-specific custom hooks |
|
|
202
|
+
|
|
203
|
+
### Example: Complex Component Structure
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
src/components/checkout-wizard/
|
|
207
|
+
├── index.tsx # Main wizard component
|
|
208
|
+
├── types.ts # WizardState, WizardAction, etc.
|
|
209
|
+
├── constants.ts # Step IDs, default values
|
|
210
|
+
├── hooks/
|
|
211
|
+
│ ├── use-wizard-state.ts # State management hook
|
|
212
|
+
│ └── use-submission.ts # Form submission hook
|
|
213
|
+
├── steps/
|
|
214
|
+
│ ├── shipping-step.tsx # Shipping info step
|
|
215
|
+
│ └── payment-step.tsx # Payment info step
|
|
216
|
+
└── __tests__/
|
|
217
|
+
└── checkout-wizard.test.tsx
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Import Rules
|
|
221
|
+
|
|
222
|
+
### ALWAYS Use Absolute Imports
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
// ✅ CORRECT: Absolute imports with @/
|
|
226
|
+
import { Button } from "@/components/ui/button";
|
|
227
|
+
import { cn } from "@/lib/utils";
|
|
228
|
+
import type { User } from "@/types";
|
|
229
|
+
|
|
230
|
+
// ❌ INCORRECT: Relative imports
|
|
231
|
+
import { Button } from "../../ui/button";
|
|
232
|
+
import { cn } from "../../../lib/utils";
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Domain Organization (DDD)
|
|
236
|
+
|
|
237
|
+
Components are organized by business domain with barrel exports:
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
src/components/
|
|
241
|
+
├── auth/ # Authentication domain
|
|
242
|
+
│ ├── index.ts # Barrel export
|
|
243
|
+
│ ├── login-form/
|
|
244
|
+
│ │ └── index.tsx # export default function LoginForm
|
|
245
|
+
│ ├── register-form/
|
|
246
|
+
│ │ └── index.tsx
|
|
247
|
+
│ └── password-reset/
|
|
248
|
+
│ └── index.tsx
|
|
249
|
+
├── checkout/ # Checkout domain
|
|
250
|
+
│ ├── index.ts # Barrel export
|
|
251
|
+
│ ├── cart-summary/
|
|
252
|
+
│ ├── payment-form/
|
|
253
|
+
│ └── add-to-cart-button/
|
|
254
|
+
├── dashboard/ # Dashboard domain
|
|
255
|
+
│ ├── index.ts
|
|
256
|
+
│ ├── stats-card/
|
|
257
|
+
│ └── activity-feed/
|
|
258
|
+
├── layout/ # Layout components
|
|
259
|
+
│ ├── index.ts
|
|
260
|
+
│ ├── header/
|
|
261
|
+
│ ├── footer/
|
|
262
|
+
│ └── sidebar/
|
|
263
|
+
├── shared/ # Cross-domain components
|
|
264
|
+
│ ├── index.ts
|
|
265
|
+
│ ├── loading-spinner/
|
|
266
|
+
│ └── error-boundary/
|
|
267
|
+
└── ui/ # Primitive UI (shadcn/ui)
|
|
268
|
+
├── button.tsx # UI primitives can be single files
|
|
269
|
+
├── input.tsx
|
|
270
|
+
└── modal.tsx
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Barrel Export Example
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
// src/components/auth/index.ts
|
|
277
|
+
export { default as LoginForm } from "./login-form";
|
|
278
|
+
export { default as RegisterForm } from "./register-form";
|
|
279
|
+
export { default as PasswordReset } from "./password-reset";
|
|
280
|
+
|
|
281
|
+
// src/components/checkout/index.ts
|
|
282
|
+
export { default as CartSummary } from "./cart-summary";
|
|
283
|
+
export { default as PaymentForm } from "./payment-form";
|
|
284
|
+
export { default as AddToCartButton } from "./add-to-cart-button";
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Clean Imports
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
// ✅ CORRECT: Import from domain barrel
|
|
291
|
+
import { LoginForm, RegisterForm } from "@/components/auth";
|
|
292
|
+
import { CartSummary, PaymentForm } from "@/components/checkout";
|
|
293
|
+
|
|
294
|
+
// ❌ INCORRECT: Deep imports when barrel exists
|
|
295
|
+
import LoginForm from "@/components/auth/login-form";
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Hook Placement Rules
|
|
299
|
+
|
|
300
|
+
### CRITICAL: All hooks BEFORE conditional returns
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
// ✅ CORRECT
|
|
304
|
+
export default function Component({ data }: Props) {
|
|
305
|
+
const [state, setState] = useState(initialState);
|
|
306
|
+
const handleClick = useCallback(() => {}, []);
|
|
307
|
+
|
|
308
|
+
// Early returns AFTER all hooks
|
|
309
|
+
if (!data) return null;
|
|
310
|
+
|
|
311
|
+
return <div>...</div>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// ❌ INCORRECT: Hooks after conditional
|
|
315
|
+
export function Component({ data }: Props) {
|
|
316
|
+
if (!data) return null; // ❌ Early return before hooks
|
|
317
|
+
|
|
318
|
+
const [state, setState] = useState(initialState); // ❌ Error!
|
|
319
|
+
return <div>...</div>;
|
|
320
|
+
}
|
|
321
|
+
```
|