agents-templated 2.2.0 → 2.2.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.
Files changed (49) hide show
  1. package/README.md +9 -9
  2. package/bin/cli.js +9 -9
  3. package/index.js +12 -1
  4. package/lib/instructions.js +20 -6
  5. package/lib/layout.js +3 -2
  6. package/package.json +1 -1
  7. package/templates/{agents/subagents → .claude/agents}/README.md +2 -2
  8. package/templates/.claude/rules/ai-integration.mdc +60 -0
  9. package/templates/.claude/rules/core.mdc +180 -0
  10. package/templates/.claude/rules/database.mdc +291 -0
  11. package/templates/.claude/rules/frontend.mdc +224 -0
  12. package/templates/.claude/rules/guardrails.mdc +105 -0
  13. package/templates/.claude/rules/hardening.mdc +58 -0
  14. package/templates/.claude/rules/intent-routing.mdc +59 -0
  15. package/templates/.claude/rules/planning.mdc +75 -0
  16. package/templates/.claude/rules/security.mdc +286 -0
  17. package/templates/.claude/rules/style.mdc +306 -0
  18. package/templates/.claude/rules/system-workflow.mdc +69 -0
  19. package/templates/.claude/rules/testing.mdc +308 -0
  20. package/templates/.claude/rules/workflows.mdc +61 -0
  21. package/templates/.cursorrules +2 -5
  22. package/templates/CLAUDE.md +37 -37
  23. package/templates/README.md +3 -3
  24. package/templates/agent-docs/ARCHITECTURE.md +3 -3
  25. package/templates/agent-docs/README.md +12 -13
  26. package/templates/agents/rules/ai-integration.mdc +10 -2
  27. package/templates/agents/rules/core.mdc +8 -1
  28. package/templates/agents/rules/database.mdc +10 -2
  29. package/templates/agents/rules/frontend.mdc +10 -2
  30. package/templates/agents/rules/guardrails.mdc +10 -2
  31. package/templates/agents/rules/hardening.mdc +10 -2
  32. package/templates/agents/rules/intent-routing.mdc +10 -2
  33. package/templates/agents/rules/planning.mdc +10 -2
  34. package/templates/agents/rules/security.mdc +11 -2
  35. package/templates/agents/rules/style.mdc +10 -2
  36. package/templates/agents/rules/system-workflow.mdc +10 -2
  37. package/templates/agents/rules/testing.mdc +9 -1
  38. package/templates/agents/rules/workflows.mdc +10 -2
  39. package/templates/agents/skills/README.md +6 -6
  40. package/templates/instructions/source/core.md +0 -219
  41. /package/templates/{agents/subagents → .claude/agents}/architect.md +0 -0
  42. /package/templates/{agents/subagents → .claude/agents}/build-error-resolver.md +0 -0
  43. /package/templates/{agents/subagents → .claude/agents}/code-reviewer.md +0 -0
  44. /package/templates/{agents/subagents → .claude/agents}/doc-updater.md +0 -0
  45. /package/templates/{agents/subagents → .claude/agents}/e2e-runner.md +0 -0
  46. /package/templates/{agents/subagents → .claude/agents}/planner.md +0 -0
  47. /package/templates/{agents/subagents → .claude/agents}/refactor-cleaner.md +0 -0
  48. /package/templates/{agents/subagents → .claude/agents}/security-reviewer.md +0 -0
  49. /package/templates/{agents/subagents → .claude/agents}/tdd-guide.md +0 -0
