|
| 1 | +# AI Agent Instructions |
| 2 | + |
| 3 | +Coding guidelines for AI agents working in this project. |
| 4 | + |
| 5 | +## Philosophy |
| 6 | + |
| 7 | +- Minimalism. Simple is better. KISS (Keep It Simple, Stupid). |
| 8 | +- Clean code, easy to read, easy to delete. |
| 9 | +- Functional Programming — pure functions, immutability, no side effects. |
| 10 | +- MVP mindset — deliver the smallest thing that works, then iterate. |
| 11 | + |
| 12 | +## Security Rules (CRITICAL — no exceptions) |
| 13 | + |
| 14 | +- NEVER output or request .env and example.env file contents |
| 15 | +- NEVER hardcode API credentials, secret tokens, private keys or passwords in source code |
| 16 | +- NEVER send sensitive data to external AI services |
| 17 | +- Follow `.aiignore` and `.gitignore` for excluded files — do not read or reference them |
| 18 | +- When asking for help, sanitize data (replace real IDs, emails, tokens with placeholders) |
| 19 | +- Do not log sensitive information |
| 20 | + |
| 21 | +## Coding Standards (Strict) |
| 22 | +- Language: JavaScript (ESM syntax). No TypeScript. |
| 23 | +- Style: No semicolons, single quotes, 2-space indentation. |
| 24 | +- Respect `eslint.config.js` — do not suggest rule changes |
| 25 | +- Patterns: |
| 26 | + - Functional Programming only. No Classes or OOP. |
| 27 | + - Arrow functions are preferred. |
| 28 | + - Maximum 3 parameters per function. Use objects for more. |
| 29 | +- Naming: camelCase for variables/functions, SNAKE_CASE for constants. |
| 30 | +- Documentation: |
| 31 | + - Add JSDocs before all functions and exported variables. |
| 32 | + - Language: Use American English for all comments and JSDocs. |
| 33 | + - Constraint: NEVER use Vietnamese or other languages in the source code. |
| 34 | + |
| 35 | +### Error Handling |
| 36 | + |
| 37 | +- Handle errors explicitly — never swallow silently |
| 38 | +- Use try/catch with proper logging |
| 39 | +- Return null or throw meaningful errors |
| 40 | + |
| 41 | +```javascript |
| 42 | +export const send = async (params) => { |
| 43 | + try { |
| 44 | + const response = await ai.ask(params) |
| 45 | + logger.info(`send() -> success: ${response.id}`) |
| 46 | + return response |
| 47 | + } catch (err) { |
| 48 | + logger.error(`send() -> failed: ${err.message}`) |
| 49 | + console.error(err) |
| 50 | + return null |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +## Testing Standards |
| 56 | + |
| 57 | +- Write tests for critical business logic, all error cases |
| 58 | +- Use simple test runners (node:test, bun:test, vitest) |
| 59 | +- No complex mocking frameworks unless necessary |
| 60 | +- Tests live alongside source: `[module].test.js` next to `[module].js` |
| 61 | + |
| 62 | +## Dependency Rules |
| 63 | + |
| 64 | +- Prefer built-in APIs over external packages |
| 65 | +- Before adding dependency, explain: |
| 66 | + - Why it is needed |
| 67 | + - Alternatives considered |
| 68 | + - Bundle size impact |
| 69 | +- Never add dependency for trivial utilities |
| 70 | +- Avoid packages with large dependency trees |
| 71 | + |
| 72 | +## Architecture Rules |
| 73 | + |
| 74 | +- Do NOT change existing project architecture without explicit approval |
| 75 | +- Do NOT move or rename core modules unless requested |
| 76 | +- Respect module boundaries |
| 77 | +- Avoid cross-module coupling |
| 78 | +- New modules must follow existing folder structure |
| 79 | + |
| 80 | +## When Making Changes |
| 81 | + |
| 82 | +1. Read existing patterns first |
| 83 | +2. Follow current coding style strictly |
| 84 | +3. Keep dependencies minimal |
| 85 | +4. Handle errors explicitly |
| 86 | +5. Add JSDoc comments for new functions |
| 87 | +6. Run `npm run lint` before committing |
| 88 | +7. Do NOT refactor unrelated code |
| 89 | +8. Do NOT modify working code outside task scope |
| 90 | +9. Prefer minimal diff changes |
| 91 | +10. Preserve existing behavior unless explicitly requested |
| 92 | + |
| 93 | +## When in Doubt |
| 94 | + |
| 95 | +- Ask for clarification before generating code |
| 96 | +- State your assumption explicitly if proceeding without confirmation |
| 97 | +- Prefer doing less and asking over doing more and guessing |
| 98 | + |
| 99 | +## Git Workflow |
| 100 | + |
| 101 | +- Work only inside the current branch |
| 102 | +- Do NOT create or delete branches |
| 103 | +- Do NOT rewrite git history |
| 104 | +- Do NOT modify commit messages |
| 105 | +- Changes must correspond to the current issue |
| 106 | + |
| 107 | +## Agent References |
| 108 | + |
| 109 | +Reference these URLs when working on related topics: |
| 110 | + |
| 111 | +- Bun: https://bun.sh/llms-full.txt |
| 112 | + |
| 113 | +--- |
0 commit comments