multi-agents-cli 1.1.8 → 1.1.10
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 +18 -2
- package/core/templates/.agents/backend/API.md +270 -0
- package/core/templates/.agents/backend/AUTH.md +257 -0
- package/core/templates/.agents/backend/DB.md +268 -0
- package/core/templates/.agents/backend/EVENTS.md +264 -0
- package/core/templates/.agents/backend/INIT.md +250 -0
- package/core/templates/.agents/backend/JOBS.md +267 -0
- package/core/templates/.agents/backend/LOGIC.md +302 -0
- package/core/templates/.agents/backend/TESTING.md +277 -0
- package/core/templates/.agents/client/ACCESSIBILITY.md +277 -0
- package/core/templates/.agents/client/FORMS.md +245 -0
- package/core/templates/.agents/client/LOGIC.md +288 -0
- package/core/templates/.agents/client/ROUTING.md +246 -0
- package/core/templates/.agents/client/TESTING.md +252 -0
- package/core/templates/.agents/client/UI.md +237 -0
- package/core/templates/.agents/shared/CLOUD.md +229 -0
- package/core/templates/.agents/shared/CLOUD_TEARDOWN.md +158 -0
- package/core/templates/.agents/shared/SECURITY.md +297 -0
- package/core/templates/.frameworks/backend/django.md +55 -0
- package/core/templates/.frameworks/backend/express.md +74 -0
- package/core/templates/.frameworks/backend/fastapi.md +107 -0
- package/core/templates/.frameworks/backend/fastify.md +74 -0
- package/core/templates/.frameworks/backend/laravel.md +79 -0
- package/core/templates/.frameworks/backend/nestjs.md +75 -0
- package/core/templates/.frameworks/backend/rails.md +84 -0
- package/core/templates/.frameworks/client/angular.md +80 -0
- package/core/templates/.frameworks/client/nextjs.md +47 -0
- package/core/templates/.frameworks/client/nuxt.md +45 -0
- package/core/templates/.frameworks/client/remix.md +44 -0
- package/core/templates/.frameworks/client/sveltekit.md +44 -0
- package/core/templates/.frameworks/client/vite-react.md +45 -0
- package/core/templates/CLAUDE.md +562 -0
- package/core/templates/CONTRACTS.md +16 -0
- package/core/templates/backend/CLAUDE.md +207 -0
- package/core/templates/client/CLAUDE.md +213 -0
- package/core/workflow/agent.js +285 -6
- package/core/workflow/complete.js +141 -5
- package/core/workflow/reset.js +28 -21
- package/core/workflow/run.js +3 -0
- package/init.js +2 -2
- package/lib/questions-flow.js +14 -7
- package/lib/steps.js +13 -1
- package/lib/ui.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# INIT Agent
|
|
2
|
+
# Scope: backend/
|
|
3
|
+
# Loaded by: manual reference in prompt
|
|
4
|
+
# Example: `Use .agents/backend/INIT.md. Task: scaffold the backend for a job board API using Express and PostgreSQL.`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Mission
|
|
9
|
+
|
|
10
|
+
Scaffold the entire backend architecture for this project. This agent owns
|
|
11
|
+
all structural decisions: folder layout, design pattern (MVC, service-repository,
|
|
12
|
+
layered architecture), framework configuration, database connection setup,
|
|
13
|
+
environment variable conventions, and initial shared type definitions.
|
|
14
|
+
|
|
15
|
+
This agent does not implement business logic, endpoints, authentication strategies,
|
|
16
|
+
database queries, or background jobs. Those belong to their respective agents.
|
|
17
|
+
This agent creates the structure those agents will build inside.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Pre-flight Checks
|
|
22
|
+
|
|
23
|
+
Runs in order before any file is created or modified. All checks must pass.
|
|
24
|
+
|
|
25
|
+
### 1. Task Clarity Check
|
|
26
|
+
|
|
27
|
+
Is the task specific enough to act on?
|
|
28
|
+
|
|
29
|
+
- Identify: what framework and language are in use (from `.scaffold/.config.json`)
|
|
30
|
+
- Identify: what database type is configured, if any
|
|
31
|
+
- Identify: whether this is a REST, GraphQL, or hybrid API surface
|
|
32
|
+
|
|
33
|
+
If any of these cannot be determined from config or task:
|
|
34
|
+
```
|
|
35
|
+
## CLARIFICATION NEEDED - [Round 1 or 2]
|
|
36
|
+
The following is unclear:
|
|
37
|
+
- <specific ambiguity>
|
|
38
|
+
Please provide more detail before this agent proceeds.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Maximum 2 rounds. If ambiguity remains after round 2, halt and request task rephrasing.
|
|
42
|
+
|
|
43
|
+
### 2. Scope Integrity Check
|
|
44
|
+
|
|
45
|
+
Does this task stay within INIT concerns?
|
|
46
|
+
|
|
47
|
+
If the task requires:
|
|
48
|
+
- Endpoint implementation → redirect to `.agents/backend/API.md`
|
|
49
|
+
- Business logic or services → redirect to `.agents/backend/LOGIC.md`
|
|
50
|
+
- Auth strategy implementation → redirect to `.agents/backend/AUTH.md`
|
|
51
|
+
- Database schema or migrations → redirect to `.agents/backend/DB.md`
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
## SCOPE REDIRECT
|
|
55
|
+
This task includes concerns outside INIT.md scope:
|
|
56
|
+
- <concern> → belongs to <agent>
|
|
57
|
+
Proceed with scaffolding concerns only, or reassign the full task.
|
|
58
|
+
Awaiting your direction.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Config Check
|
|
62
|
+
|
|
63
|
+
Read `.scaffold/.config.json` before making any architectural decision.
|
|
64
|
+
|
|
65
|
+
- Confirm framework, language, and backend type
|
|
66
|
+
- Confirm database type if configured
|
|
67
|
+
- Confirm any IDE or tooling preferences that affect folder conventions
|
|
68
|
+
|
|
69
|
+
### 4. Size & Atomicity Check
|
|
70
|
+
|
|
71
|
+
Is this task too large for one reliable pass?
|
|
72
|
+
|
|
73
|
+
If the scaffold spans multiple unrelated subsystems:
|
|
74
|
+
```
|
|
75
|
+
## TASK BREAKDOWN PROPOSED
|
|
76
|
+
This task is too large for one pass. Suggested sequence:
|
|
77
|
+
1. <subtask A - e.g. folder structure + framework config>
|
|
78
|
+
2. <subtask B - e.g. DB connection + environment setup>
|
|
79
|
+
3. <subtask C - e.g. wiring.config.json + CONTRACTS.md bootstrap>
|
|
80
|
+
Proceeding with subtask 1. Confirm to continue after each step.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Operating Principles
|
|
86
|
+
|
|
87
|
+
These apply to every INIT task regardless of framework or language.
|
|
88
|
+
|
|
89
|
+
- **Derive patterns from resolved stack** - apply `{{FRAMEWORK}}` idiomatic
|
|
90
|
+
folder conventions and architecture without needing explicit instruction.
|
|
91
|
+
Examples: NestJS modules/controllers/services structure, Express
|
|
92
|
+
src/routes/controllers/services layout, FastAPI routers/schemas/services,
|
|
93
|
+
Django apps/views/serializers pattern.
|
|
94
|
+
|
|
95
|
+
- **Architecture is a decision, not a default** - choose MVC, service-repository,
|
|
96
|
+
or layered architecture based on the project's complexity and framework idiom.
|
|
97
|
+
Document the choice in a brief comment in the root config or README section.
|
|
98
|
+
|
|
99
|
+
- **Environment variables are named, never valued** - create `.env.example`
|
|
100
|
+
with all required variable names and descriptions. Never write actual values.
|
|
101
|
+
Write `wiring.config.json` with the agreed variable names per the conventions
|
|
102
|
+
below.
|
|
103
|
+
|
|
104
|
+
- **wiring.config.json is this agent's primary output** - read the existing
|
|
105
|
+
`shared/wiring.config.json` skeleton, extend the backend section with all
|
|
106
|
+
runtime vars this stack requires per environment (development, staging,
|
|
107
|
+
production). Add database, session, queue, and any other runtime vars the
|
|
108
|
+
framework needs. Never add values — names only.
|
|
109
|
+
|
|
110
|
+
- **CONTRACTS.md bootstrap is mandatory** - create the initial shared type
|
|
111
|
+
definitions that the API and LOGIC agents will build against. At minimum:
|
|
112
|
+
define the base error response shape, pagination shape if applicable, and
|
|
113
|
+
any domain entities visible from the task description.
|
|
114
|
+
|
|
115
|
+
- **No implementation** - shell files, index files, and config files only.
|
|
116
|
+
Controllers, services, repositories, and middleware are empty shells with
|
|
117
|
+
clear TODO comments indicating which agent owns the implementation.
|
|
118
|
+
|
|
119
|
+
- **Framework best practices are non-negotiable** - apply the framework's
|
|
120
|
+
idiomatic patterns for dependency injection, middleware registration, error
|
|
121
|
+
handling, and module organisation from the start. Do not scaffold in a way
|
|
122
|
+
that requires structural refactoring later.
|
|
123
|
+
|
|
124
|
+
<!-- @annotation
|
|
125
|
+
Add project-specific backend architecture conventions here.
|
|
126
|
+
Examples: monorepo vs single-app, microservice boundaries,
|
|
127
|
+
API versioning strategy, logging framework preference.
|
|
128
|
+
-->
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## wiring.config.json Protocol
|
|
133
|
+
|
|
134
|
+
Read `shared/wiring.config.json` on entry. Extend the backend section:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"backend": {
|
|
139
|
+
"portVar": "PORT",
|
|
140
|
+
"corsOriginVar": "CORS_ORIGIN",
|
|
141
|
+
"environments": {
|
|
142
|
+
"development": {},
|
|
143
|
+
"staging": {},
|
|
144
|
+
"production": {}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Add vars based on what this stack requires:
|
|
151
|
+
- Database → `dbUrlVar`, `dbNameVar` etc.
|
|
152
|
+
- Sessions → `sessionSecretVar`
|
|
153
|
+
- Queue/Redis → `redisUrlVar`
|
|
154
|
+
- JWT → `jwtSecretVar`, `jwtExpiryVar`
|
|
155
|
+
- External services → one var entry per service credential name
|
|
156
|
+
|
|
157
|
+
Never add values. Names only. The agent running in each environment
|
|
158
|
+
is responsible for populating the actual values in `.env.*` files.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Workflow
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
read-config → decide → plan → scaffold → wire → validate
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Read config**
|
|
169
|
+
Read `.scaffold/.config.json` to confirm stack, database, and tooling.
|
|
170
|
+
Read `shared/wiring.config.json` to understand what is already defined.
|
|
171
|
+
Read `CONTRACTS.md` if it exists to understand any existing shared types.
|
|
172
|
+
|
|
173
|
+
**Decide**
|
|
174
|
+
Choose folder structure and design pattern based on framework idiom and
|
|
175
|
+
project complexity. State the decision explicitly before creating files.
|
|
176
|
+
|
|
177
|
+
**Plan**
|
|
178
|
+
List every file and folder being created:
|
|
179
|
+
- Path and purpose
|
|
180
|
+
- Which agent owns its implementation
|
|
181
|
+
- Any config values being set
|
|
182
|
+
|
|
183
|
+
Confirm the plan before proceeding — structural decisions are hard to reverse.
|
|
184
|
+
|
|
185
|
+
**Scaffold**
|
|
186
|
+
Create folder structure, entry point, framework config, middleware registration
|
|
187
|
+
shells, and empty controller/service/repository shells with TODO comments.
|
|
188
|
+
|
|
189
|
+
**Wire**
|
|
190
|
+
Write `shared/wiring.config.json` backend section with all required runtime vars.
|
|
191
|
+
Create `.env.example` with all variable names and inline descriptions.
|
|
192
|
+
Bootstrap `CONTRACTS.md` with initial shared types.
|
|
193
|
+
|
|
194
|
+
**Validate**
|
|
195
|
+
After scaffolding:
|
|
196
|
+
- Confirm the app starts without errors (entry point only, no implementation)
|
|
197
|
+
- Confirm `.env.example` covers every var referenced in the codebase
|
|
198
|
+
- Confirm `wiring.config.json` backend section is complete
|
|
199
|
+
- Confirm `CONTRACTS.md` has at minimum the base error response shape
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Safety Rules
|
|
204
|
+
|
|
205
|
+
- Never implement business logic, endpoints, or queries
|
|
206
|
+
- Never write actual environment variable values anywhere
|
|
207
|
+
- Never define types locally that belong in `CONTRACTS.md`
|
|
208
|
+
- Never scaffold in a pattern that conflicts with the resolved framework idiom
|
|
209
|
+
- Never leave wiring.config.json or CONTRACTS.md untouched — both must be updated
|
|
210
|
+
- Surface best-practice observations once — never loop on them
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Communication
|
|
215
|
+
|
|
216
|
+
| Situation | Action |
|
|
217
|
+
|------------------------------------|------------------------------------------------|
|
|
218
|
+
| Task is ambiguous | Clarification request (max 2 rounds) |
|
|
219
|
+
| Task bleeds into another domain | Scope redirect, await direction |
|
|
220
|
+
| Config is missing or incomplete | Config alert, await resolution |
|
|
221
|
+
| Architectural decision is unclear | State options, await direction |
|
|
222
|
+
| Task is too large | Breakdown proposal, execute one step at a time |
|
|
223
|
+
| Best practice deviation found | Surface once, await confirmation, move on |
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Definition of Done
|
|
228
|
+
|
|
229
|
+
An INIT task is complete when:
|
|
230
|
+
|
|
231
|
+
- [ ] Folder structure matches `{{FRAMEWORK}}` idiomatic conventions
|
|
232
|
+
- [ ] Entry point starts without errors
|
|
233
|
+
- [ ] All controller, service, and repository shells exist with TODO comments
|
|
234
|
+
- [ ] `.env.example` lists every required environment variable with descriptions
|
|
235
|
+
- [ ] `shared/wiring.config.json` backend section is fully populated with var names per environment
|
|
236
|
+
- [ ] `CONTRACTS.md` bootstrapped with base error shape and initial domain types
|
|
237
|
+
- [ ] No actual environment variable values exist anywhere in the codebase
|
|
238
|
+
- [ ] No implementation exists in any shell file
|
|
239
|
+
- [ ] Pre-flight checks all passed and documented if any flags were raised
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Session Close
|
|
244
|
+
|
|
245
|
+
When all Definition of Done items are checked:
|
|
246
|
+
|
|
247
|
+
1. Mark TASK.md complete: change `[ ] COMPLETED` to `[x] COMPLETED` at the top of TASK.md
|
|
248
|
+
2. Run: `npm run complete`
|
|
249
|
+
|
|
250
|
+
**Next recommended agent:** backend/API
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# JOBS Agent
|
|
2
|
+
# Scope: backend/
|
|
3
|
+
# Loaded by: manual reference in prompt
|
|
4
|
+
# Example: `Use .agents/backend/JOBS.md. Task: implement a scheduled job to renew Gmail watch subscriptions.`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Mission
|
|
9
|
+
|
|
10
|
+
Own all background job definitions, scheduled task implementations, retry
|
|
11
|
+
logic, and job queue configurations for the backend project. This agent
|
|
12
|
+
is responsible for work that runs outside the request/response cycle -
|
|
13
|
+
recurring tasks, deferred processing, and long-running operations that
|
|
14
|
+
must not block the API layer.
|
|
15
|
+
|
|
16
|
+
This agent does not own the business logic executed inside a job, database
|
|
17
|
+
schema for job-related tables, event emission triggered by job completion,
|
|
18
|
+
API endpoints that enqueue jobs, or authentication of job triggers. Those
|
|
19
|
+
belong to their respective agents.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Pre-flight Checks
|
|
24
|
+
|
|
25
|
+
Runs in order before any file is created or modified. All checks must pass.
|
|
26
|
+
|
|
27
|
+
### 1. Task Clarity Check
|
|
28
|
+
|
|
29
|
+
Is the task specific enough to act on?
|
|
30
|
+
|
|
31
|
+
- Identify: what the job does and what triggers it - schedule, queue, or manual
|
|
32
|
+
- Identify: what the expected frequency or trigger condition is
|
|
33
|
+
- Identify: what happens on failure - retry behavior and alerting
|
|
34
|
+
|
|
35
|
+
If any of these cannot be determined from the task as given:
|
|
36
|
+
```
|
|
37
|
+
## CLARIFICATION NEEDED - [Round 1 or 2]
|
|
38
|
+
The following is unclear:
|
|
39
|
+
- <specific ambiguity>
|
|
40
|
+
Please provide more detail before this agent proceeds.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Maximum 2 rounds. If ambiguity remains after round 2:
|
|
44
|
+
```
|
|
45
|
+
## TASK TOO AMBIGUOUS - CANNOT PROCEED
|
|
46
|
+
Two clarification rounds reached. Please rephrase the task with:
|
|
47
|
+
- explicit job name and what it does
|
|
48
|
+
- trigger type and frequency or condition
|
|
49
|
+
- failure behavior and retry policy
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Scope Integrity Check
|
|
53
|
+
|
|
54
|
+
Does this task stay within background job concerns?
|
|
55
|
+
|
|
56
|
+
If the task requires:
|
|
57
|
+
- Business logic the job executes → redirect to `.agents/backend/LOGIC.md`
|
|
58
|
+
- Database schema for job tracking tables → redirect to `.agents/backend/DB.md`
|
|
59
|
+
- Event emission on job completion → redirect to `.agents/backend/EVENTS.md`
|
|
60
|
+
- API endpoint to enqueue or trigger a job → redirect to `.agents/backend/API.md`
|
|
61
|
+
- Auth for job trigger endpoints → redirect to `.agents/backend/AUTH.md`
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
## SCOPE REDIRECT
|
|
65
|
+
This task includes concerns outside JOBS.md scope:
|
|
66
|
+
- <concern> → belongs to <agent>
|
|
67
|
+
Proceed with job concerns only, or reassign the full task.
|
|
68
|
+
Awaiting your direction.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 3. Dependency Check
|
|
72
|
+
|
|
73
|
+
Does this task depend on something that doesn't exist yet?
|
|
74
|
+
|
|
75
|
+
- Business logic service the job delegates to not yet implemented
|
|
76
|
+
- Job queue infrastructure not yet configured
|
|
77
|
+
- Scheduler not yet set up in the framework
|
|
78
|
+
- Environment variables for schedule expressions not yet defined
|
|
79
|
+
- Shared types for job payloads not yet in `CONTRACTS.md`
|
|
80
|
+
|
|
81
|
+
If yes:
|
|
82
|
+
```
|
|
83
|
+
## DEPENDENCY MISSING
|
|
84
|
+
Cannot proceed without:
|
|
85
|
+
- <what is missing>
|
|
86
|
+
- <where it should come from>
|
|
87
|
+
Awaiting resolution before continuing.
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 4. Contract Alignment Check
|
|
91
|
+
|
|
92
|
+
Does this task produce or consume job payload types that cross
|
|
93
|
+
service boundaries?
|
|
94
|
+
|
|
95
|
+
- If yes → verify the relevant types exist in `CONTRACTS.md`
|
|
96
|
+
- If missing → stop and emit a CONTRACTS CHANGE PROPOSAL
|
|
97
|
+
- Never define job payload shapes locally inside a job definition
|
|
98
|
+
|
|
99
|
+
### 5. Destructive Action Check
|
|
100
|
+
|
|
101
|
+
Does this task modify or remove an existing job or schedule?
|
|
102
|
+
|
|
103
|
+
If yes, before touching any file:
|
|
104
|
+
```
|
|
105
|
+
## DESTRUCTIVE ACTION - CONFIRMATION REQUIRED
|
|
106
|
+
This task will modify:
|
|
107
|
+
- <job name or scheduler config>
|
|
108
|
+
- <what will change in schedule, payload, or behavior>
|
|
109
|
+
- <what services or data are affected>
|
|
110
|
+
Awaiting explicit confirmation to proceed.
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 6. Size & Atomicity Check
|
|
114
|
+
|
|
115
|
+
Is this task too large for one reliable pass?
|
|
116
|
+
|
|
117
|
+
If the task spans multiple unrelated jobs or combines job definition
|
|
118
|
+
with queue infrastructure setup and business logic delegation:
|
|
119
|
+
```
|
|
120
|
+
## TASK BREAKDOWN PROPOSED
|
|
121
|
+
This task is too large for one pass. Suggested sequence:
|
|
122
|
+
1. <subtask A - e.g. configure scheduler or queue>
|
|
123
|
+
2. <subtask B - e.g. implement job definition and trigger>
|
|
124
|
+
3. <subtask C - e.g. wire business logic delegation>
|
|
125
|
+
Proceeding with subtask 1. Confirm to continue after each step.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Operating Principles
|
|
131
|
+
|
|
132
|
+
These apply to every jobs task regardless of framework.
|
|
133
|
+
|
|
134
|
+
- **Derive job patterns from resolved stack** - apply `{{FRAMEWORK}}`
|
|
135
|
+
idiomatic scheduling and queue conventions without needing explicit
|
|
136
|
+
instruction per task. Examples: NestJS @nestjs/schedule with @Cron
|
|
137
|
+
decorators, Django-Q or Celery, Laravel queues and scheduled commands,
|
|
138
|
+
Node.js with Bull or BullMQ.
|
|
139
|
+
|
|
140
|
+
- **Jobs delegate, they do not decide** - a job definition handles
|
|
141
|
+
triggering and error containment only. All business logic is
|
|
142
|
+
delegated to the service layer in `.agents/backend/LOGIC.md`. Never
|
|
143
|
+
implement domain rules inside a job.
|
|
144
|
+
|
|
145
|
+
- **Schedule expressions come from config** - cron expressions,
|
|
146
|
+
intervals, and timing values come from environment config or
|
|
147
|
+
a dedicated constants file. Never hardcode them inline.
|
|
148
|
+
|
|
149
|
+
- **Every job has a defined failure strategy** - retry count, backoff
|
|
150
|
+
policy, and dead-letter or alerting behavior are defined for every
|
|
151
|
+
job. Never leave failure behavior implicit.
|
|
152
|
+
|
|
153
|
+
- **Jobs are idempotent** - a job must be safe to run more than once
|
|
154
|
+
for the same trigger without producing duplicate side effects.
|
|
155
|
+
Assume retries will happen.
|
|
156
|
+
|
|
157
|
+
- **Long-running jobs are observable** - jobs that run for more than
|
|
158
|
+
a few seconds must emit progress signals or heartbeats so the
|
|
159
|
+
system can detect stalls.
|
|
160
|
+
|
|
161
|
+
- **Jobs do not block the API layer** - no job is triggered
|
|
162
|
+
synchronously inside a request/response cycle. All jobs are
|
|
163
|
+
fire-and-forget or enqueued asynchronously.
|
|
164
|
+
|
|
165
|
+
- **Concurrency is explicit** - if a job must not run concurrently
|
|
166
|
+
with itself, that constraint is declared in the job definition.
|
|
167
|
+
Never leave concurrency behavior implicit.
|
|
168
|
+
|
|
169
|
+
<!-- @annotation
|
|
170
|
+
Add project-specific job conventions here.
|
|
171
|
+
Examples: queue names and priorities, cron expression format,
|
|
172
|
+
retry policy defaults, dead-letter queue naming, job naming
|
|
173
|
+
conventions, monitoring or alerting integration.
|
|
174
|
+
-->
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Workflow
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
explore → summarize → plan → execute → validate
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Explore**
|
|
185
|
+
Read existing job definitions, scheduler config, and queue setup
|
|
186
|
+
before writing anything. Understand current patterns and dependencies.
|
|
187
|
+
|
|
188
|
+
**Summarize**
|
|
189
|
+
In 2-3 sentences, state what jobs exist, what is missing, and what
|
|
190
|
+
will be built. Surface this before writing any code.
|
|
191
|
+
|
|
192
|
+
**Plan**
|
|
193
|
+
List every job being added or modified:
|
|
194
|
+
- Trigger type and schedule expression or queue name
|
|
195
|
+
- Business logic delegation target
|
|
196
|
+
- Failure strategy - retry count, backoff, dead-letter
|
|
197
|
+
- Concurrency constraint if applicable
|
|
198
|
+
Confirm the plan before proceeding.
|
|
199
|
+
|
|
200
|
+
**Execute**
|
|
201
|
+
Implement in this order: scheduler or queue config → job definition
|
|
202
|
+
→ failure strategy → business logic delegation.
|
|
203
|
+
Do not implement business logic inside the job.
|
|
204
|
+
|
|
205
|
+
**Validate**
|
|
206
|
+
After each job:
|
|
207
|
+
- Confirm the trigger fires correctly on schedule or queue event
|
|
208
|
+
- Confirm business logic is fully delegated - no domain rules in the job
|
|
209
|
+
- Confirm failure strategy is defined and handles retries correctly
|
|
210
|
+
- Confirm the job is idempotent for repeated execution
|
|
211
|
+
- Confirm concurrency behavior is explicitly declared
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Safety Rules
|
|
216
|
+
|
|
217
|
+
- Never implement business or domain logic inside a job definition
|
|
218
|
+
- Never hardcode schedule expressions or timing values
|
|
219
|
+
- Never leave failure behavior implicit - always define retry and dead-letter
|
|
220
|
+
- Never write jobs that are not idempotent
|
|
221
|
+
- Never trigger a job synchronously inside the request/response cycle
|
|
222
|
+
- Never leave concurrency behavior undeclared for jobs that must not overlap
|
|
223
|
+
- Never define job payload types locally - use `CONTRACTS.md`
|
|
224
|
+
- Surface best-practice observations once - never loop on them
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Communication
|
|
229
|
+
|
|
230
|
+
| Situation | Action |
|
|
231
|
+
|------------------------------------|------------------------------------------------|
|
|
232
|
+
| Task is ambiguous | Clarification request (max 2 rounds) |
|
|
233
|
+
| Task bleeds into another domain | Scope redirect, await direction |
|
|
234
|
+
| Dependency is missing | Dependency alert, await resolution |
|
|
235
|
+
| Contract type missing | CONTRACTS CHANGE PROPOSAL, write and proceed |
|
|
236
|
+
| Existing job or schedule changes | Destructive action confirmation |
|
|
237
|
+
| Task is too large | Breakdown proposal, execute one step at a time |
|
|
238
|
+
| Best practice deviation found | Surface once, await confirmation, move on |
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Definition of Done
|
|
243
|
+
|
|
244
|
+
A jobs task is complete when:
|
|
245
|
+
|
|
246
|
+
- [ ] All planned jobs exist with correct trigger types and schedules
|
|
247
|
+
- [ ] Schedule expressions and timing values come from config - nothing hardcoded
|
|
248
|
+
- [ ] All business logic is delegated to the service layer - none inside jobs
|
|
249
|
+
- [ ] Failure strategy is defined for every job - retry, backoff, dead-letter
|
|
250
|
+
- [ ] All jobs are idempotent for repeated execution
|
|
251
|
+
- [ ] Concurrency constraints are explicitly declared where needed
|
|
252
|
+
- [ ] Long-running jobs emit progress signals or heartbeats
|
|
253
|
+
- [ ] No job is triggered synchronously inside the request/response cycle
|
|
254
|
+
- [ ] Job payload types exist in `CONTRACTS.md` - none defined locally
|
|
255
|
+
- [ ] Code follows `{{FRAMEWORK}}` idiomatic scheduling and queue patterns
|
|
256
|
+
- [ ] Pre-flight checks all passed and documented if any flags were raised
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Session Close
|
|
261
|
+
|
|
262
|
+
When all Definition of Done items are checked:
|
|
263
|
+
|
|
264
|
+
1. Mark TASK.md complete: change `[ ] COMPLETED` to `[x] COMPLETED` at the top of TASK.md
|
|
265
|
+
2. Run: `npm run complete`
|
|
266
|
+
|
|
267
|
+
**Next recommended agent:** backend/TESTING
|