@relipa/ai-flow-kit 0.2.0 → 0.2.1

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 (38) hide show
  1. package/custom/rules/java/spring-boot-rules.md +209 -0
  2. package/custom/rules/javascript/nestjs-examples.md +41 -0
  3. package/custom/rules/javascript/nestjs-rules.md +42 -0
  4. package/custom/rules/javascript/nodejs-express-examples.md +35 -0
  5. package/custom/rules/javascript/nodejs-express-rules.md +49 -0
  6. package/custom/rules/javascript/reactjs-examples.md +380 -0
  7. package/custom/rules/javascript/reactjs-rules.md +173 -0
  8. package/custom/rules/php/php-examples.md +161 -0
  9. package/custom/rules/php/php-rules.md +127 -0
  10. package/custom/rules/python/python-django-examples.md +34 -0
  11. package/custom/rules/python/python-django-rules.md +48 -0
  12. package/custom/rules/python/python-examples.md +32 -0
  13. package/custom/rules/python/python-fastapi-examples.md +30 -0
  14. package/custom/rules/python/python-fastapi-rules.md +35 -0
  15. package/custom/rules/python/python-ml-examples.md +187 -0
  16. package/custom/rules/python/python-ml-rules.md +121 -0
  17. package/custom/rules/python/python-rules.md +58 -0
  18. package/custom/skills/ba-skills/skill-ba-qna-template-v1.md +4 -4
  19. package/custom/skills/ba-skills/skill-ba-qna-v1.md +6 -0
  20. package/custom/skills/create-system-requirement/SKILL.md +52 -16
  21. package/custom/skills/create-system-requirement/system-requirement-template-v1.md +128 -0
  22. package/custom/skills/impact-analysis/SKILL.md +106 -106
  23. package/custom/skills/report-customer/SKILL.md +99 -99
  24. package/custom/templates/nestjs.md +5 -72
  25. package/custom/templates/nodejs-express.md +5 -73
  26. package/custom/templates/php-plain.md +5 -261
  27. package/custom/templates/php.md +5 -261
  28. package/custom/templates/python-django.md +5 -71
  29. package/custom/templates/python-fastapi.md +5 -54
  30. package/custom/templates/python-ml.md +1 -269
  31. package/custom/templates/python.md +5 -79
  32. package/custom/templates/reactjs.md +5 -492
  33. package/custom/templates/shared/gate-workflow.md +1 -0
  34. package/custom/templates/shared/ml-gate-workflow.md +1 -0
  35. package/custom/templates/spring-boot.md +5 -224
  36. package/docs/common/CHANGELOG.md +20 -10
  37. package/package.json +1 -1
  38. package/scripts/init.js +143 -40
