agent-ctx 1.0.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.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +133 -0
  3. package/dist/bin/agent-ctx.d.ts +7 -0
  4. package/dist/bin/agent-ctx.d.ts.map +1 -0
  5. package/dist/bin/agent-ctx.js +8 -0
  6. package/dist/bin/agent-ctx.js.map +1 -0
  7. package/dist/bin/agentrc.d.ts +7 -0
  8. package/dist/bin/agentrc.d.ts.map +1 -0
  9. package/dist/bin/agentrc.js +8 -0
  10. package/dist/bin/agentrc.js.map +1 -0
  11. package/dist/commands/add.d.ts +12 -0
  12. package/dist/commands/add.d.ts.map +1 -0
  13. package/dist/commands/add.js +17 -0
  14. package/dist/commands/add.js.map +1 -0
  15. package/dist/commands/centralize.d.ts +12 -0
  16. package/dist/commands/centralize.d.ts.map +1 -0
  17. package/dist/commands/centralize.js +111 -0
  18. package/dist/commands/centralize.js.map +1 -0
  19. package/dist/commands/clean.d.ts +13 -0
  20. package/dist/commands/clean.d.ts.map +1 -0
  21. package/dist/commands/clean.js +109 -0
  22. package/dist/commands/clean.js.map +1 -0
  23. package/dist/commands/doctor.d.ts +12 -0
  24. package/dist/commands/doctor.d.ts.map +1 -0
  25. package/dist/commands/doctor.js +168 -0
  26. package/dist/commands/doctor.js.map +1 -0
  27. package/dist/commands/init.d.ts +14 -0
  28. package/dist/commands/init.d.ts.map +1 -0
  29. package/dist/commands/init.js +189 -0
  30. package/dist/commands/init.js.map +1 -0
  31. package/dist/commands/update.d.ts +13 -0
  32. package/dist/commands/update.d.ts.map +1 -0
  33. package/dist/commands/update.js +97 -0
  34. package/dist/commands/update.js.map +1 -0
  35. package/dist/index.d.ts +6 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +76 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/lib/bridges.d.ts +35 -0
  40. package/dist/lib/bridges.d.ts.map +1 -0
  41. package/dist/lib/bridges.js +171 -0
  42. package/dist/lib/bridges.js.map +1 -0
  43. package/dist/lib/config.d.ts +31 -0
  44. package/dist/lib/config.d.ts.map +1 -0
  45. package/dist/lib/config.js +75 -0
  46. package/dist/lib/config.js.map +1 -0
  47. package/dist/lib/i18n.d.ts +22 -0
  48. package/dist/lib/i18n.d.ts.map +1 -0
  49. package/dist/lib/i18n.js +170 -0
  50. package/dist/lib/i18n.js.map +1 -0
  51. package/dist/lib/logger.d.ts +55 -0
  52. package/dist/lib/logger.d.ts.map +1 -0
  53. package/dist/lib/logger.js +168 -0
  54. package/dist/lib/logger.js.map +1 -0
  55. package/dist/lib/templates.d.ts +46 -0
  56. package/dist/lib/templates.d.ts.map +1 -0
  57. package/dist/lib/templates.js +88 -0
  58. package/dist/lib/templates.js.map +1 -0
  59. package/dist/lib/utils.d.ts +39 -0
  60. package/dist/lib/utils.d.ts.map +1 -0
  61. package/dist/lib/utils.js +127 -0
  62. package/dist/lib/utils.js.map +1 -0
  63. package/dist/lib/wizard.d.ts +22 -0
  64. package/dist/lib/wizard.d.ts.map +1 -0
  65. package/dist/lib/wizard.js +197 -0
  66. package/dist/lib/wizard.js.map +1 -0
  67. package/package.json +63 -0
  68. package/src/templates/en/base/_agents.md +62 -0
  69. package/src/templates/en/base/_architecture.md +90 -0
  70. package/src/templates/en/base/_bootstrap.md +89 -0
  71. package/src/templates/en/base/_doc.md +65 -0
  72. package/src/templates/en/base/_mcp.md +81 -0
  73. package/src/templates/en/base/_project_state.md +48 -0
  74. package/src/templates/en/base/_rule.md +56 -0
  75. package/src/templates/en/base/_skill.md +60 -0
  76. package/src/templates/en/docs/doc-readme.md +43 -0
  77. package/src/templates/en/docs/mcp-readme.md +21 -0
  78. package/src/templates/en/memory/active_context.md +38 -0
  79. package/src/templates/en/memory/progress.md +35 -0
  80. package/src/templates/en/memory/project_brief.md +34 -0
  81. package/src/templates/en/memory/tech_context.md +44 -0
  82. package/src/templates/en/rules/rule-coding-standards.md +22 -0
  83. package/src/templates/en/skills/skill-agents.md +74 -0
  84. package/src/templates/en/skills/skill-api.md +117 -0
  85. package/src/templates/en/skills/skill-architecture.md +87 -0
  86. package/src/templates/en/skills/skill-generating.md +116 -0
  87. package/src/templates/en/skills/skill-git.md +109 -0
  88. package/src/templates/en/skills/skill-project-state.md +99 -0
  89. package/src/templates/en/skills/skill-react.md +94 -0
  90. package/src/templates/en/skills/skill-rules.md +100 -0
  91. package/src/templates/en/skills/skill-testing.md +139 -0
  92. package/src/templates/es/base/_agents.md +62 -0
  93. package/src/templates/es/base/_architecture.md +90 -0
  94. package/src/templates/es/base/_bootstrap.md +89 -0
  95. package/src/templates/es/base/_doc.md +65 -0
  96. package/src/templates/es/base/_mcp.md +81 -0
  97. package/src/templates/es/base/_project_state.md +48 -0
  98. package/src/templates/es/base/_rule.md +56 -0
  99. package/src/templates/es/base/_skill.md +60 -0
  100. package/src/templates/es/docs/doc-readme.md +43 -0
  101. package/src/templates/es/docs/mcp-readme.md +21 -0
  102. package/src/templates/es/memory/active_context.md +38 -0
  103. package/src/templates/es/memory/progress.md +35 -0
  104. package/src/templates/es/memory/project_brief.md +34 -0
  105. package/src/templates/es/memory/tech_context.md +44 -0
  106. package/src/templates/es/rules/rule-coding-standards.md +22 -0
  107. package/src/templates/es/skills/skill-agents.md +74 -0
  108. package/src/templates/es/skills/skill-api.md +117 -0
  109. package/src/templates/es/skills/skill-architecture.md +87 -0
  110. package/src/templates/es/skills/skill-generating.md +116 -0
  111. package/src/templates/es/skills/skill-git.md +108 -0
  112. package/src/templates/es/skills/skill-project-state.md +99 -0
  113. package/src/templates/es/skills/skill-react.md +94 -0
  114. package/src/templates/es/skills/skill-rules.md +100 -0
  115. package/src/templates/es/skills/skill-testing.md +139 -0