@@ -0,0 +1,59 @@
1
+ ---
2
+ title: "Intent Routing & Command Selection"
3
+ description: "Apply when determining which rule or workflow applies to the user's request. Ensures correct execution pathway"
4
+ version: "1.0.0"
5
+ tags: ["routing", "deterministic", "workflow", "commands"]
6
+ triggers:
7
+ - "Ambiguous or multi-intent user request"
8
+ - "Need to route to correct rule or workflow"
9
+ - "Destructive action requested"
10
+ - "Scope expansion detected"
11
+ ---
12
+
13
+ ## Purpose
14
+
15
+ Provide deterministic routing from user intent to the correct execution pathway, with minimal clarification and strict safety behavior.
16
+
17
+ ## Deterministic Routing Contract
18
+
19
+ 1. Normalize input (trim, collapse whitespace, preserve semantic tokens).
20
+ 2. Detect explicit slash command first.
21
+ 3. If no slash command, run implicit intent routing against known command set.
22
+ 4. Select exactly one command only when confidence is sufficient.
23
+ 5. If ambiguous, return blocked output with decision-critical missing fields.
24
+ 6. Never execute destructive actions without confirmation token.
25
+
26
+ ## Confidence & Ambiguity Rules
27
+
28
+ - High confidence: execute selected contract.
29
+ - Medium confidence: execute with explicit assumptions in output.
30
+ - Low confidence: return `status: blocked` with 1-2 critical clarifications.
31
+ - Multi-intent input: split into ordered tasks only when boundaries are explicit; otherwise block.
32
+
33
+ ## Minimal Clarification Policy
34
+
35
+ - Ask questions only when unsafe or logically blocked.
36
+ - Ask at most 2 questions per command cycle.
37
+ - Questions must be single-purpose and decision-critical.
38
+
39
+ ## Structured Output Defaults
40
+
41
+ All routed executions must return schema-compliant output:
42
+ - `command`, `execution_id`, `mode`, `status`, `inputs`
43
+ - `prechecks`, `execution_log`, `artifacts`
44
+ - `risks`, `safety_checks`, `stop_condition`, `next_action`
45
+
46
+ ## Safety Behavior
47
+
48
+ - Unknown slash command: structured error and stop.
49
+ - Ambiguous non-slash intent: blocked with minimal missing inputs.
50
+ - High-risk actions: blocked until explicit confirmation token is present.
51
+
52
+ ## Guardrails Cross-Reference
53
+
54
+ When intent involves scope expansion, destructive actions, or agent behavioral safety, apply `.claude/rules/guardrails.mdc` in addition to the primary route:
55
+
56
+ - Scope creep detected → Guardrails § Scope Control
57
+ - Destructive/irreversible action → Guardrails § Hard Stops + Reversibility Principle
58
+ - Agent accessing external systems beyond task scope → Guardrails § Minimal Footprint
59
+ - Repeated failure / silent retry → Guardrails § No Autonomous Escalation
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: "Planning Discipline"
3
+ description: "Apply when implementing features, designing systems, or making architectural decisions that affect future work"
4
+ version: "1.0.0"
5
+ tags: ["planning", "workflow", "documentation", "prompts"]
6
+ alwaysApply: true
7
+ triggers:
8
+ - "User asks to implement a new feature"
9
+ - "Making design or architecture decisions"
10
+ - "Planning a significant refactor"
11
+ - "Fixing bugs that require investigation"
12
+ - "Discussion produces decisions affecting architecture"
13
+ ---
14
+
15
+ ## Purpose
16
+
17
+ Ensure every feature discussion, design decision, or implementation produces a reusable prompt plan stored in `.github/prompts/`. Plans persist across sessions and serve as living context for future work — they are never discarded.
18
+
19
+ ## When to Apply
20
+
21
+ This rule is always active. Trigger when:
22
+
23
+ - User asks to implement a new feature
24
+ - A design or architecture decision is being made
25
+ - A significant refactor is planned
26
+ - A bug fix requires non-trivial investigation or systemic changes
27
+ - A discussion produces decisions that affect future work
28
+
29
+ ## Plan File Convention
30
+
31
+ **Location:** `.github/prompts/`
32
+ **Filename:** `YYYY-MM-DD-{feature-slug}.prompt.md`
33
+ **Format:** VS Code reusable prompt (`.prompt.md` — usable as an `@workspace` prompt in Copilot Chat)
34
+
35
+ ## Required Sections
36
+
37
+ Each plan file must contain:
38
+
39
+ ```
40
+ ---
41
+ mode: agent
42
+ description: One-line summary of what this plan covers.
43
+ ---
44
+
45
+ ## Context
46
+ Brief background — what problem are we solving and why now.
47
+
48
+ ## Decision
49
+ What we decided to do and the reasoning behind it (not just what, but why).
50
+
51
+ ## Steps
52
+ Numbered implementation steps in dependency order.
53
+
54
+ ## Acceptance Criteria
55
+ Concrete, testable outcomes that define "done".
56
+
57
+ ## Status
58
+ - [ ] Not started / [ ] In progress / [x] Complete
59
+ Blockers (if any):
60
+ ```
61
+
62
+ ## Workflow
63
+
64
+ 1. At the start of any feature discussion or implementation, create the plan file immediately.
65
+ 2. Use the filename convention: `YYYY-MM-DD-{feature-slug}.prompt.md`.
66
+ 3. Fill out **Context**, **Decision**, and **Steps** before starting implementation.
67
+ 4. Update **Status** and **Acceptance Criteria** incrementally as work progresses.
68
+ 5. Mark the plan complete when implementation is verified and accepted.
69
+
70
+ ## Guardrails
71
+
72
+ - Do not skip plan creation for "small" features — small decisions accumulate into undocumented technical debt.
73
+ - Plans are never deleted — they form a historical record of architectural decisions.
74
+ - Plan files must not contain secrets, credentials, or PII.
75
+ - If a plan changes significantly mid-implementation, update it in place rather than creating a new one.
@@ -0,0 +1,286 @@
1
+ ---
2
+ title: "Security Rules & Best Practices"
3
+ description: "Apply when implementing authentication, authorization, API validation, secrets management, or protecting against OWASP Top 10 vulnerabilities"
4
+ alwaysApply: true
5
+ version: "3.0.0"
6
+ tags: ["security", "auth", "validation", "secrets", "owasp"]
7
+ triggers:
8
+ - "User adds login/authentication to project"
9
+ - "Building API endpoints or handling user input"
10
+ - "Storing passwords, tokens, or sensitive data"
11
+ - "Validating form inputs or API requests"
12
+ - "Protecting against injection, XSS, CSRF"
13
+ - "Adding authorization/permissions to endpoints"
14
+ - "Integrating third-party APIs or external services"
15
+ ---
16
+
17
+ # Security Rules & Best Practices
18
+
19
+ You are an expert security-focused developer implementing security-first development regardless of technology stack.
20
+
21
+ ## Core Security Principles
22
+
23
+ - **Defense in Depth**: Implement multiple layers of security controls
24
+ - **Least Privilege**: Grant minimum necessary permissions for each role/service
25
+ - **Input Validation**: Validate all inputs at boundaries with appropriate schema validation
26
+ - **Output Encoding**: Encode all outputs to prevent injection attacks
27
+ - **Secure by Default**: Choose secure configurations over convenience
28
+ - **Fail Securely**: Default to denial, require explicit allow
29
+
30
+ ## Authentication & Authorization Patterns
31
+
32
+ ### Session Management Best Practices
33
+
34
+ Implement secure session handling regardless of framework:
35
+ - **Session storage**: Use secure cookies (HttpOnly, Secure, SameSite) or JWT tokens
36
+ - **Token expiration**: Implement appropriate timeout for token validity
37
+ - **Refresh tokens**: Separate long-lived and short-lived tokens
38
+ - **Session invalidation**: Properly terminate sessions on logout
39
+ - **CSRF protection**: Verify request origin for state-changing operations
40
+
41
+ ### Authentication Patterns (Language-Agnostic)
42
+
43
+ Authentication Flow:
44
+ 1. User provides credentials (username/password)
45
+ 2. Validate credentials against hashed password in database
46
+ 3. Create session or JWT token with user identity
47
+ 4. Return session/token to client with secure flags
48
+ 5. Client includes token/session in subsequent requests
49
+ 6. Server validates token/session on each request
50
+ 7. Extract user identity from verified token/session
51
+
52
+ **Key Requirements:**
53
+ - Hash passwords with strong algorithms (bcrypt, scrypt, argon2)
54
+ - Salt rounds: 12+ for bcrypt
55
+ - Never store plaintext passwords
56
+ - Implement rate limiting on authentication endpoints
57
+ - Log authentication attempts (failures especially)
58
+ - Provide clear error messages that don't leak user information
59
+
60
+ ### Authorization Patterns (Language-Agnostic)
61
+
62
+ Authorization Flow:
63
+ 1. Extract user identity from authenticated session/token
64
+ 2. For each protected operation:
65
+ a. Check if user is authenticated
66
+ b. Retrieve user's roles/permissions from database
67
+ c. Verify required permissions for operation
68
+ d. Allow or deny based on permission check
69
+ 3. Log authorization checks (especially failures)
70
+ 4. Return appropriate error for denied access
71
+
72
+ **Role-Based Access Control (RBAC):**
73
+ - Define roles with clear permissions (admin, moderator, user, guest)
74
+ - Assign roles to users (can be multiple)
75
+ - Check user's roles before allowing sensitive operations
76
+ - Implement at API boundaries and critical business logic
77
+ - Audit role changes and permission checks
78
+
79
+ ## Input Validation & Sanitization
80
+
81
+ ### Validation Strategy (Technology-Agnostic)
82
+
83
+ Validate all user inputs at API boundaries:
84
+
85
+ Validation Process:
86
+ 1. Define schema/rules for each input
87
+ - Data type (string, number, boolean, date, etc.)
88
+ - Length constraints (min/max)
89
+ - Format requirements (regex patterns)
90
+ - Allowed values (whitelist)
91
+ - Required fields
92
+
93
+ 2. Validate incoming data against schema
94
+ - Reject invalid data with clear error messages
95
+ - Never modify user input, reject or accept
96
+
97
+ 3. Transform/normalize data if needed
98
+ - Trim whitespace
99
+ - Convert to lowercase/uppercase as appropriate
100
+ - Parse dates to consistent format
101
+
102
+ 4. Return validation result
103
+ - Success with validated data
104
+ - Failure with specific field errors
105
+
106
+ **Common Validation Rules:**
107
+ - Email: Valid format using standardized validation, convert to lowercase
108
+ - Password: Minimum 8 characters, complexity requirements (uppercase, lowercase, number, special)
109
+ - Names: 2-100 characters, alphanumeric with spaces allowed
110
+ - URLs: Valid URL format for whitelist only
111
+ - Phone: Valid format for your region
112
+ - User IDs: UUID v4 format or similar non-sequential identifiers
113
+
114
+ ### Special Input Handling
115
+
116
+ **File Uploads:**
117
+ - Validate file content type (MIME type check from file content, not extension)
118
+ - Enforce size limits (max upload size)
119
+ - Scan for malware when possible
120
+ - Store outside web root
121
+ - No execute permission on upload directory
122
+ - Serve with inline=false to force download
123
+
124
+ **API Parameters:**
125
+ - Validate query parameters with same rules as request body
126
+ - Whitelist allowed parameters per endpoint
127
+ - Validate pagination limits (max 100-1000 items)
128
+ - Validate sort fields against whitelist
129
+
130
+ **Database Queries:**
131
+ - Use ORM/parameterized queries only (never string concatenation)
132
+ - Filter results to authenticated user's data
133
+ - Limit results with pagination
134
+ - Monitor for suspicious query patterns
135
+
136
+ ## Rate Limiting & DoS Protection
137
+
138
+ ### Rate Limiting Strategy
139
+
140
+ Implement rate limiting on sensitive endpoints:
141
+
142
+ Rate Limiting Levels:
143
+ - Authentication endpoints: 5 attempts per 15 minutes per IP
144
+ - API endpoints: 100-1000 requests per hour per user/IP
145
+ - Public endpoints: 1000+ requests per hour per IP
146
+ - Critical operations: 1 attempt per minute per user
147
+
148
+ **Implementation approach:**
149
+ - Use Redis or similar for distributed rate limiting
150
+ - Track by IP address, user ID, or API key depending on endpoint
151
+ - Return 429 (Too Many Requests) when limit exceeded
152
+ - Include retry-after header in response
153
+ - Log rate limit violations
154
+
155
+ ## OWASP Top 10 Protection
156
+
157
+ ### A01: Broken Access Control
158
+ - Implement authentication on all protected endpoints
159
+ - Check authorization for current user before returning data
160
+ - Use role-based access control with clear permission model
161
+ - Validate user can only access their own data
162
+ - Log authorization failures for security monitoring
163
+
164
+ ### A02: Cryptographic Failures
165
+ - Hash passwords with strong algorithms (bcrypt, scrypt, argon2)
166
+ - Use HTTPS in production for all communications
167
+ - Store secrets in environment variables, never in code
168
+ - Use secure cookie flags (HttpOnly, Secure, SameSite)
169
+ - Encrypt sensitive data at rest when appropriate
170
+
171
+ ### A03: Injection
172
+ - Use ORM/parameterized queries only (no string concatenation)
173
+ - Validate all inputs with schema/whitelist approach
174
+ - Encode output data in appropriate context (HTML, URL, etc.)
175
+ - Implement Content Security Policy headers
176
+ - Use prepared statements for database queries
177
+
178
+ ### A04: Insecure Design
179
+ - Implement authentication and authorization from start
180
+ - Rate limit authentication endpoints
181
+ - Validate input at every API boundary
182
+ - Design with fail-secure defaults
183
+ - Implement comprehensive error handling
184
+
185
+ ### A05: Security Misconfiguration
186
+ - Run only necessary services/features
187
+ - Implement all security headers (CSP, X-Frame-Options, HSTS, etc.)
188
+ - Update frameworks and dependencies regularly
189
+ - Remove default accounts and credentials
190
+ - Validate environment variables at startup
191
+
192
+ ### A06: Vulnerable Components
193
+ - Keep dependencies updated with security patches
194
+ - Use lock files (package-lock.json, requirements.txt, etc.)
195
+ - Regularly scan dependencies for vulnerabilities
196
+ - Remove unused dependencies
197
+ - Only use supported versions of frameworks
198
+
199
+ ### A07: Authentication Failure
200
+ - Implement strong password requirements
201
+ - Use rate limiting on authentication endpoints
202
+ - Hash passwords securely (bcrypt, scrypt, argon2)
203
+ - Implement session timeouts
204
+ - Log authentication attempts
205
+
206
+ ### A08: Data Integrity Failures
207
+ - Validate all input data with schema validation
208
+ - Implement proper error handling
209
+ - Log integrity violation attempts
210
+ - Use strong checksums/hashes for critical data
211
+ - Implement database constraints
212
+
213
+ ### A09: Logging and Monitoring Failure
214
+ - Log authentication and authorization events
215
+ - Log sensitive operations and data access
216
+ - Monitor for suspicious patterns
217
+ - Keep logs secure and don't expose sensitive info
218
+ - Alert on security-relevant events
219
+
220
+ ### A10: SSRF (Server-Side Request Forgery)
221
+ - Validate and whitelist URLs that application accesses
222
+ - Implement network-level restrictions
223
+ - Disable unused URL schemes
224
+ - Implement timeouts on external requests
225
+ - Log and monitor external API calls
226
+
227
+ ## Environment & Secrets Management
228
+
229
+ ### Environment Variables
230
+
231
+ Environment Variable Validation Pattern:
232
+ 1. Define all required variables with types
233
+ 2. Load from .env file or environment not from code
234
+ 3. Validate all variables exist at startup
235
+ 4. Validate all variables are correct type/format
236
+ 5. Provide clear error if validation fails
237
+ 6. Never log or expose environment variables
238
+
239
+ **Sensitive Variables:**
240
+ - Database credentials (URL, passwords)
241
+ - API keys and secrets
242
+ - Encryption keys
243
+ - Authentication secrets (session secret, JWT secret)
244
+ - Third-party service credentials
245
+
246
+ No sensitive variables should ever be:
247
+ - Committed to version control
248
+ - Logged (even in debug logs)
249
+ - Exposed in error messages
250
+ - Included in client-side code
251
+ - Transmitted in URLs
252
+
253
+ ## Application Hardening & Obfuscation
254
+
255
+ - Treat obfuscation as **defense in depth**, not a replacement for authentication, authorization, secrets hygiene, or validation.
256
+ - Apply hardening selectively by risk profile, especially for distributed clients (mobile/desktop/browser) and high-value IP logic.
257
+ - Integrate hardening into build/release flow and require post-hardening functional regression and performance checks.
258
+ - Protect symbol/mapping/debug artifacts with restricted access and secure retention policies.
259
+ - Require reproducible builds and a clear rollback path for hardened releases.
260
+
261
+ ## Security Checklist
262
+
263
+ Before deploying to production:
264
+
265
+ - [ ] All inputs validated with schema validation
266
+ - [ ] Password hashing implemented with strong algorithm
267
+ - [ ] Rate limiting on authentication endpoints
268
+ - [ ] HTTPS enforced in production
269
+ - [ ] Security headers configured
270
+ - [ ] Environment variables validated at startup
271
+ - [ ] No sensitive data in logs
272
+ - [ ] Database queries use ORM (no raw SQL)
273
+ - [ ] Authorization checks on protected endpoints
274
+ - [ ] Error messages don't leak sensitive information
275
+ - [ ] External API calls use HTTPS
276
+ - [ ] Dependencies scanned for vulnerabilities
277
+ - [ ] Unused dependencies removed
278
+ - [ ] Dead code removed
279
+ - [ ] Secrets never committed to version control
280
+ - [ ] Session/token timeouts configured
281
+ - [ ] CSRF protection implemented (if applicable)
282
+
283
+ ---
284
+
285
+ Remember: **Security must be built in from the beginning, not added as an afterthought.**
286
+ Every feature should consider security implications, and every developer should understand these principles.