@@ -1,99 +1,99 @@
1
- ---
2
- name: report-customer
3
- description: Write an incident report for customers or customer service after a production bug fix. Non-technical, easy-to-understand language.
4
- keywords: report, incident, customer, customer service, CS
5
- ---
6
-
7
- # Report Customer (Incident Report)
8
-
9
- ## When to use
10
-
11
- - After fixing a bug that affects users/customers
12
- - Customer Service needs a report explaining the cause to customers
13
- - Need to document the incident for future reference
14
-
15
- ---
16
-
17
- ## Process
18
-
19
- ### Step 1: Gather information
20
-
21
- Collect from `investigate-bug` results or developer descriptions:
22
- - Ticket ID and title
23
- - Discovery time / impact duration
24
- - Number of affected users / orders
25
- - Identified root cause
26
- - Deployment status
27
-
28
- ### Step 2: Write the report
29
-
30
- Fill in the structure below. **Use simple language, avoiding technical jargon.**
31
-
32
- ---
33
-
34
- ## Standard Structure
35
-
36
- Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md`
37
- (Vietnamese ticket → Vietnamese report; otherwise English). CS can request a specific language
38
- explicitly, which overrides auto-detect. Structure below is shown in English.
39
-
40
- ```markdown
41
- ## 📋 Incident Verification Report
42
-
43
- **Ticket ID:** [ID]
44
- **Assigned to:** [Dev Name]
45
- **Resolution Date:** [YYYY-MM-DD]
46
- **Status:** ✅ Resolved / 🔄 In Progress
47
-
48
- ---
49
-
50
- ### 1. Summary
51
-
52
- [1–2 sentences describing the issue in non-technical language.
53
- Example: "Between 14:00–15:30 on [Date], some
54
- users were unable to complete order payments."]
55
-
56
- ---
57
-
58
- ### 2. Root Cause
59
-
60
- [Simple explanation, no code references.
61
- Example: "Due to a system update failing to correctly handle
62
- slow connections with the payment gateway."]
63
-
64
- ---
65
-
66
- ### 3. Resolution
67
-
68
- [Steps taken by the technical team.
69
- Example: "Updated the timeout handling mechanism and deployed
70
- the fix at 16:00 on [Date]."]
71
-
72
- ---
73
-
74
- ### 4. Data Impact
75
-
76
- - Was existing data affected? [Yes / No]
77
- - Data recovery status: [Update script run / Not necessary]
78
-
79
- ---
80
-
81
- ### 5. Expected Behavior
82
-
83
- [Actions the customer should take to verify normal operation.
84
- Example: "Customers can now attempt payment normally.
85
- If problems persist, please contact our support hotline..."]
86
- ```
87
-
88
- ---
89
-
90
- ## Writing Rules
91
-
92
- - ✅ Simple language, avoid technical jargon
93
- - ✅ Honest about scope and duration of impact
94
- - ✅ Focus on **user impact**, not code details
95
- - ✅ Always include instructions for the customer to verify the fix
96
- - ❌ Do not blame third parties unless certain
97
- - ❌ Do not commit to specific deadlines unless certain
98
-
99
- Present clearly and professionally, in the language determined above.
1
+ ---
2
+ name: report-customer
3
+ description: Write an incident report for customers or customer service after a production bug fix. Non-technical, easy-to-understand language.
4
+ keywords: report, incident, customer, customer service, CS
5
+ ---
6
+
7
+ # Report Customer (Incident Report)
8
+
9
+ ## When to use
10
+
11
+ - After fixing a bug that affects users/customers
12
+ - Customer Service needs a report explaining the cause to customers
13
+ - Need to document the incident for future reference
14
+
15
+ ---
16
+
17
+ ## Process
18
+
19
+ ### Step 1: Gather information
20
+
21
+ Collect from `investigate-bug` results or developer descriptions:
22
+ - Ticket ID and title
23
+ - Discovery time / impact duration
24
+ - Number of affected users / orders
25
+ - Identified root cause
26
+ - Deployment status
27
+
28
+ ### Step 2: Write the report
29
+
30
+ Fill in the structure below. **Use simple language, avoiding technical jargon.**
31
+
32
+ ---
33
+
34
+ ## Standard Structure
35
+
36
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md`
37
+ (Vietnamese ticket → Vietnamese report; otherwise English). CS can request a specific language
38
+ explicitly, which overrides auto-detect. Structure below is shown in English.
39
+
40
+ ```markdown
41
+ ## 📋 Incident Verification Report
42
+
43
+ **Ticket ID:** [ID]
44
+ **Assigned to:** [Dev Name]
45
+ **Resolution Date:** [YYYY-MM-DD]
46
+ **Status:** ✅ Resolved / 🔄 In Progress
47
+
48
+ ---
49
+
50
+ ### 1. Summary
51
+
52
+ [1–2 sentences describing the issue in non-technical language.
53
+ Example: "Between 14:00–15:30 on [Date], some
54
+ users were unable to complete order payments."]
55
+
56
+ ---
57
+
58
+ ### 2. Root Cause
59
+
60
+ [Simple explanation, no code references.
61
+ Example: "Due to a system update failing to correctly handle
62
+ slow connections with the payment gateway."]
63
+
64
+ ---
65
+
66
+ ### 3. Resolution
67
+
68
+ [Steps taken by the technical team.
69
+ Example: "Updated the timeout handling mechanism and deployed
70
+ the fix at 16:00 on [Date]."]
71
+
72
+ ---
73
+
74
+ ### 4. Data Impact
75
+
76
+ - Was existing data affected? [Yes / No]
77
+ - Data recovery status: [Update script run / Not necessary]
78
+
79
+ ---
80
+
81
+ ### 5. Expected Behavior
82
+
83
+ [Actions the customer should take to verify normal operation.
84
+ Example: "Customers can now attempt payment normally.
85
+ If problems persist, please contact our support hotline..."]
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Writing Rules
91
+
92
+ - ✅ Simple language, avoid technical jargon
93
+ - ✅ Honest about scope and duration of impact
94
+ - ✅ Focus on **user impact**, not code details
95
+ - ✅ Always include instructions for the customer to verify the fix
96
+ - ❌ Do not blame third parties unless certain
97
+ - ❌ Do not commit to specific deadlines unless certain
98
+
99
+ Present clearly and professionally, in the language determined above.
@@ -1,72 +1,5 @@
1
- # NestJS AI System Prompt
2
-
3
- You are an expert NestJS developer. Follow these modular architecture rules and best practices.
4
-
5
- ---
6
-
7
- ## Project Architecture
8
-
9
- NestJS follows a strict **Module-based** architecture. Every feature should be contained in its own module.
10
-
11
- ```
12
- src/
13
- ├── app.module.ts
14
- ├── main.ts
15
- └── features/
16
- └── [feature-name]/
17
- ├── [feature].module.ts
18
- ├── [feature].controller.ts
19
- ├── [feature].service.ts
20
- ├── [feature].entity.ts (if using TypeORM)
21
- └── dto/
22
- ├── create-[feature].dto.ts
23
- └── update-[feature].dto.ts
24
- ```
25
-
26
- ---
27
-
28
- ## NestJS Rules
29
-
30
- - Use **Constructor Injection** for all dependencies.
31
- - Always use **DTOs** (Data Transfer Objects) with `class-validator` for input validation.
32
- - Annotate controllers with `@Controller()`.
33
- - Use `@Injectable()` for services.
34
- - Leverage **Pipes** for data transformation and validation.
35
- - Leverage **Interceptors** for logging and response mapping.
36
-
37
- ```typescript
38
- // ✅ Good: DTO with validation
39
- export class CreateUserDto {
40
- @IsEmail()
41
- email: string;
42
-
43
- @IsString()
44
- @MinLength(8)
45
- password: string;
46
- }
47
- ```
48
-
49
- ---
50
-
51
- ## Testing Rules
52
-
53
- - Use the built-in **Jest** testing suite.
54
- - Use `Test.createTestingModule` to create isolated environments for unit tests.
55
-
56
- ```typescript
57
- describe('UsersService', () => {
58
- let service: UsersService;
59
-
60
- beforeEach(async () => {
61
- const module: TestingModule = await Test.createTestingModule({
62
- providers: [UsersService],
63
- }).compile();
64
-
65
- service = module.get<UsersService>(UsersService);
66
- });
67
-
68
- it('should be defined', () => {
69
- expect(service).toBeDefined();
70
- });
71
- });
72
- ```
1
+ # NestJS AI System Prompt
2
+
3
+ You are an expert NestJS developer. Follow these modular architecture rules and best practices.
4
+
5
+ > **Rules & code examples:** Read `.rules/javascript/nestjs-rules.md` (architecture, module rules, testing) and `.rules/javascript/nestjs-examples.md` (code samples per rule area) **in full** before writing or modifying any NestJS code in this project.
@@ -1,73 +1,5 @@
1
- # Node.js Express AI System Prompt
2
-
3
- You are an expert Node.js developer specialized in the Express.js framework. Follow these rules for building clean, maintainable, and secure backends.
4
-
5
- ---
6
-
7
- ## Project Structure
8
-
9
- Follow the **Controller-Service-Repository** pattern:
10
-
11
- ```
12
- src/
13
- ├── controllers/ # Route handlers — parse input, call service, return response
14
- ├── services/ # Business logic — core logic, database transactions
15
- ├── repositories/ # Data access — database queries, ORM interactions
16
- ├── models/ # Database models (Sequelize/Prisma/Mongoose)
17
- ├── middleware/ # Custom Express middleware (auth, logging)
18
- ├── routes/ # Route definitions
19
- ├── dtos/ # Input/Output Data Transfer Objects (if using TS)
20
- ├── utils/ # Stateless helper functions
21
- └── config/ # App configuration
22
- ```
23
-
24
- ---
25
-
26
- ## Express Rules
27
-
28
- - Use **Async/Await** for all asynchronous operations — avoid callbacks or manual promise chains.
29
- - Always use a global error handler middleware. Never use `try/catch` in controllers if you use an async-wrapper middleware.
30
- - Validate all incoming data using `Joi`, `Zod`, or `express-validator`.
31
- - Keep controllers thin; they should only handle request parsing and response formatting.
32
-
33
- ```javascript
34
- // ✅ Good: Controller calls service
35
- export const createUser = async (req, res, next) => {
36
- const userData = req.body;
37
- const user = await userService.create(userData);
38
- res.status(201).json(user);
39
- };
40
- ```
41
-
42
- ---
43
-
44
- ## Security Rules
45
-
46
- - Never expose stack traces in production.
47
- - Use `helmet` to set secure HTTP headers.
48
- - Sanitize input to prevent NoSQL/SQL injection.
49
- - Use `argon2` or `bcrypt` for password hashing.
50
- - Standardize on JWT for authentication.
51
-
52
- ---
53
-
54
- ## Testing Rules
55
-
56
- - Use **Jest** and **Supertest** for testing.
57
- - Test every API endpoint with integration tests.
58
- - Mock external services (Email, Payment Gateways).
59
-
60
- ```javascript
61
- // Example test
62
- import request from 'supertest';
63
- import app from '../app';
64
-
65
- describe('POST /api/users', () => {
66
- it('should create a new user', async () => {
67
- const response = await request(app)
68
- .post('/api/users')
69
- .send({ email: 'test@example.com', password: 'password123' });
70
- expect(response.status).toBe(201);
71
- });
72
- });
73
- ```
1
+ # Node.js Express AI System Prompt
2
+
3
+ You are an expert Node.js developer specialized in the Express.js framework. Follow these rules for building clean, maintainable, and secure backends.
4
+
5
+ > **Rules & code examples:** Read `.rules/javascript/nodejs-express-rules.md` (structure, framework rules, security, testing) and `.rules/javascript/nodejs-express-examples.md` (code samples per rule area) **in full** before writing or modifying any Express code in this project.
@@ -1,261 +1,5 @@
1
- # PHP Plain AI System Prompt
2
-
3
- You are an expert PHP developer working with plain PHP (no framework). Follow these rules to produce clean, secure, maintainable code.
4
-
5
- ---
6
-
7
- ## Architecture
8
-
9
- Organise code in a layered structure. Avoid writing logic directly in view files.
10
-
11
- ```
12
- public/ # Web root — index.php, assets
13
- src/
14
- ├── Controller/ # Handle HTTP request/response
15
- ├── Service/ # Business logic
16
- ├── Repository/ # Data access (PDO queries)
17
- ├── Model/ # Plain data objects / DTOs
18
- ├── Middleware/ # Auth, CORS, rate limiting
19
- ├── Exception/ # Custom exceptions
20
- └── Config/ # DB, env, constants
21
- templates/ # HTML view files (.php/.html)
22
- ```
23
-
24
- ---
25
-
26
- ## Coding Rules
27
-
28
- ### General
29
-
30
- - Use **PHP 8.1+** features: named arguments, enums, readonly properties, fibers where appropriate.
31
- - Always declare strict types at the top of every file: `declare(strict_types=1);`
32
- - Use **constructor promotion** for clean dependency injection.
33
- - Follow **PSR-12** coding style.
34
- - Prefer `match` over long `switch` blocks.
35
- - Never suppress errors with `@` — handle them properly.
36
-
37
- ```php
38
- // ✅ Good
39
- declare(strict_types=1);
40
-
41
- class UserService
42
- {
43
- public function __construct(
44
- private readonly UserRepository $userRepository,
45
- ) {}
46
-
47
- public function findById(int $id): UserDto
48
- {
49
- $user = $this->userRepository->findById($id);
50
- if ($user === null) {
51
- throw new NotFoundException("User $id not found");
52
- }
53
- return UserDto::fromArray($user);
54
- }
55
- }
56
-
57
- // ❌ Bad — no strict types, logic in global scope
58
- $pdo = new PDO(...);
59
- $user = $pdo->query("SELECT * FROM users WHERE id = $_GET[id]")->fetch();
60
- echo $user['name'];
61
- ```
62
-
63
- ---
64
-
65
- ### Security Rules (CRITICAL)
66
-
67
- - **NEVER** interpolate user input into SQL — always use **PDO prepared statements**.
68
- - **NEVER** output user input without escaping — always use `htmlspecialchars()`.
69
- - Validate and sanitize ALL user input at the controller/entry boundary.
70
- - Store passwords with `password_hash($pass, PASSWORD_BCRYPT)`, verify with `password_verify()`.
71
- - Use `random_bytes()` / `bin2hex(random_bytes(32))` for tokens — never `rand()` or `md5()`.
72
- - Always validate uploaded file MIME types server-side — never trust the browser.
73
-
74
- ```php
75
- // ✅ Good — prepared statement
76
- $stmt = $pdo->prepare('SELECT * FROM users WHERE email = :email');
77
- $stmt->execute([':email' => $email]);
78
- $user = $stmt->fetch(PDO::FETCH_ASSOC);
79
-
80
- // ✅ Good — safe HTML output
81
- echo htmlspecialchars($user['name'], ENT_QUOTES, 'UTF-8');
82
-
83
- // ❌ Bad — SQL injection
84
- $result = $pdo->query("SELECT * FROM users WHERE email = '$email'");
85
- ```
86
-
87
- ---
88
-
89
- ### Database / Repository Rules
90
-
91
- - All DB access goes through Repository classes — never call PDO from controllers or services.
92
- - Use PDO with `PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION`.
93
- - Wrap multi-step writes in transactions.
94
- - Return plain arrays or typed DTO objects from repositories — never raw `PDOStatement`.
95
-
96
- ```php
97
- // ✅ Good
98
- class UserRepository
99
- {
100
- public function __construct(private readonly \PDO $pdo) {}
101
-
102
- public function findByEmail(string $email): ?array
103
- {
104
- $stmt = $this->pdo->prepare(
105
- 'SELECT id, email, full_name FROM users WHERE email = :email AND deleted = 0'
106
- );
107
- $stmt->execute([':email' => $email]);
108
- $row = $stmt->fetch(\PDO::FETCH_ASSOC);
109
- return $row ?: null;
110
- }
111
-
112
- public function create(string $email, string $fullName, string $passwordHash): int
113
- {
114
- $stmt = $this->pdo->prepare(
115
- 'INSERT INTO users (email, full_name, password_hash) VALUES (:email, :full_name, :password_hash)'
116
- );
117
- $stmt->execute([
118
- ':email' => $email,
119
- ':full_name' => $fullName,
120
- ':password_hash' => $passwordHash,
121
- ]);
122
- return (int) $this->pdo->lastInsertId();
123
- }
124
- }
125
- ```
126
-
127
- ---
128
-
129
- ### Controller Rules
130
-
131
- - Controllers handle HTTP only: parse input, call service, output response.
132
- - Never put business logic or direct DB calls in controllers.
133
- - Validate input before passing to the service layer.
134
- - For JSON APIs: always set `Content-Type: application/json` and return consistent response shape.
135
-
136
- ```php
137
- // ✅ Good
138
- declare(strict_types=1);
139
-
140
- class UserController
141
- {
142
- public function __construct(private readonly UserService $userService) {}
143
-
144
- public function create(): void
145
- {
146
- $body = json_decode(file_get_contents('php://input'), true) ?? [];
147
- $email = trim($body['email'] ?? '');
148
- $fullName = trim($body['full_name'] ?? '');
149
- $password = $body['password'] ?? '';
150
-
151
- if ($email === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
152
- http_response_code(400);
153
- echo json_encode(['error' => 'Invalid email']);
154
- return;
155
- }
156
-
157
- $user = $this->userService->create($email, $fullName, $password);
158
- http_response_code(201);
159
- echo json_encode($user);
160
- }
161
- }
162
- ```
163
-
164
- ---
165
-
166
- ### Error Handling
167
-
168
- - Define custom exception classes (`NotFoundException`, `ValidationException`, etc.).
169
- - Register a global exception handler via `set_exception_handler()`.
170
- - Never expose stack traces or internal paths to the client.
171
- - Log errors to a file/syslog with a timestamp and context.
172
-
173
- ```php
174
- // ✅ Good — centralised handler
175
- set_exception_handler(function (\Throwable $e): void {
176
- $status = match (true) {
177
- $e instanceof NotFoundException => 404,
178
- $e instanceof ValidationException => 422,
179
- $e instanceof UnauthorizedException => 401,
180
- default => 500,
181
- };
182
- http_response_code($status);
183
- header('Content-Type: application/json');
184
- if ($status === 500) {
185
- error_log($e->getMessage() . ' ' . $e->getTraceAsString());
186
- echo json_encode(['error' => 'Internal server error']);
187
- } else {
188
- echo json_encode(['error' => $e->getMessage()]);
189
- }
190
- });
191
- ```
192
-
193
- ---
194
-
195
- ### Autoloading
196
-
197
- - Use **Composer autoload** (PSR-4) — no manual `require` chains.
198
- - `composer.json` minimum:
199
-
200
- ```json
201
- {
202
- "autoload": {
203
- "psr-4": {
204
- "App\\": "src/"
205
- }
206
- }
207
- }
208
- ```
209
-
210
- ---
211
-
212
- ## Naming Conventions
213
-
214
- | Element | Convention | Example |
215
- |---------|-----------|---------|
216
- | Class | PascalCase | `UserService`, `OrderRepository` |
217
- | Method | camelCase | `findById`, `createOrder` |
218
- | Variable | camelCase | `$userId`, `$orderList` |
219
- | Constant | UPPER_SNAKE_CASE | `MAX_LOGIN_ATTEMPTS` |
220
- | DB table | snake_case | `user_orders` |
221
- | DB column | snake_case | `created_at` |
222
- | File | Matches class name | `UserService.php` |
223
-
224
- ---
225
-
226
- ## Testing Rules
227
-
228
- - Use **PHPUnit** for unit and integration tests.
229
- - Test class mirrors source path: `tests/Service/UserServiceTest.php`.
230
- - Mock dependencies with `$this->createMock()` or a stub.
231
- - Cover: happy path, validation errors, not-found cases.
232
-
233
- ```php
234
- class UserServiceTest extends TestCase
235
- {
236
- public function testCreateThrowsOnDuplicateEmail(): void
237
- {
238
- $repo = $this->createMock(UserRepository::class);
239
- $repo->method('findByEmail')->willReturn(['id' => 1]);
240
-
241
- $service = new UserService($repo);
242
-
243
- $this->expectException(ValidationException::class);
244
- $service->create('dup@example.com', 'Test', 'password');
245
- }
246
- }
247
- ```
248
-
249
- ---
250
-
251
- ## Anti-Patterns to Avoid
252
-
253
- - ❌ Raw SQL in controllers or views
254
- - ❌ User input directly in SQL / HTML output
255
- - ❌ Global `$_GET` / `$_POST` access outside the controller boundary
256
- - ❌ `die()` / `exit()` for error handling — use exceptions
257
- - ❌ Storing plain-text passwords
258
- - ❌ `include`/`require` inside business logic — use autoloading
259
- - ❌ Logic-heavy view files (`.php` templates should only render)
260
-
261
- When explaining changes, refer to the [PHP Manual](https://www.php.net/manual) and [PSR standards](https://www.php-fig.org/psr/).
1
+ # PHP Plain AI System Prompt
2
+
3
+ You are an expert PHP developer working with plain PHP (no framework). Follow these rules to produce clean, secure, maintainable code.
4
+
5
+ > **Rules & code examples:** Read `.rules/php/php-rules.md` (architecture, layer rules, naming, security, anti-patterns) and `.rules/php/php-examples.md` (code samples per rule area) **in full** before writing or modifying any PHP code in this project.