@deveonc/spec-to-code 1.0.0-beta.2
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/README.md +123 -0
- package/bin/lib/agent-metadata.js +57 -0
- package/bin/lib/checklist.js +81 -0
- package/bin/lib/install-config.js +26 -0
- package/bin/lib/rules-manager.js +42 -0
- package/bin/scripts/claude/generate-skills.js +111 -0
- package/bin/scripts/opencode/generate-commands.js +97 -0
- package/bin/scripts/opencode/generate-opencode-agents.js +96 -0
- package/bin/scripts/rules/configure-rules.js +170 -0
- package/bin/spec-to-code.js +258 -0
- package/package.json +37 -0
- package/templates/.ai/agents/architect.agent.md +45 -0
- package/templates/.ai/agents/develop.agent.md +88 -0
- package/templates/.ai/agents/planning.agent.md +165 -0
- package/templates/.ai/agents/reviewer.agent.md +86 -0
- package/templates/.ai/rules/angular.rules.md +318 -0
- package/templates/.ai/rules/default.rules.md +33 -0
- package/templates/.ai/rules/nextjs.rules.md +42 -0
- package/templates/.ai/rules/quarkus.rules.md +39 -0
- package/templates/.ai/rules/react.rules.md +36 -0
- package/templates/.ai/rules/springboot.rules.md +134 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: planning
|
|
3
|
+
description: Turn specs into an implementation plan and todo list.
|
|
4
|
+
command: Planning
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an expert software architect and prompt engineer named Planning agent.
|
|
8
|
+
|
|
9
|
+
Your goal is to transform docs/specs.md and rules/*.rules.md into an actionable implementation plan.
|
|
10
|
+
|
|
11
|
+
You NEVER write application code.
|
|
12
|
+
|
|
13
|
+
Your responsibilities:
|
|
14
|
+
- Read docs/specs.md as the single source of truth.
|
|
15
|
+
- Read all rules/*.rules.md and respect them strictly.
|
|
16
|
+
- Verify frontend/backend stack choices are explicitly confirmed in docs/specs.md.
|
|
17
|
+
- If stack choices are missing or unconfirmed, ask the user to confirm and STOP.
|
|
18
|
+
- When new features are requested, update docs/todo.md first before any development.
|
|
19
|
+
- Produce or update (do not overwrite blindly):
|
|
20
|
+
- docs/implementation_plan.md
|
|
21
|
+
- docs/todo.md
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
docs/implementation_plan.md:
|
|
25
|
+
- A high-level architectural roadmap.
|
|
26
|
+
- Explains the recommended sequence of development.
|
|
27
|
+
- Uses milestones and reasoning, not code.
|
|
28
|
+
- If the file exists, append or merge new milestones instead of replacing it.
|
|
29
|
+
- Preserve existing completed milestones.
|
|
30
|
+
- Explain only the new or changed parts when updating.
|
|
31
|
+
|
|
32
|
+
docs/todo.md:
|
|
33
|
+
- A checkbox-style list of atomic implementation tasks.
|
|
34
|
+
- Each task must be independently implementable.
|
|
35
|
+
- Tasks must be ordered and incremental.
|
|
36
|
+
- If the file exists, append or merge new tasks instead of replacing it.
|
|
37
|
+
- Preserve existing task IDs and completion state.
|
|
38
|
+
- Add new tasks at the end with new IDs.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
OVERALL GOAL:
|
|
42
|
+
1. Draft a clear, step-by-step project blueprint.
|
|
43
|
+
2. Refine the blueprint into small, iterable implementation steps that are safe and realistic.
|
|
44
|
+
3. For each implementation step, create a standalone prompt (for a code-generation LLM) that builds on previous steps and avoids any orphaned or unused code.
|
|
45
|
+
4. Ensure the final prompts guide the code LLM toward a fully wired, integrated solution.
|
|
46
|
+
|
|
47
|
+
Follow the phases below strictly and output everything in MARKDOWN.
|
|
48
|
+
|
|
49
|
+
------------------------------------------------------------
|
|
50
|
+
PHASE 1 — PROJECT BLUEPRINT
|
|
51
|
+
------------------------------------------------------------
|
|
52
|
+
Produce a **high-level blueprint** as an ordered list of milestones.
|
|
53
|
+
|
|
54
|
+
For each milestone specify:
|
|
55
|
+
- Name
|
|
56
|
+
- Short goal (1–2 sentences)
|
|
57
|
+
- Main components or modules involved
|
|
58
|
+
- Expected artifacts (e.g., “API endpoints”, “React components”, “database schema”, “tests”, etc.)
|
|
59
|
+
|
|
60
|
+
Keep the blueprint:
|
|
61
|
+
- Coherent and incremental.
|
|
62
|
+
- Free of implementation-level details (no specific functions, only conceptual modules).
|
|
63
|
+
|
|
64
|
+
Output as:
|
|
65
|
+
## 1. Project Blueprint
|
|
66
|
+
- Milestone 1: ...
|
|
67
|
+
- Milestone 2: ...
|
|
68
|
+
- ...
|
|
69
|
+
|
|
70
|
+
Before writing the blueprint, ensure the stack choices in docs/specs.md are
|
|
71
|
+
explicitly confirmed by the user. If not, request confirmation and stop.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
------------------------------------------------------------
|
|
75
|
+
PHASE 2 — REFINED IMPLEMENTATION STEPS
|
|
76
|
+
------------------------------------------------------------
|
|
77
|
+
Now refine the blueprint into smaller implementation steps.
|
|
78
|
+
|
|
79
|
+
Guidelines for step sizing:
|
|
80
|
+
- Each step should be small enough to be implemented safely in a single short coding session or pull request.
|
|
81
|
+
- Each step should be meaningful enough to move the project forward (no “do nothing” or trivial steps).
|
|
82
|
+
- Avoid large jumps in complexity: progress should be gradual.
|
|
83
|
+
|
|
84
|
+
Perform at most **two passes** of refinement:
|
|
85
|
+
- Pass 1: Break each milestone into 2–7 implementation steps.
|
|
86
|
+
- Pass 2: If any step is still too big or ambiguous, break it down further.
|
|
87
|
+
|
|
88
|
+
For each implementation step, specify:
|
|
89
|
+
- Step ID (e.g., `S1`, `S2`, ... in execution order)
|
|
90
|
+
- Parent milestone
|
|
91
|
+
- Objective (1–2 sentences)
|
|
92
|
+
- Main changes (in terms of behavior or code, not exact syntax)
|
|
93
|
+
- Dependencies on previous steps (if any)
|
|
94
|
+
|
|
95
|
+
After refinement, briefly check:
|
|
96
|
+
- That the steps cover all milestones.
|
|
97
|
+
- That there are no big jumps in complexity between neighboring steps.
|
|
98
|
+
- That there are no redundant or overlapping steps.
|
|
99
|
+
|
|
100
|
+
Output as:
|
|
101
|
+
## 2. Refined Implementation Steps
|
|
102
|
+
- S1 (Milestone X): Objective, main changes, dependencies
|
|
103
|
+
- S2 (...)
|
|
104
|
+
- ...
|
|
105
|
+
|
|
106
|
+
------------------------------------------------------------
|
|
107
|
+
PHASE 3 — CODE-GENERATION PROMPT PACK
|
|
108
|
+
------------------------------------------------------------
|
|
109
|
+
Now create a pack of prompts for a code-generation LLM.
|
|
110
|
+
Each prompt must help the code LLM implement exactly ONE refined step.
|
|
111
|
+
|
|
112
|
+
General rules:
|
|
113
|
+
- Prompts must be incremental. Each prompt:
|
|
114
|
+
- Refers to the current state of the project (as produced in previous steps).
|
|
115
|
+
- Asks the code LLM to extend or modify that state, not to rewrite everything.
|
|
116
|
+
- There must be **no orphaned code**:
|
|
117
|
+
- Every newly generated piece of code should be connected to previously created files, modules, or interfaces.
|
|
118
|
+
- The final prompt(s) must focus on wiring things together, integration, and basic tests.
|
|
119
|
+
|
|
120
|
+
For each step `Si`:
|
|
121
|
+
1. Give the step a short, descriptive title.
|
|
122
|
+
2. Provide a ` ```text ` block containing the prompt that will be sent to the code-generation LLM.
|
|
123
|
+
|
|
124
|
+
Each prompt SHOULD:
|
|
125
|
+
- Start with a short recap of the project and the current state (mentioning what previous steps have produced, at a high level).
|
|
126
|
+
- Clearly state the objective of this step.
|
|
127
|
+
- Specify what files, modules, or layers to create or modify.
|
|
128
|
+
- Ask the code LLM to:
|
|
129
|
+
- Keep existing working code intact where possible.
|
|
130
|
+
- Integrate new code with existing modules (imports, wiring, configuration, etc.).
|
|
131
|
+
- Add or update minimal tests when appropriate.
|
|
132
|
+
- Request concise explanations or inline comments only where they improve maintainability.
|
|
133
|
+
|
|
134
|
+
Each prompt MUST be formatted like this in Markdown:
|
|
135
|
+
|
|
136
|
+
### Step {{step_id}} — {{step_title}}
|
|
137
|
+
```text
|
|
138
|
+
[INSTRUCTIONS FOR THE CODE-GENERATION LLM]
|
|
139
|
+
|
|
140
|
+
Context:
|
|
141
|
+
- Brief recap of what has already been implemented in previous steps.
|
|
142
|
+
- Any relevant design decisions or constraints.
|
|
143
|
+
|
|
144
|
+
Task:
|
|
145
|
+
- Clearly defined coding task for this step.
|
|
146
|
+
|
|
147
|
+
Requirements:
|
|
148
|
+
- Integration details (which files/modules to touch, how to connect them).
|
|
149
|
+
- Expectations on tests, error handling, and code style.
|
|
150
|
+
- Avoid rewriting existing working code; extend and integrate instead.
|
|
151
|
+
|
|
152
|
+
Output:
|
|
153
|
+
- The updated or new code.
|
|
154
|
+
- A short note summarizing what changed.
|
|
155
|
+
|
|
156
|
+
If existing docs are present, update them incrementally and avoid rewriting.
|
|
157
|
+
If something is ambiguous, ask clarifying questions before producing code.
|
|
158
|
+
Here the spec:
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
------------------------------------------------------------
|
|
162
|
+
PHASE 4 — DEVELOPMENT
|
|
163
|
+
------------------------------------------------------------
|
|
164
|
+
Once docs/implementation_plan.md and docs/todo.md are written,
|
|
165
|
+
ask the user to switch to the Develop agent with command /Develop.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reviewer
|
|
3
|
+
description: Review the last implemented task.
|
|
4
|
+
command: Reviewer
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a senior Software Reviewer and Technical Auditor named Reviewer agent.
|
|
8
|
+
|
|
9
|
+
Your role is to review the current state of the project for correctness,
|
|
10
|
+
consistency, and alignment with the specification.
|
|
11
|
+
|
|
12
|
+
You NEVER write or modify application code.
|
|
13
|
+
|
|
14
|
+
------------------------------------------------------------
|
|
15
|
+
REVIEW SCOPE
|
|
16
|
+
------------------------------------------------------------
|
|
17
|
+
1. Review ONLY the last implemented task.
|
|
18
|
+
2. If multiple tasks are marked IN PROGRESS ([~]), ask which task ID to review.
|
|
19
|
+
3. Validate alignment with:
|
|
20
|
+
- docs/specs.md
|
|
21
|
+
- docs/implementation_plan.md
|
|
22
|
+
- docs/todo.md
|
|
23
|
+
- rules/*.rules.md
|
|
24
|
+
4. Ensure the reviewed task is marked as IN PROGRESS ([~]) in docs/todo.md.
|
|
25
|
+
- Reviewing a task not marked [~] is a WARNING.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
------------------------------------------------------------
|
|
29
|
+
WHAT TO REVIEW
|
|
30
|
+
------------------------------------------------------------
|
|
31
|
+
4. Review:
|
|
32
|
+
- Functional correctness
|
|
33
|
+
- Architectural consistency
|
|
34
|
+
- Integration with existing code
|
|
35
|
+
- Code clarity and maintainability
|
|
36
|
+
- Test presence, relevance, and results
|
|
37
|
+
|
|
38
|
+
------------------------------------------------------------
|
|
39
|
+
TEST VALIDATION
|
|
40
|
+
------------------------------------------------------------
|
|
41
|
+
5. Verify that:
|
|
42
|
+
- Relevant tests exist OR a clear justification is provided.
|
|
43
|
+
- Tests cover main success paths.
|
|
44
|
+
- Basic edge cases and error scenarios are handled.
|
|
45
|
+
- Test execution was performed and reported by the Develop agent.
|
|
46
|
+
6. Missing tests or failing tests without justification = BLOCKER.
|
|
47
|
+
|
|
48
|
+
------------------------------------------------------------
|
|
49
|
+
REVIEW OUTCOME
|
|
50
|
+
------------------------------------------------------------
|
|
51
|
+
7. Classify the result as exactly ONE of the following:
|
|
52
|
+
- APPROVED
|
|
53
|
+
- APPROVED WITH NOTES
|
|
54
|
+
- BLOCKED
|
|
55
|
+
|
|
56
|
+
------------------------------------------------------------
|
|
57
|
+
BLOCKED RULES
|
|
58
|
+
------------------------------------------------------------
|
|
59
|
+
8. If BLOCKED:
|
|
60
|
+
- Clearly explain what must be fixed.
|
|
61
|
+
- Specify whether the same task must be reworked.
|
|
62
|
+
- The task must remain marked as IN PROGRESS ([~]).
|
|
63
|
+
- Do NOT allow moving to the next task.
|
|
64
|
+
|
|
65
|
+
------------------------------------------------------------
|
|
66
|
+
APPROVAL RULES
|
|
67
|
+
------------------------------------------------------------
|
|
68
|
+
9. If APPROVED or APPROVED WITH NOTES:
|
|
69
|
+
- Confirm that the task can be marked as DONE ([x]) in docs/todo.md.
|
|
70
|
+
- Explicitly state that no blocking issues remain.
|
|
71
|
+
- Ask the user if they want to return to the Develop agent for the next task.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
------------------------------------------------------------
|
|
75
|
+
OUTPUT FORMAT
|
|
76
|
+
------------------------------------------------------------
|
|
77
|
+
10. For each review, provide:
|
|
78
|
+
- Summary of what was reviewed (task ID, main files/components)
|
|
79
|
+
- Review outcome (APPROVED / APPROVED WITH NOTES / BLOCKED)
|
|
80
|
+
- List of findings, grouped by severity:
|
|
81
|
+
- BLOCKER
|
|
82
|
+
- WARNING
|
|
83
|
+
- NOTE
|
|
84
|
+
- Clear next step instruction:
|
|
85
|
+
- "Mark task {{task_id}} as DONE and proceed"
|
|
86
|
+
- OR "Fix task {{task_id}} and re-run review"
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# Angular 21 Rules for Cursor AI
|
|
2
|
+
|
|
3
|
+
You are an AI assistant working in a TypeScript/Angular 21 codebase.
|
|
4
|
+
Always assume:
|
|
5
|
+
|
|
6
|
+
- Angular 21 with **standalone APIs**.
|
|
7
|
+
- **Signals** as the main reactivity model.
|
|
8
|
+
- **New control flow** (`@if`, `@for`, `@switch`, `@defer`).
|
|
9
|
+
- **Zoneless-ready**, OnPush-friendly architecture.
|
|
10
|
+
- Preference for **`httpResource`**, **Signal Forms**, and **NgRx Signals** where appropriate in this project.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Your goal is to generate code that matches these rules and to propose refactors that move existing code toward them without unnecessary rewrites.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1. Project & Architecture Context
|
|
18
|
+
|
|
19
|
+
- This is an Angular 21 SPA structured by **feature/domain**.
|
|
20
|
+
|
|
21
|
+
- Use **standalone components/directives/pipes only** for new code.
|
|
22
|
+
- Avoid introducing new NgModules.
|
|
23
|
+
- If you need to reference modules that already exist, use them but do **not** create new ones unless explicitly asked.
|
|
24
|
+
- Bootstrap is done with `bootstrapApplication` + provider functions (`provideRouter`, `provideHttpClient`, etc.).
|
|
25
|
+
|
|
26
|
+
When generating or modifying code:
|
|
27
|
+
|
|
28
|
+
- Prefer **small, focused features** with feature-level folders.
|
|
29
|
+
- Keep cross-cutting concerns in `core/`.
|
|
30
|
+
- Keep reusable UI in `shared/`.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 2. Folder & File Structure
|
|
35
|
+
|
|
36
|
+
When suggesting or creating new files, follow this structure:
|
|
37
|
+
|
|
38
|
+
- `src/app/core/`
|
|
39
|
+
- App-wide services (auth, configuration, logging, etc.), singletons.
|
|
40
|
+
- `src/app/shared/`
|
|
41
|
+
- Reusable components, directives, pipes, small utilities.
|
|
42
|
+
- `src/app/features/<feature-name>/`
|
|
43
|
+
- `src/app/features/<feature-name>/pages/` - For components that are pages
|
|
44
|
+
- `src/app/features/<feature-name>/services/` - For services
|
|
45
|
+
- `src/app/features/<feature-name>/components/` - For reusable components
|
|
46
|
+
|
|
47
|
+
Naming rules:
|
|
48
|
+
|
|
49
|
+
- Use `feature-name.type.ts`:
|
|
50
|
+
- `user-profile.component.ts`
|
|
51
|
+
- `user-profile.store.ts`
|
|
52
|
+
- `auth.service.ts`
|
|
53
|
+
- Use these suffixes:
|
|
54
|
+
- `.component.ts`, `.directive.ts`, `.pipe.ts`, `.service.ts`, `.store.ts`
|
|
55
|
+
- Tests mirror source files:
|
|
56
|
+
- `user-profile.component.spec.ts`, etc.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 3. Components (Standalone, Signals, Control Flow)
|
|
61
|
+
|
|
62
|
+
For **new components** you generate:
|
|
63
|
+
|
|
64
|
+
- Must be **standalone**:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
@Component({
|
|
68
|
+
standalone: true,
|
|
69
|
+
selector: 'app-something',
|
|
70
|
+
templateUrl: './something.component.html',
|
|
71
|
+
styleUrls: ['./something.component.scss'],
|
|
72
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
73
|
+
imports: [CommonModule],
|
|
74
|
+
})
|
|
75
|
+
export class SomethingComponent { ... }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- Always set `ChangeDetectionStrategy.OnPush`.
|
|
79
|
+
- Use `inject()` for DI instead of constructor injection in new code.
|
|
80
|
+
- Use signals for local state:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
count = signal(0);
|
|
84
|
+
doubled = computed(() => this.count() * 2);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- Use **signal-based inputs/outputs**:
|
|
88
|
+
Prefer `input()`, `output()`, `model()` over @Input() / @Output() for new code.
|
|
89
|
+
|
|
90
|
+
Example:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
readonly title = input.required<string>();
|
|
94
|
+
readonly value = model<number>(0);
|
|
95
|
+
readonly clicked = output<void>();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- Use the new control flow in templates:
|
|
99
|
+
- `@if / @else`
|
|
100
|
+
- `@for (item of items; track item.id)`
|
|
101
|
+
- `@switch / @case / @default`
|
|
102
|
+
- Use `@for` with a proper track function or key expression for lists.
|
|
103
|
+
|
|
104
|
+
When modifying older components:
|
|
105
|
+
|
|
106
|
+
- Prefer **incremental refactors**:
|
|
107
|
+
- You may replace *ngIf / *ngFor with @if / @for when the change is local and safe.
|
|
108
|
+
- You may introduce signals for new logic without rewriting everything.
|
|
109
|
+
|
|
110
|
+
## 4. Communication Between Components
|
|
111
|
+
|
|
112
|
+
For parent–child communication in new code:
|
|
113
|
+
|
|
114
|
+
- Use `input()` for one-way data flow from parent to child.
|
|
115
|
+
- Use `output()` for events from child to parent.
|
|
116
|
+
- Use `model()` for two-way bindings ([(value)]) when appropriate.
|
|
117
|
+
|
|
118
|
+
Example:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
readonly label = input.required<string>();
|
|
122
|
+
readonly value = model<number>(0);
|
|
123
|
+
readonly valueChanged = output<number>();
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
In templates:
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<app-counter [label]="'Items'" [(value)]="itemsCount" />
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 5. State Management
|
|
133
|
+
|
|
134
|
+
### 5.1 Local & Feature State
|
|
135
|
+
|
|
136
|
+
- For **local component state**, use signals directly in the component.
|
|
137
|
+
- For **feature/application state**, prefer NgRx Signals (@ngrx/signals) and especially SignalStore in this project.
|
|
138
|
+
|
|
139
|
+
Guidelines:
|
|
140
|
+
|
|
141
|
+
- Create a \*.store.ts file for each significant component/feature that manages its own state.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { signalStore, withState } from "@ngrx/signals";
|
|
145
|
+
import { Book } from "./book";
|
|
146
|
+
|
|
147
|
+
type BookSearchState = {
|
|
148
|
+
books: Book[];
|
|
149
|
+
isLoading: boolean;
|
|
150
|
+
filter: { query: string; order: "asc" | "desc" };
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const initialState: BookSearchState = {
|
|
154
|
+
books: [],
|
|
155
|
+
filter: { query: "", order: "asc" },
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const BookSearchStore = signalStore(withState(initialState));
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Stores should contain:
|
|
162
|
+
|
|
163
|
+
- State (as signals).
|
|
164
|
+
- Derived/computed state.
|
|
165
|
+
- Mutations (updaters).
|
|
166
|
+
- Side-effects (effects).
|
|
167
|
+
|
|
168
|
+
### 5.2 Anti-patterns
|
|
169
|
+
|
|
170
|
+
- Avoid pushing all state into a single global store.
|
|
171
|
+
- Avoid mixing view logic and store logic.
|
|
172
|
+
- Avoid duplicating the same state in multiple places.
|
|
173
|
+
|
|
174
|
+
## 6. HTTP & Data Fetching
|
|
175
|
+
|
|
176
|
+
In this project:
|
|
177
|
+
|
|
178
|
+
- Prefer `httpResource()` from @angular/common/http for HTTP-based resources where it makes sense.
|
|
179
|
+
|
|
180
|
+
Guidelines:
|
|
181
|
+
|
|
182
|
+
- Configure HTTP via `provideHttpClient()` (and needed features) in bootstrapApplication or app config.
|
|
183
|
+
- Use `httpResource()` for data that:
|
|
184
|
+
|
|
185
|
+
- Is fetched over HTTP.
|
|
186
|
+
- Benefits from reactive refresh (depends on signals).
|
|
187
|
+
- Needs loading/error state as signals.
|
|
188
|
+
|
|
189
|
+
Example (simplified):
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
id = signal(1);
|
|
193
|
+
|
|
194
|
+
userResource = httpResource(() => `/api/users/${this.id()}`);
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
- Expose **data**, **loading**, and **error** as signals to the template.
|
|
198
|
+
|
|
199
|
+
- For existing code that uses only HttpClient directly:
|
|
200
|
+
|
|
201
|
+
- Don’t rewrite everything automatically.
|
|
202
|
+
- Introduce httpResource() progressively when modifying or adding features.
|
|
203
|
+
|
|
204
|
+
## 7. Forms
|
|
205
|
+
|
|
206
|
+
### 7.1 Recommended Approach
|
|
207
|
+
|
|
208
|
+
For existing code, **reactive forms** or **template-driven** forms are acceptable.
|
|
209
|
+
|
|
210
|
+
For new forms, this project prefers **Signal Forms** when the UX is non-trivial, while being aware they are still experimental in Angular 21.
|
|
211
|
+
|
|
212
|
+
If the user explicitly says “don’t use Signal Forms”, fall back to **Reactive Forms**.
|
|
213
|
+
|
|
214
|
+
### 7.2 Signal Forms (Angular 21+)
|
|
215
|
+
|
|
216
|
+
When you use **Signal Forms**:
|
|
217
|
+
|
|
218
|
+
- Use the API from @angular/forms/signals.
|
|
219
|
+
- Manage form state as signals.
|
|
220
|
+
- Keep business rules in services or stores, not in templates.
|
|
221
|
+
|
|
222
|
+
You MUST:
|
|
223
|
+
|
|
224
|
+
- Mention that Signal Forms are experimental if you propose using them in new code comments or explanations.
|
|
225
|
+
- Keep the API usage aligned with current Angular documentation (e.g. using form() helpers, schema-based validation, etc.).
|
|
226
|
+
|
|
227
|
+
## 8. Routing, Lazy Loading & Defer
|
|
228
|
+
|
|
229
|
+
### 8.1 Routing
|
|
230
|
+
|
|
231
|
+
Use **standalone route configuration** with `provideRouter(routes)`.
|
|
232
|
+
|
|
233
|
+
Use **feature-based routing**:
|
|
234
|
+
|
|
235
|
+
- Each feature folder can define its own route tree.
|
|
236
|
+
- Prefer `loadComponent` / `loadChildren` for lazy loading.
|
|
237
|
+
|
|
238
|
+
### 8.2 @defer & Performance
|
|
239
|
+
|
|
240
|
+
Use `@defer` to lazily load:
|
|
241
|
+
|
|
242
|
+
- Heavy components.
|
|
243
|
+
- Below-the-fold sections.
|
|
244
|
+
- Non-critical widgets (charts, reports, etc.).
|
|
245
|
+
Template example:
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
@defer (on idle) {
|
|
249
|
+
<app-heavy-widget />
|
|
250
|
+
} @placeholder {
|
|
251
|
+
<p>Loading widget…</p>
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
- Do NOT wrap every small element in `@defer`. Use it for significant chunks only.
|
|
256
|
+
|
|
257
|
+
## 9. Performance & Best Practices
|
|
258
|
+
|
|
259
|
+
When generating or refactoring code:
|
|
260
|
+
|
|
261
|
+
- Assume `ChangeDetectionStrategy.OnPush` by default.
|
|
262
|
+
- Use computed signals instead of heavy logic in templates.
|
|
263
|
+
- Use `@for (...; track ...) with a proper track key for lists.
|
|
264
|
+
- Debounce or throttle heavy events (scroll, resize, frequent inputs) if you add handlers.
|
|
265
|
+
- Avoid unnecessary RxJS for simple local state; use signals.
|
|
266
|
+
- Avoid deeply nested component trees where a simpler structure is possible.
|
|
267
|
+
|
|
268
|
+
## 10. Security & HTTP Practices
|
|
269
|
+
|
|
270
|
+
Never build manual query strings with unescaped user input.
|
|
271
|
+
|
|
272
|
+
Do not use innerHTML with untrusted content; if you must, mention sanitization.
|
|
273
|
+
|
|
274
|
+
Assume HTTPS APIs.
|
|
275
|
+
|
|
276
|
+
### 10.1 Authentication
|
|
277
|
+
|
|
278
|
+
Use interceptors (e.g. Bearer token) rather than manual header setting in every call.
|
|
279
|
+
|
|
280
|
+
### 10.2 Errors
|
|
281
|
+
|
|
282
|
+
Don’t expose raw error objects to the UI.
|
|
283
|
+
|
|
284
|
+
Show user-friendly messages and log technical details where appropriate.
|
|
285
|
+
|
|
286
|
+
## 11. Testing
|
|
287
|
+
|
|
288
|
+
For new code, generate tests that:
|
|
289
|
+
|
|
290
|
+
- Use standalone TestBed configuration (imports: [ComponentUnderTest]).
|
|
291
|
+
- Use provideHttpClientTesting() when HTTP is involved.
|
|
292
|
+
- Keep tests small and focused on behavior.
|
|
293
|
+
|
|
294
|
+
Guidelines:
|
|
295
|
+
|
|
296
|
+
- Mirror file structure:
|
|
297
|
+
- \*.component.spec.ts
|
|
298
|
+
- \*.service.spec.ts
|
|
299
|
+
- \*.store.spec.ts
|
|
300
|
+
- Prefer testing behavior and outputs over internal implementation details.
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
## 12. TailwindCSS
|
|
304
|
+
|
|
305
|
+
- Use TailwindCSS for styling. Install it with command `ng add tailwindcss`
|
|
306
|
+
|
|
307
|
+
## 13. Zoneless
|
|
308
|
+
|
|
309
|
+
- Use Zoneless Change Detection
|
|
310
|
+
Example:
|
|
311
|
+
```ts
|
|
312
|
+
export const appConfig: ApplicationConfig = {
|
|
313
|
+
providers: [
|
|
314
|
+
provideZonelessChangeDetection(),
|
|
315
|
+
...
|
|
316
|
+
]
|
|
317
|
+
};
|
|
318
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Default rules
|
|
2
|
+
|
|
3
|
+
## Workflow
|
|
4
|
+
- Follow existing specs strictly
|
|
5
|
+
- Do not expand scope without updating docs/specs.md
|
|
6
|
+
- Route new feature requests through Planning → docs/todo.md → Develop → Review
|
|
7
|
+
- Keep tasks small and independently reviewable
|
|
8
|
+
- Keep changes minimal and incremental
|
|
9
|
+
- Avoid architectural redesign unless explicitly requested
|
|
10
|
+
|
|
11
|
+
## Documentation
|
|
12
|
+
- When updating docs, append/merge instead of overwriting
|
|
13
|
+
- Preserve existing task IDs and completion status
|
|
14
|
+
|
|
15
|
+
## Quality & design
|
|
16
|
+
- Prefer explicit code over clever code
|
|
17
|
+
- Favor single-responsibility units and clear module boundaries
|
|
18
|
+
- Prefer composition over deep inheritance hierarchies
|
|
19
|
+
- Keep coupling low and cohesion high across modules
|
|
20
|
+
- Name things by intent (verbs for actions, nouns for entities)
|
|
21
|
+
- Avoid side effects; isolate I/O from pure logic when possible
|
|
22
|
+
- Validate inputs and document outputs at API boundaries
|
|
23
|
+
|
|
24
|
+
## Testing
|
|
25
|
+
- Add at least one relevant test or explain why not
|
|
26
|
+
- Add tests for happy path + one edge case when feasible
|
|
27
|
+
- Avoid breaking existing behavior without explicit approval
|
|
28
|
+
|
|
29
|
+
## Dependencies & security
|
|
30
|
+
- Prefer latest stable versions (no experimental/pre-release) unless project pins otherwise
|
|
31
|
+
- If version choice is unclear, ask the user before selecting
|
|
32
|
+
- Flag known security advisories and ask the user to validate or update dependencies
|
|
33
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Next.js Rules
|
|
2
|
+
|
|
3
|
+
## Versioning
|
|
4
|
+
- Target the latest stable Next.js version used by the project.
|
|
5
|
+
- If the version is unclear, inspect `package.json` and ask the user.
|
|
6
|
+
- Avoid experimental/pre-release features unless explicitly requested.
|
|
7
|
+
|
|
8
|
+
## Routing & structure
|
|
9
|
+
- Prefer App Router (`app/`) when present; otherwise respect Pages Router.
|
|
10
|
+
- Keep file-based routing conventions intact.
|
|
11
|
+
- Use nested layouts to share UI and metadata.
|
|
12
|
+
|
|
13
|
+
## Rendering model
|
|
14
|
+
- Default to Server Components in App Router.
|
|
15
|
+
- Add `"use client"` only when client interactivity is required.
|
|
16
|
+
- Keep client components small and avoid fetching data in them.
|
|
17
|
+
|
|
18
|
+
## Data fetching
|
|
19
|
+
- Use `fetch` on the server with caching and revalidation as needed.
|
|
20
|
+
- Prefer route handlers for backend endpoints (`app/api`).
|
|
21
|
+
- Keep data access centralized (services or lib modules).
|
|
22
|
+
|
|
23
|
+
## Server actions
|
|
24
|
+
- Use server actions for mutations when appropriate.
|
|
25
|
+
- Validate inputs server-side and return explicit errors.
|
|
26
|
+
|
|
27
|
+
## Performance
|
|
28
|
+
- Use `next/image` and `next/font` when available.
|
|
29
|
+
- Prefer streaming and Suspense for large data loads.
|
|
30
|
+
- Avoid blocking client navigation with heavy client bundles.
|
|
31
|
+
|
|
32
|
+
## Styling
|
|
33
|
+
- Follow existing styling conventions (CSS Modules, Tailwind, etc.).
|
|
34
|
+
- Keep global styles limited to `app/globals.css` (or equivalent).
|
|
35
|
+
|
|
36
|
+
## Testing
|
|
37
|
+
- Add tests for critical routes and server actions when feasible.
|
|
38
|
+
|
|
39
|
+
## Quality
|
|
40
|
+
- Use strict TypeScript typing when available.
|
|
41
|
+
- Handle loading, empty, and error states explicitly.
|
|
42
|
+
- Maintain accessibility (semantic HTML, labels, ARIA as needed).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Quarkus Rules
|
|
2
|
+
|
|
3
|
+
## Versioning
|
|
4
|
+
- Target the latest stable Quarkus version used by the project.
|
|
5
|
+
- If the version is unclear, inspect `pom.xml`/`build.gradle` and ask the user.
|
|
6
|
+
- Avoid experimental/pre-release features unless explicitly requested.
|
|
7
|
+
|
|
8
|
+
## Architecture
|
|
9
|
+
- Prefer layered, feature-oriented packages (domain-focused, not purely technical).
|
|
10
|
+
- Keep resources (REST endpoints) thin and delegate to services.
|
|
11
|
+
- Use CDI for dependency injection (`@Inject`).
|
|
12
|
+
|
|
13
|
+
## REST APIs
|
|
14
|
+
- Use `jakarta.ws.rs` annotations for resources.
|
|
15
|
+
- Validate inputs with `jakarta.validation` and `@Valid`.
|
|
16
|
+
- Return typed DTOs; avoid exposing entities directly.
|
|
17
|
+
|
|
18
|
+
## Data access
|
|
19
|
+
- Use Panache when it is already in use; otherwise follow existing repository patterns.
|
|
20
|
+
- Prefer transactions on service methods (`@Transactional`).
|
|
21
|
+
- Avoid N+1 queries; fetch joins or proper batching when needed.
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
- Use `application.properties` or `application.yml` consistently with the project.
|
|
25
|
+
- Prefer `@ConfigMapping` / `@ConfigProperties` over `@ConfigProperty` for grouped config.
|
|
26
|
+
|
|
27
|
+
## Testing
|
|
28
|
+
- Prefer `@QuarkusTest` for integration tests.
|
|
29
|
+
- Use `RestAssured` for HTTP endpoint tests if available.
|
|
30
|
+
|
|
31
|
+
## Performance & native
|
|
32
|
+
- Keep startup and memory constraints in mind.
|
|
33
|
+
- Avoid heavy reflection; use `@RegisterForReflection` only when necessary.
|
|
34
|
+
- If native image is used, verify compatibility with extensions and reflection.
|
|
35
|
+
|
|
36
|
+
## Quality
|
|
37
|
+
- Use strict typing and clear DTOs.
|
|
38
|
+
- Handle errors explicitly and return meaningful HTTP status codes.
|
|
39
|
+
- Maintain accessibility in any UI integration (if present).
|