Spaces:
Sleeping
Sleeping
File size: 3,412 Bytes
5f4d28e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # AI Working Rules β PulseFabric Monitor
This document defines the rules and conventions that AI assistants (GitHub Copilot, agents, etc.) must follow when working on this project.
## Feature Implementation Order
All features must be implemented in this strict sequence:
1. **db.json** β Add or update data in `backend/db.json`
2. **Typed model** β Add or update the DTO interface in `frontend/src/app/core/models/api.models.ts`
3. **Service** β Add a method to `frontend/src/app/core/services/dashboard-api.service.ts`
4. **UI** β Build or extend the component, consuming data via the service
Never skip steps. Never put data fetching logic directly in a component.
## 20 Production Code Rules
| # | Rule | Summary |
|---|------|---------|
| 1 | Separation of Concerns | TS, HTML, SCSS in separate files |
| 2 | No Hardcoded Data | All data from API or mock files |
| 3 | Typed Interfaces | Every data structure has a TS interface; `any` is forbidden |
| 4 | Component-Driven | Reusable standalone Angular components |
| 5 | No Magic Numbers | Named constants, enums, or config objects only |
| 6 | CSS Token System | Use `--mat-sys-*`, `--pf-*`, or SCSS variables |
| 7 | Material 3 Compliance | Follow M3 guidelines for all UI |
| 8 | Concise Angular | Signals, `input()`, `inject()`, pipes, directives |
| 9 | No Over-Engineering | No unnecessary libraries or infrastructure |
| 10 | Reuse Before Creating | Audit existing code first |
| 11 | Generic Component Design | Input-driven; new instance = new inputs, not new file |
| 12 | Minimal Change Principle | >3 files changed β stop and explain |
| 13 | Flat HTML Structure | No unnecessary DOM wrappers |
| 14 | No console.log | Remove all logging before committing |
| 15 | No Dead Code | No commented-out blocks |
| 16 | Clean Imports | Every import must be used |
| 17 | Consistent Naming | kebab-case files, camelCase vars, PascalCase classes |
| 18 | Single Responsibility | One component/service/model group per file |
| 19 | No `any` (Reinforced) | Forbidden in all positions |
| 20 | SCSS Nesting β€ 3 Levels | Refactor into separate classes if exceeded |
## Governance Files
| File | Purpose |
|------|---------|
| `.github/copilot-instructions.md` | Full rule set loaded into every Copilot session |
| `.github/prompts/add-kpi-widget.prompt.md` | Step-by-step prompt for adding a KPI card |
| `.github/prompts/add-chart-widget.prompt.md` | Step-by-step prompt for adding a chart widget |
| `.github/prompts/add-new-component.prompt.md` | Step-by-step prompt for creating a new component |
| `.github/agents/network-dashboard-implementer.md` | Agent profile with planning, compliance, and stop behavior |
| `.github/skills/dashboard-widget.md` | Optional skill for widget scaffolding |
## Stop Conditions
The AI must stop and ask the user when:
- A task requires modifying more than 3 existing files
- A task conflicts with any of the 20 rules
- The data shape is ambiguous or incomplete
- It is unclear whether to create or reuse a component
## Validation Checklist
Before completing any task, verify:
- [ ] `ng build` passes from `frontend/`
- [ ] No `any` types introduced
- [ ] No `console.log` statements
- [ ] No dead or commented-out code
- [ ] All imports are used
- [ ] SCSS nesting β€ 3 levels
- [ ] CSS tokens used (no raw hex/px/rem)
- [ ] Implementation follows db.json β model β service β UI order
|