@@ -0,0 +1,48 @@
1
+ # Project State (Memory)
2
+
3
+ > This file is updated manually so the AI knows where it left off in the last session.
4
+ > **Last updated:** [DATE]
5
+
6
+ ## Current Context
7
+
8
+ [Briefly describe what phase the project is in: MVP, active development, maintenance, etc.]
9
+
10
+ ## Recently Completed
11
+
12
+ - [x] Completed task 1
13
+ - [x] Completed task 2
14
+ - [x] Completed task 3
15
+
16
+ ## In Progress (Current Sprint)
17
+
18
+ - [ ] Task in progress 1
19
+ - [ ] Task in progress 2
20
+ - [ ] Task in progress 3
21
+
22
+ ## Coming Up Next
23
+
24
+ - [ ] Pending task 1
25
+ - [ ] Pending task 2
26
+
27
+ ## Known Bugs / Technical Debt
28
+
29
+ | Bug/Issue | Priority | Notes |
30
+ |-----------|----------|-------|
31
+ | Bug description | High/Medium/Low | Additional context |
32
+
33
+ ## Important Decisions
34
+
35
+ - **Decision 1**: [What was decided and why]
36
+ - **Decision 2**: [What was decided and why]
37
+
38
+ ## Notes for Next Session
39
+
40
+ > Write here anything important the AI should know before starting to work:
41
+
42
+ - Note 1
43
+ - Note 2
44
+
45
+ ## Current Restrictions
46
+
47
+ - Do not modify [X] because [reason]
48
+ - Avoid [Y] until [condition]
@@ -0,0 +1,56 @@
1
+ ---
2
+ type: rule-template
3
+ target: .context/rules/{name}.md
4
+ ---
5
+
6
+ # AI Guide
7
+
8
+ You are helping the user create a new coding rule/standard document. Follow these steps:
9
+ 1. Ask the user about the specific rule or standard they want to document
10
+ 2. Gather examples of correct and incorrect usage
11
+ 3. Fill in the template below with the information
12
+
13
+ # Questions to Ask
14
+
15
+ 1. What is the name/title of this rule?
16
+ 2. What problem does this rule solve or prevent?
17
+ 3. What are the specific requirements or constraints?
18
+ 4. Can you provide examples of correct usage?
19
+ 5. Can you provide examples of what to avoid?
20
+ 6. Are there any exceptions to this rule?
21
+
22
+ # Template Output
23
+
24
+ ```markdown
25
+ # ⚖️ Rule: {name}
26
+
27
+ > {brief description of the rule}
28
+
29
+ ## Why this rule exists
30
+
31
+ {Explain the problem this rule prevents or the benefit it provides}
32
+
33
+ ## Requirements
34
+
35
+ - {Requirement 1}
36
+ - {Requirement 2}
37
+ - {Requirement 3}
38
+
39
+ ## ✅ Correct Examples
40
+
41
+ {code or examples showing correct usage}
42
+
43
+ ## ❌ Incorrect Examples
44
+
45
+ {code or examples showing what to avoid}
46
+
47
+ ## Exceptions
48
+
49
+ {List any valid exceptions to this rule, or "No exceptions" if none}
50
+
51
+ ## Enforcement
52
+
53
+ - [ ] Linter rule: {rule name if applicable}
54
+ - [ ] Code review checklist item
55
+ - [ ] Automated test
56
+ ```
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: skill-name
3
+ description: Brief description of what this skill does and when to use it. Write in third person. Be specific about triggers and use cases.
4
+ ---
5
+
6
+ # Skill Name
7
+
8
+ Brief overview of the skill's purpose.
9
+
10
+ ## When to use
11
+
12
+ - When the user asks for [specific task]
13
+ - When [pattern or trigger] is detected
14
+ - When working with [technology or domain]
15
+
16
+ ## Quick start
17
+
18
+ Minimal example to get started immediately:
19
+
20
+ ```typescript
21
+ // Concise, functional example
22
+ import { example } from 'library';
23
+
24
+ const result = example.process(input);
25
+ ```
26
+
27
+ ## Implementation steps
28
+
29
+ 1. **Step 1**: Brief description
30
+ 2. **Step 2**: Brief description
31
+ 3. **Step 3**: Brief description
32
+
33
+ ## Best practices
34
+
35
+ ### ✅ Do
36
+
37
+ - Good practice 1
38
+ - Good practice 2
39
+
40
+ ### ❌ Avoid
41
+
42
+ - Anti-pattern 1
43
+ - Anti-pattern 2
44
+
45
+ ## References
46
+
47
+ - [Official docs](link)
48
+ - [Best practices guide](link)
49
+
50
+ ## Verification checklist
51
+
52
+ Copy and track progress:
53
+
54
+ ```
55
+ - [ ] Dependencies installed
56
+ - [ ] Configuration complete
57
+ - [ ] Core logic implemented
58
+ - [ ] Error handling added
59
+ - [ ] Tests written
60
+ ```
@@ -0,0 +1,43 @@
1
+ # 📚 External Documentation (Vendorizing)
2
+
3
+ This folder contains documentation from external libraries and APIs so AI agents can consult it locally without depending on internet access.
4
+
5
+ ## 🎯 Purpose
6
+
7
+ Many LLMs have outdated or limited knowledge about specific libraries. By placing documentation here, the agent can:
8
+
9
+ 1. Query up-to-date APIs
10
+ 2. View recent code examples
11
+ 3. Avoid suggesting deprecated code
12
+
13
+ ## 📥 What to place here?
14
+
15
+ - **`llms.txt`**: Special documentation files for LLMs (e.g., `mui-llms.txt`, `vercel-llms.txt`)
16
+ - **API References**: Documentation exports from APIs you use
17
+ - **Changelogs**: Important change notes from critical dependencies
18
+ - **Migration guides**: If you're migrating from one version to another
19
+
20
+ ## 💡 Examples of useful files
21
+
22
+ ```
23
+ docs/
24
+ ├── mui-llms.txt # Material UI docs for LLMs
25
+ ├── nextjs-app-router.md # Next.js App Router guide
26
+ ├── prisma-schema-guide.md # Prisma schema reference
27
+ ├── tailwind-v4-changes.md # Tailwind v3 to v4 changes
28
+ └── api-internal.md # Your internal API documentation
29
+ ```
30
+
31
+ ## 🔍 How to get llms.txt
32
+
33
+ Many modern libraries publish `.txt` files optimized for LLMs:
34
+
35
+ - **Vercel**: `https://vercel.com/docs/llms.txt`
36
+ - **Material UI**: Search in their repository
37
+ - **Others**: Check `/llms.txt` or `/docs/llms.txt` on the official site
38
+
39
+ ## ⚠️ Notes
40
+
41
+ - Keep only the essentials to avoid overloading the context
42
+ - Update periodically when you update dependencies
43
+ - Prioritize the libraries you use most in the project
@@ -0,0 +1,21 @@
1
+ # 🔌 Recommended MCP Servers
2
+
3
+ This file maintains a list of recommended MCP (Model Context Protocol) servers for this project.
4
+ Consistency in tooling across the team ensures better collaboration and AI assistance.
5
+
6
+ ## 📋 Server List
7
+
8
+ | Server Name | Description | Purpose | Install Command / Source |
9
+ |-------------|-------------|---------|--------------------------|
10
+ | `context7` | Documentation refresher | Keeps docs up-to-date in context | `npm install -g context7` |
11
+ | `filesystem`| File System Access | Allow AI to read/write files | Native in most MCP clients |
12
+
13
+ ## 📦 How to Install
14
+
15
+ Most MCP servers are installed via your editor's configuration (e.g., Cursor, VS Code).
16
+ Refer to your editor's documentation on how to add these servers.
17
+
18
+ ## 📝 Notes
19
+
20
+ - Add new servers here when the team agrees on a new standard tool.
21
+ - Keep the installation commands updated.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: active_context
3
+ description: Current session state - dynamic, updates frequently during development
4
+ ---
5
+
6
+ # Active Context
7
+
8
+ > Last updated: [DATE]
9
+
10
+ ## Current Focus
11
+
12
+ [What is currently being worked on]
13
+
14
+ ## Recent Changes
15
+
16
+ - [Change 1]
17
+ - [Change 2]
18
+
19
+ ## Open Questions
20
+
21
+ - [ ] Question 1
22
+ - [ ] Question 2
23
+
24
+ ## Blockers
25
+
26
+ | Blocker | Impact | Status |
27
+ |---------|--------|--------|
28
+ | | | |
29
+
30
+ ## Next Steps
31
+
32
+ 1. [ ] Step 1
33
+ 2. [ ] Step 2
34
+ 3. [ ] Step 3
35
+
36
+ ---
37
+
38
+ *This file is dynamically updated by the AI agent during development sessions.*
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: progress
3
+ description: Development progress tracking - dynamic, updates with each milestone
4
+ ---
5
+
6
+ # Progress
7
+
8
+ ## Milestones
9
+
10
+ ### Phase 1: [Name]
11
+
12
+ | Task | Status | Notes |
13
+ |------|--------|-------|
14
+ | | ⬜ Not Started | |
15
+ | | 🔄 In Progress | |
16
+ | | ✅ Complete | |
17
+
18
+ ## Changelog
19
+
20
+ ### [DATE]
21
+
22
+ - Added:
23
+ - Changed:
24
+ - Fixed:
25
+
26
+ ## Metrics
27
+
28
+ | Metric | Value | Target |
29
+ |--------|-------|--------|
30
+ | Test Coverage | | |
31
+ | Performance | | |
32
+
33
+ ---
34
+
35
+ *This file tracks overall project progress and is updated by the AI agent.*
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: project_brief
3
+ description: Project vision and goals - static, rarely changes
4
+ ---
5
+
6
+ # Project Brief
7
+
8
+ ## Vision
9
+
10
+ [Describe the overall vision for this project]
11
+
12
+ ## Goals
13
+
14
+ - [ ] Goal 1
15
+ - [ ] Goal 2
16
+ - [ ] Goal 3
17
+
18
+ ## Success Criteria
19
+
20
+ 1. [Criterion 1]
21
+ 2. [Criterion 2]
22
+
23
+ ## Constraints
24
+
25
+ - [Technical constraint]
26
+ - [Business constraint]
27
+ - [Timeline constraint]
28
+
29
+ ## Stakeholders
30
+
31
+ | Role | Name | Responsibility |
32
+ |------|------|----------------|
33
+ | Owner | | |
34
+ | Developer | | |
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: tech_context
3
+ description: Technical stack and dependencies - semi-static, updates with major changes
4
+ ---
5
+
6
+ # Technical Context
7
+
8
+ ## Stack
9
+
10
+ | Layer | Technology | Version |
11
+ |-------|------------|---------|
12
+ | Language | | |
13
+ | Framework | | |
14
+ | Database | | |
15
+ | Cache | | |
16
+ | Hosting | | |
17
+
18
+ ## Dependencies
19
+
20
+ ### Production
21
+
22
+ | Package | Purpose |
23
+ |---------|---------|
24
+ | | |
25
+
26
+ ### Development
27
+
28
+ | Package | Purpose |
29
+ |---------|---------|
30
+ | | |
31
+
32
+ ## Architecture Decisions
33
+
34
+ ### [Decision 1]
35
+
36
+ **Context:**
37
+ **Decision:**
38
+ **Consequences:**
39
+
40
+ ## Integration Points
41
+
42
+ - **API:**
43
+ - **External Services:**
44
+ - **Third-party:**
@@ -0,0 +1,22 @@
1
+ # Coding Standards and Rules
2
+
3
+ ## 1. General Principles
4
+ - **DRY (Don't Repeat Yourself):** Extract repeated logic to hooks or utilities.
5
+ - **KISS (Keep It Simple, Stupid):** Prefer the most readable solution over the "clever" one.
6
+ - **Composition:** Prefer small, composed components over monoliths.
7
+
8
+ ## 2. TypeScript & Typing
9
+ - **Forbidden:** Using `any`. If you don't know the type, use `unknown` and do narrowing.
10
+ - **Required:** Define interfaces/types for all component Props.
11
+ - **Preference:** Use `type` for object definitions and `interface` if you need to extend them.
12
+
13
+ ## 3. Styles and Naming
14
+ - **Components:** `PascalCase` (e.g., `UserProfile.tsx`).
15
+ - **Functions/Variables:** `camelCase` (e.g., `getUserData`).
16
+ - **Constants:** `UPPER_SNAKE_CASE` (e.g., `MAX_RETRY_COUNT`).
17
+ - **CSS:** We use [Tailwind CSS]. Avoid inline styles (`style={{...}}`).
18
+
19
+ ## 4. Error Handling
20
+ - Wrap async calls in `try/catch` blocks.
21
+ - Use `ErrorBoundary` components for UI failures.
22
+ - Never leave a `catch` empty. Log the error.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: managing-agents
3
+ description: Configure and update AGENTS.md context file for AI agents. Use when setting up agent context or modifying agent instructions.
4
+ ---
5
+
6
+ # Managing Agents Context
7
+
8
+ Configure the AGENTS.md file that orients AI agents to your project.
9
+
10
+ ## When to use
11
+
12
+ - Setting up AI agent context for a new project
13
+ - Updating agent instructions
14
+ - Adding new knowledge sources for agents
15
+ - Changing how agents should behave in your project
16
+
17
+ ## AGENTS.md Purpose
18
+
19
+ The AGENTS.md file is the entry point for AI agents. It tells them:
20
+ - What the project does
21
+ - Where to find critical information
22
+ - How to behave and what rules to follow
23
+
24
+ ## Standard Template
25
+
26
+ ```markdown
27
+ # AI Agent Context
28
+
29
+ You are a senior developer joining this project.
30
+ Your goal is to help build, refactor, and maintain code following our architecture.
31
+
32
+ ## Knowledge Index
33
+
34
+ Before writing code, load context from:
35
+
36
+ - **Architecture:** `.context/architecture.md`
37
+ - **Rules:** `.context/rules/coding-standards.md`
38
+ - **Skills:** `.context/skills/`
39
+
40
+ ## Current State
41
+
42
+ Check `.context/project_state.md` for current work status.
43
+ ```
44
+
45
+ ## Best Practices
46
+
47
+ ### ✅ Do
48
+
49
+ - Keep AGENTS.md concise (under 50 lines)
50
+ - Point to detailed files instead of duplicating content
51
+ - Update when project structure changes
52
+ - Include path to rules and conventions
53
+
54
+ ### ❌ Avoid
55
+
56
+ - Putting detailed documentation in AGENTS.md
57
+ - Outdated file paths
58
+ - Generic instructions without project specifics
59
+ - Conflicting information between files
60
+
61
+ ## Placement
62
+
63
+ AGENTS.md should be at the project root:
64
+
65
+ ```
66
+ project/
67
+ ├── AGENTS.md # AI agent entry point
68
+ ├── .context/ # Detailed context
69
+ │ ├── architecture.md
70
+ │ ├── project_state.md
71
+ │ ├── rules/
72
+ │ └── skills/
73
+ └── src/
74
+ ```
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: api-design
3
+ description: Design REST APIs with consistent patterns, proper HTTP status codes, and validation. Use when creating endpoints, handling errors, or implementing API versioning.
4
+ ---
5
+
6
+ # API Design
7
+
8
+ Patterns and best practices for designing REST APIs.
9
+
10
+ ## When to use
11
+
12
+ - Designing REST endpoints
13
+ - Handling errors consistently
14
+ - Implementing API versioning
15
+ - Adding request validation
16
+
17
+ ## REST Conventions
18
+
19
+ ### URL Structure
20
+
21
+ ```
22
+ GET /api/v1/users # List users
23
+ GET /api/v1/users/:id # Get user
24
+ POST /api/v1/users # Create user
25
+ PUT /api/v1/users/:id # Full update
26
+ PATCH /api/v1/users/:id # Partial update
27
+ DELETE /api/v1/users/:id # Delete user
28
+ ```
29
+
30
+ ### Query Parameters
31
+
32
+ ```
33
+ GET /api/v1/users?
34
+ page=1& # Pagination
35
+ limit=20& # Items per page
36
+ sort=createdAt:desc& # Sorting
37
+ filter[status]=active # Filters
38
+ ```
39
+
40
+ ## Standard Responses
41
+
42
+ ### Success (200, 201)
43
+
44
+ ```json
45
+ {
46
+ "success": true,
47
+ "data": { "id": "123", "name": "John Doe" },
48
+ "meta": { "page": 1, "total": 100 }
49
+ }
50
+ ```
51
+
52
+ ### Error (400, 404, 500)
53
+
54
+ ```json
55
+ {
56
+ "success": false,
57
+ "error": {
58
+ "code": "VALIDATION_ERROR",
59
+ "message": "Email is required",
60
+ "details": [{ "field": "email", "message": "Required" }]
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## HTTP Status Codes
66
+
67
+ | Code | Meaning | Usage |
68
+ |------|---------|-------|
69
+ | 200 | OK | Successful GET, PUT/PATCH |
70
+ | 201 | Created | Successful POST |
71
+ | 204 | No Content | Successful DELETE |
72
+ | 400 | Bad Request | Validation failed |
73
+ | 401 | Unauthorized | Not authenticated |
74
+ | 403 | Forbidden | No permissions |
75
+ | 404 | Not Found | Resource doesn't exist |
76
+ | 500 | Server Error | Internal error |
77
+
78
+ ## Validation Example
79
+
80
+ ```typescript
81
+ import { z } from 'zod';
82
+
83
+ const userSchema = z.object({
84
+ email: z.string().email(),
85
+ name: z.string().min(2),
86
+ role: z.enum(['admin', 'user'])
87
+ });
88
+
89
+ export function validate(schema: z.ZodSchema) {
90
+ return (req, res, next) => {
91
+ const result = schema.safeParse(req.body);
92
+ if (!result.success) {
93
+ return res.status(400).json({
94
+ success: false,
95
+ error: { code: 'VALIDATION_ERROR', details: result.error.issues }
96
+ });
97
+ }
98
+ req.body = result.data;
99
+ next();
100
+ };
101
+ }
102
+ ```
103
+
104
+ ## Best practices
105
+
106
+ ### ✅ Do
107
+
108
+ - Always use HTTPS
109
+ - Version in URL (`/api/v1/`)
110
+ - Rate limiting
111
+ - Consistent response format
112
+
113
+ ### ❌ Avoid
114
+
115
+ - Verbs in URLs (`/getUsers`, `/deleteUser`)
116
+ - Exposing internal IDs
117
+ - Inconsistent response formats
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: documenting-architecture
3
+ description: Document project architecture, tech stack, and data flow. Use when setting up or updating architecture documentation.
4
+ ---
5
+
6
+ # Documenting Architecture
7
+
8
+ Create and maintain architecture documentation for AI agents and developers.
9
+
10
+ ## When to use
11
+
12
+ - Starting a new project
13
+ - Major tech stack changes
14
+ - Adding new services or integrations
15
+ - Onboarding new team members or AI agents
16
+
17
+ ## Architecture Document Structure
18
+
19
+ ```markdown
20
+ # Project Architecture
21
+
22
+ ## Project Goal
23
+ [2-3 lines describing the application purpose]
24
+
25
+ ## Tech Stack
26
+
27
+ ### Frontend
28
+ | Technology | Version | Purpose |
29
+ |------------|---------|---------|
30
+ | React | 18.x | UI |
31
+
32
+ ### Backend
33
+ | Technology | Version | Purpose |
34
+ |------------|---------|---------|
35
+ | Node.js | 20.x | API |
36
+
37
+ ## Directory Structure
38
+ [Tree showing key directories]
39
+
40
+ ## Data Flow
41
+ [Diagram or description of how data moves]
42
+
43
+ ## Environment Variables
44
+ | Variable | Description | Required |
45
+ |----------|-------------|----------|
46
+ | API_KEY | Service key | ✅ |
47
+ ```
48
+
49
+ ## Key Sections
50
+
51
+ 1. **Tech Stack**: All technologies with versions
52
+ 2. **Directory Structure**: Key folders and their purpose
53
+ 3. **Data Flow**: How data moves through the system
54
+ 4. **Environment Variables**: Required configuration
55
+ 5. **Critical Dependencies**: Important packages
56
+
57
+ ## Update Triggers
58
+
59
+ Update architecture.md when:
60
+ - Adding new frameworks or libraries
61
+ - Changing directory structure
62
+ - Adding new services or APIs
63
+ - Modifying data flow
64
+
65
+ ## Best Practices
66
+
67
+ ### ✅ Do
68
+
69
+ - Include specific versions
70
+ - Document WHY not just WHAT
71
+ - Keep current with actual codebase
72
+ - Use tables for scanability
73
+
74
+ ### ❌ Avoid
75
+
76
+ - Outdated version numbers
77
+ - Missing critical integrations
78
+ - Overly detailed (link to docs instead)
79
+ - Implementation details (put in code comments)
80
+
81
+ ## File Location
82
+
83
+ ```
84
+ project/
85
+ └── .context/
86
+ └── architecture.md # Main architecture doc
87
+ ```