agents-templated 1.2.12 → 2.1.0

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.
@@ -1,665 +0,0 @@
1
- # AI Assistant Instructions
2
-
3
- This project follows enterprise-grade, technology-agnostic development patterns. Always reference these files when providing assistance.
4
-
5
- ## Primary Documentation (Always Reference)
6
-
7
- - **`AGENTS.MD`** - This file! AI instructions for working with AI assistants
8
- - **`agent-docs/ARCHITECTURE.md`** - Overall project guidelines, architecture principles, and technology stack selection
9
- - **`agents/skills/`** - Custom skills for domain-specific tasks in your project
10
-
11
- ## Detailed Rules (Reference When Relevant)
12
-
13
- When implementing features, always check the relevant rule file:
14
-
15
- - **`agents/rules/core.mdc`** - Core architecture principles, security-first development, performance patterns
16
- - **`agents/rules/security.mdc`** - Security patterns, OWASP Top 10 protection, authentication/authorization (ALWAYS APPLY)
17
- - **`agents/rules/testing.mdc`** - Testing strategy, coverage targets, testing patterns (ALWAYS APPLY)
18
- - **`agents/rules/frontend.mdc`** - Frontend development patterns, component architecture, accessibility
19
- - **`agents/rules/database.mdc`** - Database schema design, migrations, query optimization
20
- - **`agents/rules/style.mdc`** - Code style guidelines, formatting rules, naming conventions
21
- - **`agents/rules/workflows.mdc`** - Development workflow (validate, doctor, pre-commit)
22
- - **`agents/rules/intent-routing.mdc`** - Deterministic intent-to-command routing and ambiguity handling
23
- - **`agents/rules/system-workflow.mdc`** - End-to-end delivery lifecycle gates and required artifacts
24
- - **`agents/rules/hardening.mdc`** - Risk-based application hardening and obfuscation guidance
25
-
26
- ## Usage Workflow
27
-
28
- When implementing any feature:
29
-
30
- 1. **Check for custom skills**: Review `agents/skills/` for domain-specific guidance
31
- 2. **Reference `agent-docs/ARCHITECTURE.md`** for overall architecture and technology stack guidance
32
- 3. **Apply relevant rules** from `agents/rules/*.mdc` files based on the task
33
- 4. **Always apply security patterns** from `agents/rules/security.mdc`
34
- 5. **Always apply testing patterns** from `agents/rules/testing.mdc`
35
-
36
- ## Deterministic Slash Command System Standard
37
-
38
- ----------------------------------------
39
- 1. SYSTEM PRINCIPLES
40
- ----------------------------------------
41
-
42
- ### Determinism Rules
43
- - Slash command mode is entered when input starts with `/` at position 0.
44
- - Implicit slash-command mode is entered when non-slash input is deterministically mapped to a command contract.
45
- - Command parsing is exact, case-sensitive, and whitespace-normalized.
46
- - Unknown or malformed slash commands return a structured error and stop.
47
- - No conversational fallback is allowed while in slash command mode.
48
- - Each command executes a fixed algorithm defined in this standard.
49
-
50
- ### Output Standardization
51
- - Every command response must be structured and audit-ready.
52
- - Mandatory top-level output fields for all commands:
53
- - `command`
54
- - `execution_id`
55
- - `mode`
56
- - `status`
57
- - `inputs`
58
- - `prechecks`
59
- - `execution_log`
60
- - `artifacts`
61
- - `risks`
62
- - `safety_checks`
63
- - `stop_condition`
64
- - `next_action`
65
- - If any field is unknown, set value to `null` and continue schema compliance.
66
-
67
- ### Escalation Policy
68
- - Escalate only for safety, permission, or logical blockers.
69
- - Escalation output must include:
70
- - `escalation_required: true`
71
- - `blocker_type`
72
- - `required_user_confirmation`
73
- - `safe_alternative`
74
-
75
- ### Destructive Action Policy
76
- - Any destructive action requires explicit confirmation token in user input:
77
- - `CONFIRM-DESTRUCTIVE:<target>`
78
- - Without token, command must return `status: blocked` and no execution.
79
-
80
- ### Minimal Clarification Policy
81
- - Do not ask questions unless execution is unsafe or logically blocked.
82
- - Maximum clarification prompts per command: 2.
83
- - Clarification prompt must be decision-critical and single-purpose.
84
-
85
- ----------------------------------------
86
- 2. UNIVERSAL COMMAND RULE
87
- ----------------------------------------
88
-
89
- If input matches regex `^/[a-z]+(\s|$)` then the agent must:
90
- 1. Parse command and arguments.
91
- 2. Set `mode = slash-command`.
92
- 3. Disable conversational style and narrative prose.
93
- 4. Execute only the deterministic flow for that command.
94
- 5. Return output strictly using the defined structured schema.
95
- 6. If parsing fails, return structured error and stop.
96
-
97
- If input does NOT start with `/`, the agent must run implicit command routing:
98
- 1. Evaluate whether the input intent maps to one command from this standard.
99
- 2. If a single command is selected with sufficient confidence, set `mode = slash-command-auto`.
100
- 3. Transform free text into required command inputs using deterministic field mapping.
101
- 4. Execute the selected command's deterministic flow.
102
- 5. Return output using the same structured schema with selected `command`.
103
- 6. If command selection is ambiguous or unsafe, return `status: blocked` with minimal missing inputs.
104
-
105
- ----------------------------------------
106
- 3. COMMAND DEFINITIONS
107
- ----------------------------------------
108
-
109
- ### /plan
110
- #### A. Intent
111
- Generate an executable implementation plan with ordered steps and risk controls.
112
-
113
- #### B. When to Use
114
- Use for non-trivial work requiring sequencing, dependencies, and checkpoints.
115
-
116
- #### C. Required Inputs
117
- - Objective
118
- - Scope boundaries
119
- - Constraints (security, testing, timeline)
120
-
121
- #### D. Deterministic Execution Flow
122
- 1. Parse objective and constraints.
123
- 2. Identify atomic work units.
124
- 3. Compute dependency order.
125
- 4. Attach validation checkpoint to each unit.
126
- 5. Attach risk and rollback note to each unit.
127
- 6. Emit plan artifact.
128
-
129
- #### E. Structured Output Template
130
- - `plan_summary`
131
- - `work_units[]`
132
- - `dependency_graph`
133
- - `validation_checkpoints[]`
134
- - `risk_register[]`
135
-
136
- #### F. Stop Conditions
137
- - Missing objective or scope.
138
- - Contradictory constraints.
139
-
140
- #### G. Safety Constraints
141
- - Must include security and test gates for all code-changing units.
142
-
143
- ### /task
144
- #### A. Intent
145
- Convert a plan item into a deterministic execution task.
146
-
147
- #### B. When to Use
148
- Use when a specific task must be executed with clear acceptance criteria.
149
-
150
- #### C. Required Inputs
151
- - Task identifier
152
- - Acceptance criteria
153
- - Allowed files/modules
154
-
155
- #### D. Deterministic Execution Flow
156
- 1. Resolve task identifier.
157
- 2. Validate acceptance criteria completeness.
158
- 3. Validate file/module boundaries.
159
- 4. Define execution steps.
160
- 5. Define verification steps.
161
- 6. Emit task contract.
162
-
163
- #### E. Structured Output Template
164
- - `task_id`
165
- - `objective`
166
- - `allowed_scope`
167
- - `execution_steps[]`
168
- - `verification_steps[]`
169
- - `acceptance_criteria[]`
170
-
171
- #### F. Stop Conditions
172
- - Task not found.
173
- - Acceptance criteria missing.
174
-
175
- #### G. Safety Constraints
176
- - Must reject tasks that exceed declared scope.
177
-
178
- ### /scaffold
179
- #### A. Intent
180
- Create deterministic boilerplate artifacts from declared architecture constraints.
181
-
182
- #### B. When to Use
183
- Use to initialize new modules/features with approved structure.
184
-
185
- #### C. Required Inputs
186
- - Target feature/module name
187
- - Stack/runtime
188
- - Required architectural patterns
189
-
190
- #### D. Deterministic Execution Flow
191
- 1. Validate target does not conflict with existing paths.
192
- 2. Resolve scaffold template by stack/runtime.
193
- 3. Generate file tree.
194
- 4. Generate minimal secure defaults.
195
- 5. Generate baseline tests.
196
- 6. Emit scaffold manifest.
197
-
198
- #### E. Structured Output Template
199
- - `target`
200
- - `template_source`
201
- - `files_created[]`
202
- - `secure_defaults[]`
203
- - `tests_created[]`
204
-
205
- #### F. Stop Conditions
206
- - Path collision.
207
- - Unsupported runtime/template.
208
-
209
- #### G. Safety Constraints
210
- - Must not overwrite existing files without explicit confirmation.
211
-
212
- ### /fix
213
- #### A. Intent
214
- Apply the smallest safe change that resolves a verified defect.
215
-
216
- #### B. When to Use
217
- Use for bugs with reproducible evidence.
218
-
219
- #### C. Required Inputs
220
- - Defect description
221
- - Reproduction steps or failing test
222
- - Target scope
223
-
224
- #### D. Deterministic Execution Flow
225
- 1. Validate defect evidence.
226
- 2. Reproduce failure condition.
227
- 3. Locate root cause.
228
- 4. Generate minimal patch.
229
- 5. Execute targeted validation.
230
- 6. Emit fix report.
231
-
232
- #### E. Structured Output Template
233
- - `defect_id`
234
- - `root_cause`
235
- - `patch_summary`
236
- - `files_changed[]`
237
- - `validation_results[]`
238
-
239
- #### F. Stop Conditions
240
- - Failure cannot be reproduced.
241
- - Root cause unresolved.
242
-
243
- #### G. Safety Constraints
244
- - Must not broaden scope beyond defect boundary.
245
-
246
- ### /refactor
247
- #### A. Intent
248
- Improve internal structure without changing externally observable behavior.
249
-
250
- #### B. When to Use
251
- Use for maintainability, readability, and modularity improvements.
252
-
253
- #### C. Required Inputs
254
- - Target component/module
255
- - Non-functional goals
256
- - Behavior invariants
257
-
258
- #### D. Deterministic Execution Flow
259
- 1. Capture behavior invariants.
260
- 2. Identify refactor units.
261
- 3. Apply transformations incrementally.
262
- 4. Run invariant checks after each unit.
263
- 5. Produce delta and complexity impact.
264
- 6. Emit refactor report.
265
-
266
- #### E. Structured Output Template
267
- - `target`
268
- - `invariants[]`
269
- - `transformations[]`
270
- - `behavior_check_results[]`
271
- - `complexity_delta`
272
-
273
- #### F. Stop Conditions
274
- - Invariant violation.
275
- - Missing behavior baseline.
276
-
277
- #### G. Safety Constraints
278
- - Must abort on behavior change risk.
279
-
280
- ### /audit
281
- #### A. Intent
282
- Run structured engineering audit across security, correctness, and maintainability.
283
-
284
- #### B. When to Use
285
- Use before high-impact merges, releases, or external reviews.
286
-
287
- #### C. Required Inputs
288
- - Audit scope
289
- - Risk profile
290
- - Compliance/security baseline
291
- - Hardening profile requirement (if applicable)
292
-
293
- #### D. Deterministic Execution Flow
294
- 1. Resolve audit scope.
295
- 2. Run static checks.
296
- 3. Run security rule checks.
297
- 4. Run dependency and configuration checks.
298
- 5. Verify hardening evidence when hardening-required profile applies.
299
- 6. Classify findings by severity.
300
- 7. Emit audit report.
301
-
302
- #### E. Structured Output Template
303
- - `scope`
304
- - `checks_executed[]`
305
- - `findings[]`
306
- - `severity_summary`
307
- - `remediation_plan[]`
308
- - `hardening_evidence_status`
309
-
310
- #### F. Stop Conditions
311
- - Scope inaccessible.
312
- - Tooling unavailable.
313
-
314
- #### G. Safety Constraints
315
- - Must flag secret leaks and auth bypass as critical.
316
- - Must classify missing hardening verification evidence as release-blocking when hardening is required.
317
-
318
- ### /perf
319
- #### A. Intent
320
- Evaluate and optimize performance using measurable baselines.
321
-
322
- #### B. When to Use
323
- Use when latency, throughput, memory, or build-time regressions are reported.
324
-
325
- #### C. Required Inputs
326
- - Performance target metrics
327
- - Baseline environment
328
- - Candidate optimization scope
329
-
330
- #### D. Deterministic Execution Flow
331
- 1. Capture baseline metrics.
332
- 2. Identify bottleneck candidates.
333
- 3. Apply one optimization unit.
334
- 4. Re-measure metrics.
335
- 5. Compare against baseline.
336
- 6. Emit performance report.
337
-
338
- #### E. Structured Output Template
339
- - `baseline_metrics`
340
- - `optimization_units[]`
341
- - `post_metrics`
342
- - `regression_check`
343
- - `recommendation`
344
-
345
- #### F. Stop Conditions
346
- - Baseline unavailable.
347
- - Non-reproducible benchmark.
348
-
349
- #### G. Safety Constraints
350
- - Must not trade security for performance.
351
-
352
- ### /test
353
- #### A. Intent
354
- Generate or execute deterministic test plans and test artifacts.
355
-
356
- #### B. When to Use
357
- Use for feature validation, bug regression, and release readiness.
358
-
359
- #### C. Required Inputs
360
- - Target scope
361
- - Test level (unit/integration/e2e)
362
- - Expected behavior
363
-
364
- #### D. Deterministic Execution Flow
365
- 1. Resolve test scope.
366
- 2. Map behavior to test cases.
367
- 3. Execute or generate tests.
368
- 4. Capture pass/fail artifacts.
369
- 5. Classify failures.
370
- 6. Emit test report.
371
-
372
- #### E. Structured Output Template
373
- - `scope`
374
- - `test_matrix[]`
375
- - `execution_results[]`
376
- - `coverage_delta`
377
- - `failures[]`
378
-
379
- #### F. Stop Conditions
380
- - Test runtime unavailable.
381
- - Scope undefined.
382
-
383
- #### G. Safety Constraints
384
- - Must not mark success if critical tests are skipped.
385
-
386
- ### /pr
387
- #### A. Intent
388
- Prepare a deterministic pull request payload with implementation evidence.
389
-
390
- #### B. When to Use
391
- Use after code changes are validated and ready for review.
392
-
393
- #### C. Required Inputs
394
- - Change summary
395
- - Linked issues/tasks
396
- - Validation evidence
397
-
398
- #### D. Deterministic Execution Flow
399
- 1. Collect changed files.
400
- 2. Summarize change intent and impact.
401
- 3. Attach test/audit evidence.
402
- 4. Classify risk and rollout impact.
403
- 5. Generate reviewer checklist.
404
- 6. Emit PR package.
405
-
406
- #### E. Structured Output Template
407
- - `title`
408
- - `summary`
409
- - `files_changed[]`
410
- - `validation_evidence[]`
411
- - `risk_assessment`
412
- - `review_checklist[]`
413
-
414
- #### F. Stop Conditions
415
- - Missing validation evidence.
416
- - Unresolved high severity issues.
417
-
418
- #### G. Safety Constraints
419
- - Must block PR package when critical findings remain open.
420
-
421
- ### /release
422
- #### A. Intent
423
- Produce deterministic release decision and rollout contract.
424
-
425
- #### B. When to Use
426
- Use when promoting validated changes to release channels.
427
-
428
- #### C. Required Inputs
429
- - Version/tag target
430
- - Change manifest
431
- - Rollback strategy
432
- - Hardening verification evidence (when required by risk profile)
433
-
434
- #### D. Deterministic Execution Flow
435
- 1. Validate release prerequisites.
436
- 2. Validate migration and compatibility risks.
437
- 3. Validate security/test gates.
438
- 4. Validate hardening verification evidence when hardening-required profile applies.
439
- 5. Build release notes.
440
- 6. Build rollout and rollback steps.
441
- 7. Emit release contract.
442
-
443
- #### E. Structured Output Template
444
- - `version`
445
- - `release_readiness`
446
- - `gates[]`
447
- - `rollout_plan[]`
448
- - `rollback_plan[]`
449
- - `release_notes`
450
- - `hardening_verification`
451
-
452
- #### F. Stop Conditions
453
- - Gate failure.
454
- - Missing rollback strategy.
455
-
456
- #### G. Safety Constraints
457
- - Must block release if any critical gate fails.
458
- - Must block release when required hardening evidence is missing.
459
-
460
- ### /docs
461
- #### A. Intent
462
- Generate or update documentation with traceable alignment to implemented behavior.
463
-
464
- #### B. When to Use
465
- Use when code, APIs, workflows, or operations change.
466
-
467
- #### C. Required Inputs
468
- - Documentation scope
469
- - Source changes
470
- - Target audience
471
-
472
- #### D. Deterministic Execution Flow
473
- 1. Resolve source-of-truth artifacts.
474
- 2. Extract behavior/API deltas.
475
- 3. Map deltas to docs sections.
476
- 4. Apply concise updates.
477
- 5. Validate examples/commands.
478
- 6. Emit docs change report.
479
-
480
- #### E. Structured Output Template
481
- - `scope`
482
- - `sources[]`
483
- - `sections_updated[]`
484
- - `example_validation`
485
- - `follow_up_actions[]`
486
-
487
- #### F. Stop Conditions
488
- - Source artifacts missing.
489
- - Behavioral ambiguity unresolved.
490
-
491
- #### G. Safety Constraints
492
- - Must not publish secrets, tokens, or internal credentials.
493
-
494
- ----------------------------------------
495
- 4. SAFETY & DESTRUCTIVE ACTION FRAMEWORK
496
- ----------------------------------------
497
-
498
- The agent must enforce the following hard rules:
499
-
500
- 1. Production database drops are prohibited by default.
501
- - Require explicit token: `CONFIRM-DESTRUCTIVE:prod-db-drop`.
502
- - Require backup verification artifact before execution.
503
-
504
- 2. Secret exposure is prohibited.
505
- - Never output full secrets, API keys, private tokens, or credentials.
506
- - Redact using fixed mask pattern: `****REDACTED****`.
507
-
508
- 3. Mass deletions are prohibited without threshold and confirmation.
509
- - If deletion target count > 20 files, block and escalate.
510
- - Require explicit token: `CONFIRM-DESTRUCTIVE:mass-delete`.
511
-
512
- 4. Forced migrations are prohibited by default.
513
- - Block destructive/irreversible migrations without rollback artifact.
514
- - Require explicit token: `CONFIRM-DESTRUCTIVE:forced-migration`.
515
-
516
- 5. Security bypass is prohibited.
517
- - Never disable authentication, authorization, validation, or rate limiting to pass checks.
518
-
519
- 6. Dependency upgrades require impact analysis.
520
- - Must provide compatibility matrix, changelog risk scan, and test impact summary.
521
- - If missing, set `status: blocked`.
522
-
523
- ----------------------------------------
524
- 5. FAILURE MODES
525
- ----------------------------------------
526
-
527
- ### Insufficient Context
528
- 1. Return `status: blocked`.
529
- 2. Return `blocker_type: insufficient_context`.
530
- 3. Request only decision-critical missing inputs.
531
-
532
- ### Conflicting Instructions
533
- 1. Return `status: blocked`.
534
- 2. Return `blocker_type: conflicting_instructions`.
535
- 3. List conflicts with deterministic precedence order:
536
- - Safety rules
537
- - Explicit non-negotiable constraints
538
- - Command contract
539
- - Secondary preferences
540
-
541
- ### High-Risk Change Detected
542
- 1. Return `status: blocked` unless explicit confirmation token is present.
543
- 2. Return `blocker_type: high_risk_change`.
544
- 3. Provide `safe_alternative` path.
545
-
546
- ### Unknown Framework Detected
547
- 1. Return `status: blocked`.
548
- 2. Return `blocker_type: unknown_framework`.
549
- 3. Fallback to technology-agnostic baseline rules from `agent-docs/ARCHITECTURE.md` and request minimum framework metadata.
550
-
551
- ----------------------------------------
552
- 6. EXAMPLE USAGE
553
- ----------------------------------------
554
-
555
- ### Example 1
556
- User input:
557
- `/plan objective="Implement deterministic slash commands" scope="AGENTS docs only" constraints="security,test"`
558
-
559
- Expected output structure:
560
- - `command: /plan`
561
- - `execution_id: <uuid>`
562
- - `mode: slash-command`
563
- - `status: completed`
564
- - `inputs: {...}`
565
- - `prechecks: [...]`
566
- - `execution_log: [...]`
567
- - `artifacts: { plan_summary, work_units, dependency_graph }`
568
- - `risks: [...]`
569
- - `safety_checks: [...]`
570
- - `stop_condition: none`
571
- - `next_action: /task`
572
-
573
- ### Example 2
574
- User input:
575
- `/fix defect="Null pointer in auth middleware" evidence="failing test auth.middleware.spec"`
576
-
577
- Expected output structure:
578
- - `command: /fix`
579
- - `execution_id: <uuid>`
580
- - `mode: slash-command`
581
- - `status: completed|blocked`
582
- - `inputs: {...}`
583
- - `prechecks: [...]`
584
- - `execution_log: [...]`
585
- - `artifacts: { root_cause, patch_summary, files_changed, validation_results }`
586
- - `risks: [...]`
587
- - `safety_checks: [...]`
588
- - `stop_condition: <reason|null>`
589
- - `next_action: /test`
590
-
591
- ### Example 3
592
- User input:
593
- `/release version="v2.4.0"`
594
-
595
- Expected output structure:
596
- - `command: /release`
597
- - `execution_id: <uuid>`
598
- - `mode: slash-command`
599
- - `status: blocked` (if any gate fails)
600
- - `inputs: {...}`
601
- - `prechecks: [...]`
602
- - `execution_log: [...]`
603
- - `artifacts: { release_readiness, gates, rollout_plan, rollback_plan }`
604
- - `risks: [...]`
605
- - `safety_checks: [...]`
606
- - `stop_condition: gate_failure|none`
607
- - `next_action: resolve_failed_gates`
608
-
609
- ## Critical Rules (Always Apply)
610
-
611
- ### Security-First Development
612
- - **Validate all inputs** at application boundaries with schema validation
613
- - **Authenticate and authorize** every protected endpoint
614
- - **Rate limit** public endpoints to prevent abuse
615
- - **Sanitize outputs** to prevent injection attacks
616
- - **Never expose sensitive data** in error messages or logs
617
-
618
- ### Testing Requirements
619
- - **Unit tests**: 80% coverage for business logic
620
- - **Integration tests**: 15% coverage for API endpoints and database operations
621
- - **E2E tests**: 5% coverage for critical user journeys
622
- - **Accessibility tests**: WCAG 2.1 AA compliance for all UI
623
-
624
- ### Code Quality
625
- - **Type safety**: Use strong typing, validate at boundaries
626
- - **Performance**: Monitor bundle/binary size, implement lazy loading
627
- - **Accessibility**: WCAG 2.1 AA compliance for user-facing components
628
- - **Documentation**: Keep README, agent-docs/ARCHITECTURE.md, and AGENTS.MD updated
629
-
630
- ## Architecture Principles
631
-
632
- - **Technology-agnostic**: Adapt patterns to chosen technology stack
633
- - **Security-first**: Always consider security implications first
634
- - **Feature-oriented**: Group by domain/feature, not just technical layer
635
- - **Type-safe**: Strong typing with runtime validation at boundaries
636
- - **Test-driven**: Comprehensive testing at all levels
637
-
638
- ## Quick Reference
639
-
640
- ### For UI/Design Work
641
- → Apply `agents/rules/frontend.mdc` patterns
642
- → Ensure accessibility compliance
643
-
644
- ### For API/Business Logic
645
- → Apply `agents/rules/security.mdc` for authentication/validation
646
- → Apply `agents/rules/testing.mdc` for test coverage
647
-
648
- ### For Database Work
649
- → Apply `agents/rules/database.mdc` patterns
650
- → Use ORM/ODM patterns, avoid raw queries
651
-
652
- ### For Security Reviews
653
- → Apply `agents/rules/security.mdc` comprehensively
654
- → Apply `agents/rules/hardening.mdc` for hardening profile and obfuscation decisions
655
- → Check OWASP Top 10 compliance
656
-
657
- ## When in Doubt
658
-
659
- 1. Review `agent-docs/ARCHITECTURE.md` for architecture decisions
660
- 2. Reference the specific `agents/rules/*.mdc` file for detailed patterns
661
- 3. Always prioritize security and testing requirements
662
-
663
- ---
664
-
665
- **Remember**: This is a technology-agnostic template. Adapt all patterns to the chosen technology stack while maintaining the core principles of security, testing, and code quality.