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
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm version](https://img.shields.io/npm/v/agents-templated.svg)](https://www.npmjs.com/package/agents-templated)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/agents-templated.svg)](https://www.npmjs.com/package/agents-templated)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
- [![GitHub stars](https://img.shields.io/github/stars/rickandrew2/agents-projects-templated?style=social)](https://github.com/rickandrew2/agents-templated)
6
+ [![GitHub stars](https://img.shields.io/github/stars/rickandrew2/agents-templated?style=social)](https://github.com/rickandrew2/agents-templated)
7
7
 
8
8
  > **Agents Templated** is a CLI tool and npm package that instantly scaffolds production-ready project structures with enterprise-grade development patterns, security guidelines, and AI assistant configurations. Designed for developers who want to start projects the right way—with proven OWASP security practices, comprehensive testing strategies (80/15/5 coverage targets), and agent-based architecture patterns—without being locked into specific frameworks. It generates unified configuration files that work seamlessly with Cursor, GitHub Copilot, Claude, and Google Gemini, allowing AI assistants to automatically follow best practices from day one. Whether you're building a Next.js app, Django API, Go microservice, or any custom stack, Agents Templated provides the guardrails and patterns you need while giving you complete freedom to choose your technology.
9
9
 
@@ -28,13 +28,13 @@ Agents Templated scaffolds your project with:
28
28
  - Deterministic slash-command standard in `AGENTS.MD` and modular contracts in `agents/commands/`
29
29
  - Implicit natural-language routing support (`slash-command-auto`) for non-technical prompts
30
30
  - New workflow/routing/hardening rule set:
31
- - `agents/rules/intent-routing.mdc`
32
- - `agents/rules/system-workflow.mdc`
33
- - `agents/rules/hardening.mdc`
31
+ - `.github/instructions/rules/intent-routing.mdc`
32
+ - `.github/instructions/rules/system-workflow.mdc`
33
+ - `.github/instructions/rules/hardening.mdc`
34
34
  - New baseline skills:
35
- - `agents/skills/feature-delivery/`
36
- - `agents/skills/bug-triage/`
37
- - `agents/skills/app-hardening/`
35
+ - `.github/skills/feature-delivery/`
36
+ - `.github/skills/bug-triage/`
37
+ - `.github/skills/app-hardening/`
38
38
  - Release and audit contracts now require hardening evidence when risk profile requires it
39
39
 
40
40
  ---
@@ -124,7 +124,7 @@ Agents Templated automatically configures compatible wrappers for major AI codin
124
124
  | **Claude** | `CLAUDE.md` | ✅ Compatible |
125
125
  | **Generic agents** | `AGENTS.MD` | ✅ Compatible |
126
126
 
127
- **Single source of truth:** `instructions/source/core.md` drives generated tool-compatible instruction files.
127
+ **Single source of truth:** `CLAUDE.md` drives generated tool-compatible instruction files.
128
128
 
129
129
  ---
130
130
 
@@ -421,7 +421,7 @@ await agentsTemplated.install('./my-project', {
421
421
 
422
422
  When contributing to this template:
423
423
  1. Maintain technology-agnostic patterns
424
- 2. Update relevant rule files in `agents/rules/`
424
+ 2. Update relevant rule files in `.github/instructions/rules/`
425
425
  3. Keep documentation synchronized with code changes
426
426
  4. Follow security and testing patterns
427
427
  5. Ensure AI assistant configurations remain compatible
package/bin/cli.js CHANGED
@@ -125,7 +125,7 @@ program
125
125
  { name: 'Agent rules (.github/instructions/rules/*.mdc)', value: 'rules' },
126
126
  { name: 'Skills (.github/skills/*)', value: 'skills' },
127
127
  { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github' },
128
- { name: 'Agent subagents (agents/subagents/*.md)', value: 'subagents' }
128
+ { name: 'Agent subagents (.claude/agents/*.md)', value: 'subagents' }
129
129
  ],
130
130
  default: ['all']
131
131
  },
@@ -190,6 +190,7 @@ program
190
190
  await writeGeneratedInstructions(targetDir, templateDir, options.force);
191
191
  console.log(chalk.gray(' ✓ Claude (CLAUDE.md — canonical source)'));
192
192
  console.log(chalk.gray(' ✓ GitHub Copilot (.github/copilot-instructions.md pointer)'));
193
+ console.log(chalk.gray(' ✓ Cursor (.cursorrules pointer)'));
193
194
  console.log(chalk.gray(' ✓ Generic AGENTS (AGENTS.MD pointer)'));
194
195
  }
195
196
 
@@ -198,7 +199,7 @@ program
198
199
  console.log(chalk.yellow('Installing agent subagents...'));
199
200
  await fs.ensureDir(path.join(targetDir, LAYOUT.canonical.subagentsDir));
200
201
  await copyDirectory(
201
- path.join(templateDir, 'agents', 'subagents'),
202
+ path.join(templateDir, '.claude', 'agents'),
202
203
  path.join(targetDir, LAYOUT.canonical.subagentsDir),
203
204
  options.force
204
205
  );
@@ -257,7 +258,7 @@ program
257
258
  { name: 'Agent Rules (security, testing, database, etc.)', value: 'rules' },
258
259
  { name: 'Skills (reusable agent capabilities)', value: 'skills' },
259
260
  { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github' },
260
- { name: 'Agent subagents (agents/subagents/*.md)', value: 'subagents' }
261
+ { name: 'Agent subagents (.claude/agents/*.md)', value: 'subagents' }
261
262
  ],
262
263
  validate: (answer) => {
263
264
  if (answer.length === 0) {
@@ -294,7 +295,7 @@ program
294
295
  { name: 'Agent Rules (security, testing, database, etc.)', value: 'rules', checked: true },
295
296
  { name: 'Skills (reusable agent capabilities)', value: 'skills', checked: true },
296
297
  { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github', checked: true },
297
- { name: 'Agent subagents (agents/subagents/*.md)', value: 'subagents', checked: true }
298
+ { name: 'Agent subagents (.claude/agents/*.md)', value: 'subagents', checked: true }
298
299
  ],
299
300
  validate: (answer) => {
300
301
  if (answer.length === 0) {
@@ -369,7 +370,7 @@ program
369
370
  console.log(chalk.yellow('Installing agent subagents...'));
370
371
  await fs.ensureDir(path.join(targetDir, LAYOUT.canonical.subagentsDir));
371
372
  await copyDirectory(
372
- path.join(templateDir, 'agents', 'subagents'),
373
+ path.join(templateDir, '.claude', 'agents'),
373
374
  path.join(targetDir, LAYOUT.canonical.subagentsDir),
374
375
  options.force
375
376
  );
@@ -405,7 +406,7 @@ program
405
406
  console.log(chalk.yellow('rules') + ' - Agent rules (.github/instructions/rules/*.mdc)');
406
407
  console.log(chalk.yellow('skills') + ' - Agent skills (.github/skills/*)');
407
408
  console.log(chalk.yellow('github') + ' - AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)');
408
- console.log(chalk.yellow('subagents') + ' - Agent subagents (agents/subagents/*.md)');
409
+ console.log(chalk.yellow('subagents') + ' - Agent subagents (.claude/agents/*.md)');
409
410
  console.log(chalk.yellow('all') + ' - All components');
410
411
 
411
412
  console.log(chalk.blue.bold('\n\nAvailable Presets:\n'));
@@ -653,7 +654,6 @@ async function cleanupLegacyInstructionFiles(targetDir) {
653
654
  // Files removed in v2.0.0: orphaned wrappers that contained duplicated policy
654
655
  // content and were not managed/validated by the generator.
655
656
  const legacyFiles = [
656
- '.cursorrules',
657
657
  '.github/instructions/AGENTS.md',
658
658
  // Pre-v1.2.13 paths
659
659
  '.claude/CLAUDE.md'
@@ -714,7 +714,7 @@ async function updateSelectedComponents(targetDir, templateDir, selectedComponen
714
714
  console.log(chalk.yellow('Updating agent subagents...'));
715
715
  await fs.ensureDir(path.join(targetDir, LAYOUT.canonical.subagentsDir));
716
716
  await copyDirectory(
717
- path.join(templateDir, 'agents', 'subagents'),
717
+ path.join(templateDir, '.claude', 'agents'),
718
718
  path.join(targetDir, LAYOUT.canonical.subagentsDir),
719
719
  overwrite
720
720
  );
@@ -1031,7 +1031,7 @@ program
1031
1031
 
1032
1032
  program
1033
1033
  .command('new-subagent <name>')
1034
- .description('Scaffold a new subagent in agents/subagents/<name>.md')
1034
+ .description('Scaffold a new subagent in .claude/agents/<name>.md')
1035
1035
  .action(async (name) => {
1036
1036
  try {
1037
1037
  const targetDir = process.cwd();
package/index.js CHANGED
@@ -16,12 +16,13 @@ const { CANONICAL_INSTRUCTION_FILE, writeGeneratedInstructions } = require('./li
16
16
  * @param {boolean} options.rules - Install agent rules
17
17
  * @param {boolean} options.skills - Install skills
18
18
  * @param {boolean} options.github - Install GitHub Copilot instructions
19
+ * @param {boolean} options.subagents - Install agent subagents
19
20
  * @param {boolean} options.force - Overwrite existing files
20
21
  * @returns {Promise<void>}
21
22
  */
22
23
  async function install(targetDir, options = {}) {
23
24
  const templateDir = path.join(__dirname, 'templates');
24
- const installAll = !options.docs && !options.rules && !options.skills && !options.github;
25
+ const installAll = !options.docs && !options.rules && !options.skills && !options.github && !options.subagents;
25
26
 
26
27
  const files = [];
27
28
 
@@ -73,6 +74,16 @@ async function install(targetDir, options = {}) {
73
74
  await fs.ensureDir(path.join(targetDir, '.github', 'instructions'));
74
75
  await writeGeneratedInstructions(targetDir, templateDir, options.force);
75
76
  }
77
+
78
+ // Agent subagents (.claude/agents/)
79
+ if (installAll || options.subagents) {
80
+ await fs.ensureDir(path.join(targetDir, '.claude', 'agents'));
81
+ await copyDirectory(
82
+ path.join(templateDir, '.claude', 'agents'),
83
+ path.join(targetDir, '.claude', 'agents'),
84
+ options.force
85
+ );
86
+ }
76
87
  }
77
88
 
78
89
  async function copyDirectory(sourceDir, targetDir, force = false) {
@@ -7,7 +7,8 @@ const CANONICAL_INSTRUCTION_FILE = 'CLAUDE.md';
7
7
  // Thin compatibility pointer files — policy lives in CLAUDE.md, not here.
8
8
  const POINTER_FILES = {
9
9
  agents: 'AGENTS.MD',
10
- copilot: '.github/copilot-instructions.md'
10
+ copilot: '.github/copilot-instructions.md',
11
+ cursor: '.cursorrules'
11
12
  };
12
13
 
13
14
  function buildAgentsPointer() {
@@ -31,6 +32,17 @@ function buildCopilotPointer() {
31
32
  ].join('\n');
32
33
  }
33
34
 
35
+ function buildCursorPointer() {
36
+ return [
37
+ '<!-- Tool profile: cursor-compat -->',
38
+ '# Cursor Rules',
39
+ '',
40
+ 'Primary policy source: `CLAUDE.md`.',
41
+ 'Load policy only from the canonical source file above.',
42
+ 'If this file and CLAUDE.md conflict, CLAUDE.md wins.'
43
+ ].join('\n');
44
+ }
45
+
34
46
  async function writeGeneratedInstructions(targetDir, templateDir, force = false) {
35
47
  // Copy CLAUDE.md from template if not present (or forced)
36
48
  const targetClaude = path.join(targetDir, CANONICAL_INSTRUCTION_FILE);
@@ -42,7 +54,8 @@ async function writeGeneratedInstructions(targetDir, templateDir, force = false)
42
54
  // Write thin pointer files
43
55
  const pointers = {
44
56
  [POINTER_FILES.agents]: buildAgentsPointer(),
45
- [POINTER_FILES.copilot]: buildCopilotPointer()
57
+ [POINTER_FILES.copilot]: buildCopilotPointer(),
58
+ [POINTER_FILES.cursor]: buildCursorPointer()
46
59
  };
47
60
 
48
61
  for (const [relPath, content] of Object.entries(pointers)) {
@@ -63,7 +76,8 @@ async function validateInstructionDrift(targetDir) {
63
76
  const driftFiles = [];
64
77
  const expectedPointers = {
65
78
  [POINTER_FILES.agents]: buildAgentsPointer(),
66
- [POINTER_FILES.copilot]: buildCopilotPointer()
79
+ [POINTER_FILES.copilot]: buildCopilotPointer(),
80
+ [POINTER_FILES.cursor]: buildCursorPointer()
67
81
  };
68
82
 
69
83
  for (const [relPath, expectedContent] of Object.entries(expectedPointers)) {
@@ -158,10 +172,10 @@ async function scaffoldRule(targetDir, ruleName) {
158
172
  }
159
173
 
160
174
  async function scaffoldSubagent(targetDir, name) {
161
- const subagentFile = path.join(targetDir, 'agents', 'subagents', `${name}.md`);
175
+ const subagentFile = path.join(targetDir, '.claude', 'agents', `${name}.md`);
162
176
 
163
177
  if (await fs.pathExists(subagentFile)) {
164
- throw new Error(`Subagent already exists: agents/subagents/${name}.md`);
178
+ throw new Error(`Subagent already exists: .claude/agents/${name}.md`);
165
179
  }
166
180
 
167
181
  const title = name.split('-').map(w => w[0].toUpperCase() + w.slice(1)).join(' ');
@@ -195,7 +209,7 @@ async function scaffoldSubagent(targetDir, name) {
195
209
 
196
210
  await fs.ensureDir(path.dirname(subagentFile));
197
211
  await fs.writeFile(subagentFile, content, 'utf8');
198
- return `agents/subagents/${name}.md`;
212
+ return `.claude/agents/${name}.md`;
199
213
  }
200
214
 
201
215
  module.exports = {
package/lib/layout.js CHANGED
@@ -6,7 +6,7 @@ const LAYOUT = {
6
6
  docsDir: 'agent-docs',
7
7
  rulesDir: '.github/instructions/rules',
8
8
  skillsDir: '.github/skills',
9
- subagentsDir: 'agents/subagents'
9
+ subagentsDir: '.claude/agents'
10
10
  },
11
11
  legacy: {
12
12
  rulesDirs: ['agents/rules'],
@@ -41,7 +41,7 @@ function resolveSkillsDir(baseDir) {
41
41
  }
42
42
 
43
43
  function resolveSubagentsDir(baseDir) {
44
- const candidates = [LAYOUT.canonical.subagentsDir];
44
+ const candidates = [LAYOUT.canonical.subagentsDir, 'agents/subagents'];
45
45
  return firstExistingPath(baseDir, candidates) || LAYOUT.canonical.subagentsDir;
46
46
  }
47
47
 
@@ -50,6 +50,7 @@ async function hasAnyLayout(baseDir) {
50
50
  path.join(baseDir, LAYOUT.canonical.rulesDir),
51
51
  path.join(baseDir, LAYOUT.canonical.skillsDir),
52
52
  path.join(baseDir, LAYOUT.canonical.subagentsDir),
53
+ path.join(baseDir, 'agents', 'subagents'),
53
54
  ...LAYOUT.compatible.rulesDirs.map((relPath) => path.join(baseDir, relPath)),
54
55
  ...LAYOUT.compatible.skillsDirs.map((relPath) => path.join(baseDir, relPath)),
55
56
  ...LAYOUT.legacy.rulesDirs.map((relPath) => path.join(baseDir, relPath)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-templated",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "Technology-agnostic development template with multi-AI agent support (Cursor, Copilot, VSCode, Gemini), security-first patterns, and comprehensive testing guidelines",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -41,12 +41,12 @@ Subagents are invoked automatically based on `description` matching, or explicit
41
41
  ```
42
42
 
43
43
  ### Other tools (Copilot, Cursor, Windsurf)
44
- Reference the subagent file directly in your prompt or instruct your AI to follow the workflow defined in `agents/subagents/<name>.md`.
44
+ Reference the subagent file directly in your prompt or instruct your AI to follow the workflow defined in `.claude/agents/<name>.md`.
45
45
 
46
46
  ## File Structure
47
47
 
48
48
  ```
49
- agents/subagents/
49
+ .claude/agents/
50
50
  ├── README.md ← This file
51
51
  ├── planner.md
52
52
  ├── architect.md
@@ -0,0 +1,60 @@
1
+ ---
2
+ title: "AI / LLM Integration"
3
+ description: "Apply when integrating LLMs, RAG pipelines, prompt engineering, or working with AI-powered features"
4
+ version: "1.0.0"
5
+ tags: ["ai", "llm", "openai", "anthropic", "rag", "prompt-engineering", "safety"]
6
+ alwaysApply: false
7
+ globs: ["**/*llm*", "**/*openai*", "**/*anthropic*", "**/*langchain*", "**/*rag*", "**/ai/**"]
8
+ triggers:
9
+ - "Integrating OpenAI, Claude, or other LLM APIs"
10
+ - "Building RAG (Retrieval-Augmented Generation) pipeline"
11
+ - "Engineering prompts or prompt chains"
12
+ - "Implementing LLM-powered features"
13
+ - "Evaluating LLM outputs or quality"
14
+ ---
15
+
16
+ ## Purpose
17
+
18
+ Govern LLM integrations safely: prevent prompt injection, enforce cost boundaries, define fallback behavior, and ensure model outputs are validated before use in any user-facing or downstream context.
19
+
20
+ ## Security Requirements
21
+
22
+ 1. **Prompt injection prevention** — Never interpolate raw user input directly into system prompts. Delimit user content explicitly (e.g., `<user_input>…</user_input>` tags or equivalent structural separation).
23
+ 2. **Output validation** — Treat all LLM outputs as untrusted data. Validate schema, sanitize before rendering in UI, and never execute LLM-generated code without a human or automated review gate.
24
+ 3. **Secret isolation** — API keys must live in environment variables only. Never log full request/response payloads that may contain sensitive user data.
25
+ 4. **Rate limiting** — Apply per-user and global rate limits on all LLM-backed endpoints to prevent abuse and runaway costs.
26
+
27
+ ## Cost Controls
28
+
29
+ - Set explicit `max_tokens` on every API call — never rely on model defaults.
30
+ - Log token usage per request; alert on anomalies (> 2× rolling baseline).
31
+ - Prefer streaming for long generations to enable early cancellation.
32
+ - Use smaller/cheaper models for classification, routing, or validation tasks; reserve large models for generation.
33
+
34
+ ## Model Selection
35
+
36
+ | Task | Preferred approach |
37
+ |------|--------------------|
38
+ | Classification / intent detection | Small fast model or fine-tuned classifier |
39
+ | Retrieval-augmented generation | Embed → retrieve → generate pipeline |
40
+ | Code generation | Model with strong code benchmarks; always review output |
41
+ | Summarization | Mid-tier model with explicit length constraints |
42
+ | Production generation | Model with provider SLA; never experimental endpoints in prod |
43
+
44
+ ## Fallback & Reliability
45
+
46
+ - Every LLM call must have a timeout and retry with exponential backoff (max 3 retries).
47
+ - Define a graceful degradation path for every LLM-powered feature (static response, cached answer, or user-facing degradation message).
48
+ - Do not block critical user flows on LLM availability.
49
+
50
+ ## RAG Pipeline Rules
51
+
52
+ - Chunk documents at semantic boundaries (paragraph, section), not arbitrary byte offsets.
53
+ - Score retrieved chunks; discard chunks below relevance threshold before injecting into prompt.
54
+ - Cite sources in output when content is retrieved — never present retrieved facts as model-generated knowledge.
55
+
56
+ ## Evaluation Requirements
57
+
58
+ - New LLM features must include an evaluation suite before production: minimum 20 representative examples with expected outputs.
59
+ - Track: accuracy, latency (p50/p95), token cost per request, failure rate.
60
+ - Accuracy regressions > 5% block promotion to production.
@@ -0,0 +1,180 @@
1
+ ---
2
+ title: "Core Project Guidelines"
3
+ description: "Apply to all architecture, type safety, code organization, and enterprise quality standards. Foundation for every feature"
4
+ alwaysApply: true
5
+ version: "3.0.0"
6
+ tags: ["architecture", "core", "enterprise", "technology-agnostic"]
7
+ globs:
8
+ - "*"
9
+ triggers:
10
+ - "Designing application architecture"
11
+ - "Setting up new project or module"
12
+ - "Defining type systems and validation"
13
+ - "Organizing code structure"
14
+ - "Improving code quality standards"
15
+ - "Making testing or performance decisions"
16
+ ---
17
+
18
+ ## Developer Identity
19
+
20
+ - The AI assistant should provide clear, step-by-step solutions
21
+ - Focus on security-first thinking in all recommendations
22
+ - Provide concise but comprehensive instructions
23
+ - Adapt all patterns to the chosen technology stack
24
+
25
+ ## Architecture Principles
26
+
27
+ ### Security-First Development
28
+ - **Validate all inputs** at application boundaries with appropriate validation libraries
29
+ - **Authenticate and authorize** every protected endpoint with secure session management
30
+ - **Rate limit** public endpoints to prevent abuse and DoS attacks
31
+ - **Sanitize outputs** to prevent injection attacks and data leaks
32
+ - **Use encryption** for sensitive data in transit and at rest
33
+ - **Log security events** appropriately without exposing sensitive information
34
+
35
+ ### Performance-Focused
36
+ - **Optimize asset delivery** with compression, caching, and lazy loading
37
+ - **Monitor performance metrics** specific to your platform (Web Vitals, response times, etc.)
38
+ - **Implement appropriate caching strategies** for your data freshness requirements
39
+ - **Optimize critical paths** - database queries, API responses, asset loading
40
+ - **Profile and benchmark** before and after optimization changes
41
+
42
+ ### Type Safety & Validation
43
+ - **Use strong typing systems** available in your chosen language
44
+ - **Implement runtime validation** for all external/user-provided data
45
+ - **Validate at boundaries** - API endpoints, form submissions, configuration
46
+ - **Document type contracts** between system components
47
+ - **Generate types** from schemas when possible (OpenAPI, GraphQL, database schemas)
48
+
49
+ ### Testing Strategy
50
+ - **Unit tests** for business logic and utility functions (80% of test effort)
51
+ - **Integration tests** for API endpoints and data access layers (15% of test effort)
52
+ - **E2E tests** for critical user journeys and workflows (5% of test effort)
53
+ - **Accessibility tests** for all user-facing interfaces
54
+ - **Performance tests** for critical paths and known bottlenecks
55
+ - **Security tests** for authentication, authorization, and validation flows
56
+
57
+ ## Code Quality Standards
58
+
59
+ ### Architecture & Organization
60
+ - **Feature-based structure** - organize code by business domain, not just technical layer
61
+ - **Separation of concerns** - keep UI, business logic, and data access separate
62
+ - **DRY principle** - don't repeat yourself, extract common patterns
63
+ - **SOLID principles** - single responsibility, open/closed, Liskov substitution, interface segregation, dependency inversion
64
+ - **Consistent naming** conventions throughout the codebase
65
+
66
+ ### Code Style
67
+ - **Consistent formatting** with automated tools (prettier, black, gofmt, rustfmt, etc.)
68
+ - **Linting rules** enforced via pre-commit hooks or CI/CD
69
+ - **Clear comments** for complex logic, architectural decisions, and gotchas
70
+ - **Self-documenting code** with meaningful variable and function names
71
+ - **No magic numbers** - extract constants with descriptive names
72
+
73
+ ### Component/Module Standards (Framework-Specific)
74
+ - **Single responsibility** - each component/module should have one clear purpose
75
+ - **Reusable units** - build components/modules that can be used in multiple places
76
+ - **Proper error handling** for production resilience
77
+ - **Accessibility attributes** included for user-facing components
78
+ - **Proper documentation** of public APIs and interfaces
79
+
80
+ ### Database Standards
81
+ - **Choose ONE approach** and maintain consistency (SQL with ORM, NoSQL, managed service, etc.)
82
+ - **Schema migrations only** for schema changes (never manual database edits in production)
83
+ - **ORM/ODM patterns** to prevent injection attacks (no raw SQL unless performance-critical)
84
+ - **Connection pooling** for all production deployments
85
+ - **Audit logs** for sensitive data operations
86
+ - **Proper indexing** to prevent N+1 query problems
87
+
88
+ ## Development Workflow
89
+
90
+ ### Quality Gates
91
+ - **Automated formatting** checks before code submission
92
+ - **Type checking** must pass (strict mode where available)
93
+ - **Linting** must pass with zero critical violations
94
+ - **Unit tests** must pass with adequate coverage (>80% for business logic)
95
+ - **Integration tests** must pass for API and data layer changes
96
+ - **Security scans** must pass without high-severity issues
97
+ - **Code review** approval required before merging
98
+
99
+ ### Environment Management
100
+ - **Environment variables** with runtime validation at startup
101
+ - **Secrets management** never in code, version control, or logs
102
+ - **Database migrations** applied consistently across environments
103
+ - **Feature flags** for gradual rollouts and A/B testing
104
+ - **Health checks** for deployment validation and monitoring
105
+
106
+ ### Performance Standards
107
+ - **Monitor resource usage** - memory, CPU, disk, network
108
+ - **Track performance metrics** specific to your platform
109
+ - **Profile critical paths** regularly to identify bottlenecks
110
+ - **Implement caching** appropriately for your use case
111
+ - **Alert on regressions** when performance degrades
112
+
113
+ ## Technology Stack Selection
114
+
115
+ This template is technology-agnostic. Choose your stack based on:
116
+ - **Team expertise** and preferred languages/frameworks
117
+ - **Project requirements** - performance needs, scalability, real-time features
118
+ - **Deployment environment** - cloud platform, container requirements, resources
119
+ - **Time constraints** - rapid prototyping vs. long-term maintenance
120
+
121
+ ### Frontend Tiers
122
+ - **Full-stack frameworks**: Next.js, Nuxt, SvelteKit, Remix
123
+ - **Component libraries**: React, Vue, Angular, Svelte, Solid
124
+ - **Traditional**: Server-side rendering with templates (Django, Rails, Laravel)
125
+ - **Mobile-first**: React Native, Flutter, Kotlin, Swift
126
+
127
+ ### Backend Tiers
128
+ - **Node.js**: Express, Fastify, NestJS, Koa
129
+ - **Python**: Django, FastAPI, Flask
130
+ - **Go**: Gin, Echo, Fiber
131
+ - **Rust**: Actix-web, Axum, Rocket
132
+ - **Java**: Spring Boot, Quarkus, Ktor
133
+ - **Other**: Ruby on Rails, C#/.NET, PHP, etc.
134
+
135
+ ### Database Tiers
136
+ - **SQL**: PostgreSQL, MySQL, SQLite, SQL Server
137
+ - **NoSQL**: MongoDB, DynamoDB, CouchDB, Firestore
138
+ - **Cloud-native**: Supabase, Firebase, AWS RDS, Azure SQL
139
+ - **Search**: Elasticsearch, Meilisearch, Algolia
140
+
141
+ ### Authentication
142
+ - **Self-managed**: Custom implementation with JWT, sessions, or cookies
143
+ - **Framework-integrated**: NextAuth, Passport, Django's auth system
144
+ - **SaaS**: Auth0, Firebase Auth, AWS Cognito, Supabase Auth
145
+
146
+ ## Maintenance & Evolution
147
+
148
+ ### Regular Reviews
149
+ - **Dependency updates** - keep packages current with security patches
150
+ - **Security audits** - regular vulnerability scanning and code review
151
+ - **Performance monitoring** - track metrics and address regressions
152
+ - **Code quality** - refactoring and technical debt management
153
+ - **Documentation** - keep docs current with code changes
154
+
155
+ ### Technology Updates
156
+ - **Framework versions** - planned upgrades with migration strategies
157
+ - **Critical patches** - immediate application of security updates
158
+ - **Feature adoption** - stay current with language/framework improvements
159
+ - **Deprecation management** - handle deprecated APIs and patterns
160
+
161
+ ## Documentation and Research
162
+
163
+ When deciding what to recommend or implement:
164
+
165
+ - **Local rules** (this file and other `.claude/rules/*.mdc`): Use as the primary source for architecture, security, testing, and style. Follow these when the stack is generic or already covered.
166
+ - **Context7 MCP**: Use for **up-to-date library and framework documentation**. When suggesting or implementing patterns for a specific stack (e.g. Next.js, Express, React), query Context7 (`resolve-library-id` then `query-docs`) so recommendations match current APIs and official guidance.
167
+ - **NotebookLM MCP**: Use for **research and best-practice discourse** (e.g. OWASP, building-systems advice, template design). Query when adding or changing guidelines, or when the audit/planning needs external best practices. Not for real-time API docs—use Context7 for that.
168
+
169
+ ## Communication & Collaboration
170
+
171
+ - When providing solutions, be explicit about what to change
172
+ - Show code examples in the language/framework being used
173
+ - Focus on actionable steps, minimize unnecessary explanation
174
+ - Explain security implications of code changes
175
+ - Flag performance implications of design decisions
176
+
177
+ ---
178
+
179
+ Remember: This template adapts to **any modern technology stack** while maintaining **enterprise-grade quality standards**.
180
+ Choose your technologies wisely, apply these principles consistently, and keep your codebase maintainable.