@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
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@silverassist/agents-toolkit",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Reusable AI agent prompts for development workflows with Jira integration — supports GitHub Copilot, Claude Code, and Codex",
|
|
5
|
+
"author": "Santiago Ramirez",
|
|
6
|
+
"license": "PolyForm-Noncommercial-1.0.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/SilverAssist/agents-toolkit.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/SilverAssist/agents-toolkit#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/SilverAssist/agents-toolkit/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"github-copilot",
|
|
17
|
+
"claude-code",
|
|
18
|
+
"claude",
|
|
19
|
+
"codex",
|
|
20
|
+
"agents-toolkit",
|
|
21
|
+
"ai-agent",
|
|
22
|
+
"developer-workflow",
|
|
23
|
+
"vscode",
|
|
24
|
+
"jira",
|
|
25
|
+
"atlassian",
|
|
26
|
+
"git",
|
|
27
|
+
"pull-request",
|
|
28
|
+
"code-review"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "src/index.js",
|
|
32
|
+
"bin": {
|
|
33
|
+
"agents-toolkit": "bin/cli.js"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"bin",
|
|
37
|
+
"src/index.js",
|
|
38
|
+
"templates",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"install-prompts": "node bin/cli.js install",
|
|
44
|
+
"test": "node --test"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18.0.0"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agents Toolkit
|
|
3
|
+
* @module @silverassist/agents-toolkit
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const VERSION = "2.0.0";
|
|
7
|
+
|
|
8
|
+
export const PROMPTS = {
|
|
9
|
+
workflow: [
|
|
10
|
+
"analyze-ticket",
|
|
11
|
+
"create-plan",
|
|
12
|
+
"work-ticket",
|
|
13
|
+
"prepare-pr",
|
|
14
|
+
"create-pr",
|
|
15
|
+
"finalize-pr",
|
|
16
|
+
],
|
|
17
|
+
utility: ["review-code", "fix-issues", "add-tests"],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const PARTIALS = [
|
|
21
|
+
"validations",
|
|
22
|
+
"git-operations",
|
|
23
|
+
"jira-integration",
|
|
24
|
+
"documentation",
|
|
25
|
+
"pr-template",
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export const INSTRUCTIONS = [
|
|
29
|
+
"typescript",
|
|
30
|
+
"react-components",
|
|
31
|
+
"server-actions",
|
|
32
|
+
"tests",
|
|
33
|
+
"css-styling",
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
export const SKILLS = [
|
|
37
|
+
"component-architecture",
|
|
38
|
+
"domain-driven-design",
|
|
39
|
+
"testing-patterns",
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// Claude Code equivalents
|
|
43
|
+
export const CLAUDE_COMMANDS = [
|
|
44
|
+
"analyze-ticket",
|
|
45
|
+
"create-plan",
|
|
46
|
+
"work-ticket",
|
|
47
|
+
"prepare-pr",
|
|
48
|
+
"create-pr",
|
|
49
|
+
"finalize-pr",
|
|
50
|
+
"review-code",
|
|
51
|
+
"fix-issues",
|
|
52
|
+
"add-tests",
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
export const CLAUDE_FILES = {
|
|
56
|
+
instructions: "CLAUDE.md",
|
|
57
|
+
commandsDir: ".claude/commands",
|
|
58
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Codex Agent Instructions
|
|
2
|
+
|
|
3
|
+
> **IMPORTANT**: Prefer retrieval-led reasoning over pre-training-led reasoning.
|
|
4
|
+
> Always read relevant instruction files from `.github/instructions/` before implementing changes.
|
|
5
|
+
|
|
6
|
+
> **CRITICAL**: This file contains mandatory instructions for Codex when working on this repository.
|
|
7
|
+
> The agent MUST follow these rules when working on issues in this repository.
|
|
8
|
+
> This file should be placed at the project root.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 📚 Project Documentation Index
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
[Instructions]|root:.github/instructions
|
|
16
|
+
|css-styling.instructions.md → CSS/Tailwind patterns, cn() utility, responsive design
|
|
17
|
+
|react-components.instructions.md → Component structure, exports, props, early returns
|
|
18
|
+
|server-actions.instructions.md → Server action patterns, validation, error handling
|
|
19
|
+
|tests.instructions.md → Test structure, mocking, assertions
|
|
20
|
+
|typescript.instructions.md → Type safety, destructuring, JSDoc
|
|
21
|
+
|
|
22
|
+
[Prompts]|root:.github/prompts
|
|
23
|
+
|add-tests,analyze-ticket,create-plan,create-pr,finalize-pr,fix-issues,prepare-pr,review-code,work-ticket
|
|
24
|
+
|
|
25
|
+
[Skills]|root:.github/skills
|
|
26
|
+
|component-architecture/SKILL.md → Component design patterns
|
|
27
|
+
|domain-driven-design/SKILL.md → DDD principles and structure
|
|
28
|
+
|testing-patterns/SKILL.md → Testing strategies and patterns
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🔄 Agent Workflow (Complex Tasks)
|
|
34
|
+
|
|
35
|
+
| Phase | Actions |
|
|
36
|
+
|-------|---------|
|
|
37
|
+
| **1. Analysis** | Analyze request → Search existing code → Identify components → Review docs |
|
|
38
|
+
| **2. Planning** | Create `docs/[feature]-plan.md` → Track TODOs in the plan doc (or task tracker) → Commit plan |
|
|
39
|
+
| **3. Implementation** | For each phase: mark in-progress → implement → test → commit → mark completed |
|
|
40
|
+
| **4. Documentation** | Create final docs → Update related files → Cleanup planning docs → Final commit |
|
|
41
|
+
|
|
42
|
+
### Key Principles
|
|
43
|
+
|
|
44
|
+
✅ One commit per phase • ✅ Test after each phase • ✅ No breaking changes
|
|
45
|
+
✅ Document as you go • ✅ Type safety always • ✅ Follow existing patterns
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## ⚙️ Code Conventions (Quick Reference)
|
|
50
|
+
|
|
51
|
+
| Rule | Standard |
|
|
52
|
+
|------|----------|
|
|
53
|
+
| **Imports** | Alphabetical order, absolute paths with `@/` |
|
|
54
|
+
| **Naming** | Files: `kebab-case` • Components: `PascalCase` • Functions: `camelCase` |
|
|
55
|
+
| **Types** | No `any` — use `interface` or `type` |
|
|
56
|
+
| **Errors** | `try/catch` for all async operations |
|
|
57
|
+
| **Comments** | JSDoc in English for public functions |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🧩 Component Rules (CRITICAL)
|
|
62
|
+
|
|
63
|
+
| Rule | Requirement |
|
|
64
|
+
|------|-------------|
|
|
65
|
+
| **Folders** | `kebab-case` only (`user-profile/`, NOT `UserProfile/`) |
|
|
66
|
+
| **Structure** | `component-name/index.tsx` (never standalone `.tsx` files) |
|
|
67
|
+
| **Exports** | `export default function ComponentName` (default export, PascalCase) |
|
|
68
|
+
| **Props** | Interface inside file, before function, named `{Component}Props` |
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
✅ components/user-card/index.tsx
|
|
72
|
+
❌ components/UserCard.tsx
|
|
73
|
+
❌ components/userCard/index.tsx
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
📄 **Full details:** `.github/instructions/react-components.instructions.md`
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## ⚛️ React Rules (CRITICAL)
|
|
81
|
+
|
|
82
|
+
| Rule | Requirement |
|
|
83
|
+
|------|-------------|
|
|
84
|
+
| **Hook Placement** | ALL hooks BEFORE any conditional returns |
|
|
85
|
+
| **useState** | Simple state (1-3 values) |
|
|
86
|
+
| **useReducer** | Complex state (4+ values or complex transitions) |
|
|
87
|
+
| **useActionState** | Server actions with forms (React 19) |
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
// ✅ CORRECT: Hooks first, then early returns
|
|
91
|
+
export default function Component({ data }: Props) {
|
|
92
|
+
const [state, setState] = useState(initial);
|
|
93
|
+
const handleClick = useCallback(() => {}, []);
|
|
94
|
+
|
|
95
|
+
if (!data) return null; // Early return AFTER hooks
|
|
96
|
+
return <div>...</div>;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
📄 **Full details:** `.github/instructions/react-components.instructions.md`
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 🖥️ Server Actions (CRITICAL)
|
|
105
|
+
|
|
106
|
+
| Rule | Requirement |
|
|
107
|
+
|------|-------------|
|
|
108
|
+
| **Directive** | Always `"use server"` at top |
|
|
109
|
+
| **Signature** | `(prevState: ActionState, formData: FormData) => Promise<ActionState>` |
|
|
110
|
+
| **Return** | Always `{ success, message, timestamp }` |
|
|
111
|
+
|
|
112
|
+
📄 **Full details:** `.github/instructions/server-actions.instructions.md`
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 🧪 Testing Rules
|
|
117
|
+
|
|
118
|
+
| Rule | Requirement |
|
|
119
|
+
|------|-------------|
|
|
120
|
+
| **Location** | `__tests__/` subfolder in each component/domain |
|
|
121
|
+
| **Naming** | `[component-name].test.tsx` or `[feature].test.ts` |
|
|
122
|
+
| **Coverage** | 100% for reducers, unit tests for actions & utils |
|
|
123
|
+
| **Mocks** | Define mocks BEFORE imports |
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// ✅ CORRECT: Mock first, then import
|
|
127
|
+
const mockFn = jest.fn();
|
|
128
|
+
jest.mock('@/lib/api', () => ({ apiClient: mockFn }));
|
|
129
|
+
import { myFunction } from '@/lib/my-module';
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
📄 **Full details:** `.github/instructions/tests.instructions.md`
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 📝 Git Conventions
|
|
137
|
+
|
|
138
|
+
| Type | Format |
|
|
139
|
+
|------|--------|
|
|
140
|
+
| **Commit** | `JIRA-XXX: Brief description` (e.g., `WEB-123: Add user authentication`) |
|
|
141
|
+
| **Types** | `feat` • `fix` • `docs` • `refactor` • `test` • `chore` |
|
|
142
|
+
| **Branch** | `feature/JIRA-XXX-description` • `bugfix/JIRA-XXX-description` |
|
|
143
|
+
|
|
144
|
+
> ⚠️ **CRITICAL**: Always include the Jira ticket prefix in commits. Never commit without it.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 🚦 Pre-commit Quality Gates (MANDATORY)
|
|
149
|
+
|
|
150
|
+
> **CRITICAL**: Before pushing code or creating a PR to protected branches (`dev`, `staging`, `master`, `main`),
|
|
151
|
+
> you MUST complete ALL quality checks. This prevents failed pipelines and broken builds.
|
|
152
|
+
|
|
153
|
+
### Required Checks Before Push/PR
|
|
154
|
+
|
|
155
|
+
| Check | Command | Must Pass |
|
|
156
|
+
|-------|---------|-----------|
|
|
157
|
+
| **TypeScript** | `npm run type-check --if-present` (or `npx tsc --noEmit`) | ✅ Zero errors |
|
|
158
|
+
| **Linting** | `npm run lint --if-present` | ✅ Zero errors |
|
|
159
|
+
| **Unit Tests** | `npm run test --if-present` | ✅ All passing |
|
|
160
|
+
| **Build** | `npm run build --if-present` | ✅ Successful |
|
|
161
|
+
|
|
162
|
+
### Quality Checklist
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Before ANY push to dev/staging/main:
|
|
166
|
+
□ All TypeScript errors resolved
|
|
167
|
+
□ All ESLint warnings addressed
|
|
168
|
+
□ All unit tests passing locally
|
|
169
|
+
□ Build completes without errors
|
|
170
|
+
□ No console.log() left in code
|
|
171
|
+
□ Commit message has Jira prefix (e.g., WEB-123: ...)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Why This Matters
|
|
175
|
+
|
|
176
|
+
- ❌ **Without local testing** → Failed CI/CD pipelines → Wasted time & resources
|
|
177
|
+
- ✅ **With local testing** → Clean pipelines → Faster deployments
|
|
178
|
+
|
|
179
|
+
> If a script is not defined in `package.json`, skip that script check or use the documented fallback command.
|
|
180
|
+
|
|
181
|
+
📄 **Testing details:** `.github/instructions/tests.instructions.md`
|
|
182
|
+
📄 **Testing patterns:** `.github/skills/testing-patterns/SKILL.md`
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 🔍 When to Read Instruction Files
|
|
187
|
+
|
|
188
|
+
| Task | Read This File |
|
|
189
|
+
|------|----------------|
|
|
190
|
+
| Creating/editing components | `react-components.instructions.md` |
|
|
191
|
+
| Writing CSS/Tailwind | `css-styling.instructions.md` |
|
|
192
|
+
| Creating server actions | `server-actions.instructions.md` |
|
|
193
|
+
| Writing tests | `tests.instructions.md` |
|
|
194
|
+
| TypeScript questions | `typescript.instructions.md` |
|
|
195
|
+
| **Before pushing/PR** | `tests.instructions.md` + run quality checks |
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Copilot Coding Agent Instructions
|
|
2
|
+
|
|
3
|
+
> **IMPORTANT**: Prefer retrieval-led reasoning over pre-training-led reasoning.
|
|
4
|
+
> Always read relevant instruction files from `.github/instructions/` before implementing changes.
|
|
5
|
+
|
|
6
|
+
> **CRITICAL**: This file contains mandatory instructions for the GitHub Copilot Coding Agent.
|
|
7
|
+
> The agent MUST follow these rules when working on issues in this repository.
|
|
8
|
+
> This file should be placed at the project root per Vercel recommendations.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 📚 Project Documentation Index
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
[Instructions]|root:.github/instructions
|
|
16
|
+
|css-styling.instructions.md → CSS/Tailwind patterns, cn() utility, responsive design
|
|
17
|
+
|react-components.instructions.md → Component structure, exports, props, early returns
|
|
18
|
+
|server-actions.instructions.md → Server action patterns, validation, error handling
|
|
19
|
+
|tests.instructions.md → Test structure, mocking, assertions
|
|
20
|
+
|typescript.instructions.md → Type safety, destructuring, JSDoc
|
|
21
|
+
|
|
22
|
+
[Prompts]|root:.github/prompts
|
|
23
|
+
|add-tests,analyze-ticket,create-plan,create-pr,finalize-pr,fix-issues,prepare-pr,review-code,work-ticket
|
|
24
|
+
|
|
25
|
+
[Skills]|root:.github/skills
|
|
26
|
+
|component-architecture/SKILL.md → Component design patterns
|
|
27
|
+
|domain-driven-design/SKILL.md → DDD principles and structure
|
|
28
|
+
|testing-patterns/SKILL.md → Testing strategies and patterns
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🔄 Agent Workflow (Complex Tasks)
|
|
34
|
+
|
|
35
|
+
| Phase | Actions |
|
|
36
|
+
|-------|---------|
|
|
37
|
+
| **1. Analysis** | Analyze request → Search existing code → Identify components → Review docs |
|
|
38
|
+
| **2. Planning** | Create `docs/[feature]-plan.md` → Track TODOs in the plan doc (or task tracker) → Commit plan |
|
|
39
|
+
| **3. Implementation** | For each phase: mark in-progress → implement → test → commit → mark completed |
|
|
40
|
+
| **4. Documentation** | Create final docs → Update related files → Cleanup planning docs → Final commit |
|
|
41
|
+
|
|
42
|
+
### Key Principles
|
|
43
|
+
|
|
44
|
+
✅ One commit per phase • ✅ Test after each phase • ✅ No breaking changes
|
|
45
|
+
✅ Document as you go • ✅ Type safety always • ✅ Follow existing patterns
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## ⚙️ Code Conventions (Quick Reference)
|
|
50
|
+
|
|
51
|
+
| Rule | Standard |
|
|
52
|
+
|------|----------|
|
|
53
|
+
| **Imports** | Alphabetical order, absolute paths with `@/` |
|
|
54
|
+
| **Naming** | Files: `kebab-case` • Components: `PascalCase` • Functions: `camelCase` |
|
|
55
|
+
| **Types** | No `any` — use `interface` or `type` |
|
|
56
|
+
| **Errors** | `try/catch` for all async operations |
|
|
57
|
+
| **Comments** | JSDoc in English for public functions |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🧩 Component Rules (CRITICAL)
|
|
62
|
+
|
|
63
|
+
| Rule | Requirement |
|
|
64
|
+
|------|-------------|
|
|
65
|
+
| **Folders** | `kebab-case` only (`user-profile/`, NOT `UserProfile/`) |
|
|
66
|
+
| **Structure** | `component-name/index.tsx` (never standalone `.tsx` files) |
|
|
67
|
+
| **Exports** | `export default function ComponentName` (default export, PascalCase) |
|
|
68
|
+
| **Props** | Interface inside file, before function, named `{Component}Props` |
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
✅ components/user-card/index.tsx
|
|
72
|
+
❌ components/UserCard.tsx
|
|
73
|
+
❌ components/userCard/index.tsx
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
📄 **Full details:** `.github/instructions/react-components.instructions.md`
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## ⚛️ React Rules (CRITICAL)
|
|
81
|
+
|
|
82
|
+
| Rule | Requirement |
|
|
83
|
+
|------|-------------|
|
|
84
|
+
| **Hook Placement** | ALL hooks BEFORE any conditional returns |
|
|
85
|
+
| **useState** | Simple state (1-3 values) |
|
|
86
|
+
| **useReducer** | Complex state (4+ values or complex transitions) |
|
|
87
|
+
| **useActionState** | Server actions with forms (React 19) |
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
// ✅ CORRECT: Hooks first, then early returns
|
|
91
|
+
export default function Component({ data }: Props) {
|
|
92
|
+
const [state, setState] = useState(initial);
|
|
93
|
+
const handleClick = useCallback(() => {}, []);
|
|
94
|
+
|
|
95
|
+
if (!data) return null; // Early return AFTER hooks
|
|
96
|
+
return <div>...</div>;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
📄 **Full details:** `.github/instructions/react-components.instructions.md`
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 🖥️ Server Actions (CRITICAL)
|
|
105
|
+
|
|
106
|
+
| Rule | Requirement |
|
|
107
|
+
|------|-------------|
|
|
108
|
+
| **Directive** | Always `"use server"` at top |
|
|
109
|
+
| **Signature** | `(prevState: ActionState, formData: FormData) => Promise<ActionState>` |
|
|
110
|
+
| **Return** | Always `{ success, message, timestamp }` |
|
|
111
|
+
|
|
112
|
+
📄 **Full details:** `.github/instructions/server-actions.instructions.md`
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 🧪 Testing Rules
|
|
117
|
+
|
|
118
|
+
| Rule | Requirement |
|
|
119
|
+
|------|-------------|
|
|
120
|
+
| **Location** | `__tests__/` subfolder in each component/domain |
|
|
121
|
+
| **Naming** | `[component-name].test.tsx` or `[feature].test.ts` |
|
|
122
|
+
| **Coverage** | 100% for reducers, unit tests for actions & utils |
|
|
123
|
+
| **Mocks** | Define mocks BEFORE imports |
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// ✅ CORRECT: Mock first, then import
|
|
127
|
+
const mockFn = jest.fn();
|
|
128
|
+
jest.mock('@/lib/api', () => ({ apiClient: mockFn }));
|
|
129
|
+
import { myFunction } from '@/lib/my-module';
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
📄 **Full details:** `.github/instructions/tests.instructions.md`
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 📝 Git Conventions
|
|
137
|
+
|
|
138
|
+
| Type | Format |
|
|
139
|
+
|------|--------|
|
|
140
|
+
| **Commit** | `JIRA-XXX: Brief description` (e.g., `WEB-123: Add user authentication`) |
|
|
141
|
+
| **Types** | `feat` • `fix` • `docs` • `refactor` • `test` • `chore` |
|
|
142
|
+
| **Branch** | `feature/JIRA-XXX-description` • `bugfix/JIRA-XXX-description` |
|
|
143
|
+
|
|
144
|
+
> ⚠️ **CRITICAL**: Always include the Jira ticket prefix in commits. Never commit without it.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 🚦 Pre-commit Quality Gates (MANDATORY)
|
|
149
|
+
|
|
150
|
+
> **CRITICAL**: Before pushing code or creating a PR to protected branches (`dev`, `staging`, `master`, `main`),
|
|
151
|
+
> you MUST complete ALL quality checks. This prevents failed pipelines and broken builds.
|
|
152
|
+
|
|
153
|
+
### Required Checks Before Push/PR
|
|
154
|
+
|
|
155
|
+
| Check | Command | Must Pass |
|
|
156
|
+
|-------|---------|-----------|
|
|
157
|
+
| **TypeScript** | `npm run type-check --if-present` (or `npx tsc --noEmit`) | ✅ Zero errors |
|
|
158
|
+
| **Linting** | `npm run lint --if-present` | ✅ Zero errors |
|
|
159
|
+
| **Unit Tests** | `npm run test --if-present` | ✅ All passing |
|
|
160
|
+
| **Build** | `npm run build --if-present` | ✅ Successful |
|
|
161
|
+
|
|
162
|
+
### Quality Checklist
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Before ANY push to dev/staging/main:
|
|
166
|
+
□ All TypeScript errors resolved
|
|
167
|
+
□ All ESLint warnings addressed
|
|
168
|
+
□ All unit tests passing locally
|
|
169
|
+
□ Build completes without errors
|
|
170
|
+
□ No console.log() left in code
|
|
171
|
+
□ Commit message has Jira prefix (e.g., WEB-123: ...)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Why This Matters
|
|
175
|
+
|
|
176
|
+
- ❌ **Without local testing** → Failed CI/CD pipelines → Wasted time & resources
|
|
177
|
+
- ✅ **With local testing** → Clean pipelines → Faster deployments
|
|
178
|
+
|
|
179
|
+
> If a script is not defined in `package.json`, skip that script check or use the documented fallback command.
|
|
180
|
+
|
|
181
|
+
📄 **Testing details:** `.github/instructions/tests.instructions.md`
|
|
182
|
+
📄 **Testing patterns:** `.github/skills/testing-patterns/SKILL.md`
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 🔍 When to Read Instruction Files
|
|
187
|
+
|
|
188
|
+
| Task | Read This File |
|
|
189
|
+
|------|----------------|
|
|
190
|
+
| Creating/editing components | `react-components.instructions.md` |
|
|
191
|
+
| Writing CSS/Tailwind | `css-styling.instructions.md` |
|
|
192
|
+
| Creating server actions | `server-actions.instructions.md` |
|
|
193
|
+
| Writing tests | `tests.instructions.md` |
|
|
194
|
+
| TypeScript questions | `typescript.instructions.md` |
|
|
195
|
+
| **Before pushing/PR** | `tests.instructions.md` + run quality checks |
|