@codemieai/code 0.0.33 → 0.0.34

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 (180) hide show
  1. package/README.md +73 -7
  2. package/bin/codemie-opencode.js +11 -0
  3. package/dist/agents/codemie-code/agent.d.ts +17 -1
  4. package/dist/agents/codemie-code/agent.d.ts.map +1 -1
  5. package/dist/agents/codemie-code/agent.js +62 -3
  6. package/dist/agents/codemie-code/agent.js.map +1 -1
  7. package/dist/agents/codemie-code/index.d.ts +1 -0
  8. package/dist/agents/codemie-code/index.d.ts.map +1 -1
  9. package/dist/agents/codemie-code/index.js +28 -2
  10. package/dist/agents/codemie-code/index.js.map +1 -1
  11. package/dist/agents/codemie-code/prompts.d.ts +12 -3
  12. package/dist/agents/codemie-code/prompts.d.ts.map +1 -1
  13. package/dist/agents/codemie-code/prompts.js +25 -5
  14. package/dist/agents/codemie-code/prompts.js.map +1 -1
  15. package/dist/agents/codemie-code/types.d.ts +3 -0
  16. package/dist/agents/codemie-code/types.d.ts.map +1 -1
  17. package/dist/agents/codemie-code/types.js.map +1 -1
  18. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  19. package/dist/agents/core/AgentCLI.js +3 -1
  20. package/dist/agents/core/AgentCLI.js.map +1 -1
  21. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  22. package/dist/agents/core/BaseAgentAdapter.js +33 -0
  23. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  24. package/dist/agents/core/session/BaseSessionAdapter.d.ts +25 -0
  25. package/dist/agents/core/session/BaseSessionAdapter.d.ts.map +1 -1
  26. package/dist/agents/core/session/discovery-types.d.ts +53 -0
  27. package/dist/agents/core/session/discovery-types.d.ts.map +1 -0
  28. package/dist/agents/core/session/discovery-types.js +8 -0
  29. package/dist/agents/core/session/discovery-types.js.map +1 -0
  30. package/dist/agents/core/types.d.ts +45 -0
  31. package/dist/agents/core/types.d.ts.map +1 -1
  32. package/dist/agents/plugins/claude/claude.plugin.d.ts +44 -1
  33. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  34. package/dist/agents/plugins/claude/claude.plugin.js +214 -0
  35. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  36. package/dist/agents/plugins/claude/plugin/README.md +40 -2
  37. package/dist/agents/plugins/claude/plugin/claude-templates/README.md +5 -5
  38. package/dist/agents/plugins/claude/plugin/claude-templates/templates/CLAUDE.md.template +177 -436
  39. package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/code-review-agent-template.md.template +49 -82
  40. package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/refactor-cleaner-agent.md.template +337 -0
  41. package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/solution-architect-agent.md.template +129 -419
  42. package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/unit-tester-agent.md.template +146 -693
  43. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/api/api-patterns.md.template +110 -138
  44. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/architecture.md.template +197 -0
  45. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/data/database-patterns.md.template +171 -91
  46. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/development/development-practices.md.template +219 -131
  47. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/security/security-practices.md.template +223 -98
  48. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/standards/code-quality.md.template +131 -95
  49. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/testing/testing-patterns.md.template +247 -75
  50. package/dist/agents/plugins/claude/plugin/commands/README.md +133 -0
  51. package/dist/agents/plugins/claude/plugin/commands/codemie-init.md +336 -544
  52. package/dist/agents/plugins/claude/plugin/commands/codemie-subagents.md +232 -503
  53. package/dist/agents/plugins/claude/plugin/commands/memory-add.md +311 -30
  54. package/dist/agents/plugins/claude/plugin/commands/memory-refresh.md +218 -39
  55. package/dist/agents/plugins/gemini/gemini.plugin.d.ts.map +1 -1
  56. package/dist/agents/plugins/gemini/gemini.plugin.js +0 -3
  57. package/dist/agents/plugins/gemini/gemini.plugin.js.map +1 -1
  58. package/dist/agents/plugins/opencode/index.d.ts +8 -0
  59. package/dist/agents/plugins/opencode/index.d.ts.map +1 -0
  60. package/dist/agents/plugins/opencode/index.js +12 -0
  61. package/dist/agents/plugins/opencode/index.js.map +1 -0
  62. package/dist/agents/plugins/opencode/opencode-message-types.d.ts +207 -0
  63. package/dist/agents/plugins/opencode/opencode-message-types.d.ts.map +1 -0
  64. package/dist/agents/plugins/opencode/opencode-message-types.js +59 -0
  65. package/dist/agents/plugins/opencode/opencode-message-types.js.map +1 -0
  66. package/dist/agents/plugins/opencode/opencode-model-configs.d.ts +65 -0
  67. package/dist/agents/plugins/opencode/opencode-model-configs.d.ts.map +1 -0
  68. package/dist/agents/plugins/opencode/opencode-model-configs.js +184 -0
  69. package/dist/agents/plugins/opencode/opencode-model-configs.js.map +1 -0
  70. package/dist/agents/plugins/opencode/opencode.paths.d.ts +62 -0
  71. package/dist/agents/plugins/opencode/opencode.paths.d.ts.map +1 -0
  72. package/dist/agents/plugins/opencode/opencode.paths.js +148 -0
  73. package/dist/agents/plugins/opencode/opencode.paths.js.map +1 -0
  74. package/dist/agents/plugins/opencode/opencode.plugin.d.ts +35 -0
  75. package/dist/agents/plugins/opencode/opencode.plugin.d.ts.map +1 -0
  76. package/dist/agents/plugins/opencode/opencode.plugin.js +338 -0
  77. package/dist/agents/plugins/opencode/opencode.plugin.js.map +1 -0
  78. package/dist/agents/plugins/opencode/opencode.session.d.ts +77 -0
  79. package/dist/agents/plugins/opencode/opencode.session.d.ts.map +1 -0
  80. package/dist/agents/plugins/opencode/opencode.session.js +424 -0
  81. package/dist/agents/plugins/opencode/opencode.session.js.map +1 -0
  82. package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts +25 -0
  83. package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts.map +1 -0
  84. package/dist/agents/plugins/opencode/opencode.storage-utils.js +96 -0
  85. package/dist/agents/plugins/opencode/opencode.storage-utils.js.map +1 -0
  86. package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts +30 -0
  87. package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts.map +1 -0
  88. package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js +116 -0
  89. package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js.map +1 -0
  90. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts +102 -0
  91. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts.map +1 -0
  92. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js +584 -0
  93. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js.map +1 -0
  94. package/dist/agents/registry.d.ts.map +1 -1
  95. package/dist/agents/registry.js +2 -0
  96. package/dist/agents/registry.js.map +1 -1
  97. package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts +5 -0
  98. package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts.map +1 -1
  99. package/dist/cli/commands/doctor/checks/AgentsCheck.js +29 -0
  100. package/dist/cli/commands/doctor/checks/AgentsCheck.js.map +1 -1
  101. package/dist/cli/commands/install.d.ts.map +1 -1
  102. package/dist/cli/commands/install.js +86 -7
  103. package/dist/cli/commands/install.js.map +1 -1
  104. package/dist/cli/commands/opencode-metrics.d.ts +13 -0
  105. package/dist/cli/commands/opencode-metrics.d.ts.map +1 -0
  106. package/dist/cli/commands/opencode-metrics.js +200 -0
  107. package/dist/cli/commands/opencode-metrics.js.map +1 -0
  108. package/dist/cli/commands/setup.d.ts.map +1 -1
  109. package/dist/cli/commands/setup.js +113 -0
  110. package/dist/cli/commands/setup.js.map +1 -1
  111. package/dist/cli/commands/skill.d.ts +6 -0
  112. package/dist/cli/commands/skill.d.ts.map +1 -0
  113. package/dist/cli/commands/skill.js +196 -0
  114. package/dist/cli/commands/skill.js.map +1 -0
  115. package/dist/cli/commands/update.d.ts.map +1 -1
  116. package/dist/cli/commands/update.js +34 -6
  117. package/dist/cli/commands/update.js.map +1 -1
  118. package/dist/cli/index.js +4 -0
  119. package/dist/cli/index.js.map +1 -1
  120. package/dist/migrations/003-remove-hooks-node.migration.d.ts +22 -0
  121. package/dist/migrations/003-remove-hooks-node.migration.d.ts.map +1 -0
  122. package/dist/migrations/003-remove-hooks-node.migration.js +103 -0
  123. package/dist/migrations/003-remove-hooks-node.migration.js.map +1 -0
  124. package/dist/migrations/index.d.ts +1 -0
  125. package/dist/migrations/index.d.ts.map +1 -1
  126. package/dist/migrations/index.js +1 -1
  127. package/dist/migrations/index.js.map +1 -1
  128. package/dist/providers/plugins/sso/sso.http-client.js +2 -2
  129. package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
  130. package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
  131. package/dist/providers/plugins/sso/sso.setup-steps.js +14 -10
  132. package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
  133. package/dist/skills/core/SkillDiscovery.d.ts +83 -0
  134. package/dist/skills/core/SkillDiscovery.d.ts.map +1 -0
  135. package/dist/skills/core/SkillDiscovery.js +237 -0
  136. package/dist/skills/core/SkillDiscovery.js.map +1 -0
  137. package/dist/skills/core/SkillManager.d.ts +86 -0
  138. package/dist/skills/core/SkillManager.d.ts.map +1 -0
  139. package/dist/skills/core/SkillManager.js +155 -0
  140. package/dist/skills/core/SkillManager.js.map +1 -0
  141. package/dist/skills/core/types.d.ts +120 -0
  142. package/dist/skills/core/types.d.ts.map +1 -0
  143. package/dist/skills/core/types.js +20 -0
  144. package/dist/skills/core/types.js.map +1 -0
  145. package/dist/skills/index.d.ts +12 -0
  146. package/dist/skills/index.d.ts.map +1 -0
  147. package/dist/skills/index.js +12 -0
  148. package/dist/skills/index.js.map +1 -0
  149. package/dist/skills/utils/content-loader.d.ts +25 -0
  150. package/dist/skills/utils/content-loader.d.ts.map +1 -0
  151. package/dist/skills/utils/content-loader.js +161 -0
  152. package/dist/skills/utils/content-loader.js.map +1 -0
  153. package/dist/skills/utils/frontmatter.d.ts +60 -0
  154. package/dist/skills/utils/frontmatter.d.ts.map +1 -0
  155. package/dist/skills/utils/frontmatter.js +114 -0
  156. package/dist/skills/utils/frontmatter.js.map +1 -0
  157. package/dist/skills/utils/pattern-matcher.d.ts +60 -0
  158. package/dist/skills/utils/pattern-matcher.d.ts.map +1 -0
  159. package/dist/skills/utils/pattern-matcher.js +97 -0
  160. package/dist/skills/utils/pattern-matcher.js.map +1 -0
  161. package/dist/utils/installation-detector.d.ts +22 -0
  162. package/dist/utils/installation-detector.d.ts.map +1 -0
  163. package/dist/utils/installation-detector.js +49 -0
  164. package/dist/utils/installation-detector.js.map +1 -0
  165. package/dist/utils/native-installer.d.ts +49 -0
  166. package/dist/utils/native-installer.d.ts.map +1 -0
  167. package/dist/utils/native-installer.js +194 -0
  168. package/dist/utils/native-installer.js.map +1 -0
  169. package/dist/utils/version-utils.d.ts +50 -0
  170. package/dist/utils/version-utils.d.ts.map +1 -0
  171. package/dist/utils/version-utils.js +92 -0
  172. package/dist/utils/version-utils.js.map +1 -0
  173. package/package.json +5 -2
  174. package/scripts/copy-mr-skill-to-global.ts +252 -0
  175. package/scripts/demo-hooks.sh +125 -0
  176. package/scripts/test-hooks.sh +196 -0
  177. package/dist/agents/plugins/claude/plugin/claude-templates/templates/INDEX.md +0 -205
  178. package/dist/agents/plugins/claude/plugin/claude-templates/templates/TEMPLATE_SIZES.md +0 -74
  179. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/layered-architecture.md.template +0 -143
  180. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/project-structure.md.template +0 -127
@@ -1,170 +1,295 @@
1
+ ---
1
2
  # Security Practices
2
3
 
3
- ## Quick Summary
4
+ <!--
5
+ GENERATION INSTRUCTIONS:
6
+ 1. Find auth middleware/guards and extract flow
7
+ 2. Scan for role/permission checks and document model
8
+ 3. Locate validation schemas at API boundaries
9
+ 4. Check for security middleware (helmet, cors, rate-limit)
10
+ 5. Find secrets loading pattern (env, vault, etc.)
11
+ 6. Identify security-sensitive operations and their protections
12
+ 7. Output: 150-300 lines max
13
+ -->
14
+
15
+ **Project**: [Extract from config]
16
+ **Auth Method**: [Detect: JWT | Session | OAuth2 | API Key | None]
17
+ **Auth Library**: [Detect: passport, jose, next-auth, etc.]
4
18
 
5
- Security patterns for [PROJECT_NAME]: authentication, authorization, input validation, and secrets management.
19
+ ---
6
20
 
7
- **Category**: Security
8
- **Complexity**: High
9
- **Prerequisites**: OWASP Top 10, [AUTH_METHOD]
21
+ ## Authentication Flow
10
22
 
11
- ---
23
+ <!-- Extract actual auth implementation -->
12
24
 
13
- ## 🚨 SIZE LIMIT WARNING
25
+ ### How Auth Works
14
26
 
15
- **This generated guide MUST be 200-400 lines maximum.**
27
+ ```
28
+ [Request] → [Auth Middleware] → [Token/Session Validation] → [User Context]
29
+
30
+ ▼ (on failure)
31
+ 401 Unauthorized
32
+ ```
16
33
 
17
- **When filling this template**:
18
- - ✅ Code examples: 5-15 lines (NEVER > 20)
19
- - ✅ ONE example per pattern
20
- - ✅ Use file:line references, not full code
21
- - ✅ Use tables for multiple patterns
22
- - ❌ NO multiple examples for same pattern
23
- - ❌ NO verbose explanations
24
- - ❌ NO copying entire functions
34
+ ### Implementation
25
35
 
26
- **Validate line count after generation**: `wc -l [this-file]`
27
- **If > 400 lines**: Condense immediately before continuing!
36
+ ```[lang]
37
+ // Source: [file:lines]
38
+ [Extract auth middleware/guard usage]
39
+ ```
28
40
 
29
- ---
41
+ ### Token/Session Details
30
42
 
31
- ## Authentication
43
+ | Aspect | Value |
44
+ |--------|-------|
45
+ | Type | `[JWT / Session / API Key]` |
46
+ | Storage | `[Header: Bearer / Cookie / Query]` |
47
+ | Expiration | `[duration or config location]` |
48
+ | Refresh | `[mechanism if exists]` |
32
49
 
33
- ### Pattern
50
+ ### Protect a Route
34
51
 
35
- ```[language]
36
- # Source: [file:lines]
37
- [auth_pattern]
52
+ ```[lang]
53
+ // Apply auth to new endpoints like this:
54
+ [Extract exact syntax for protecting routes]
38
55
  ```
39
56
 
40
- **Method**: [JWT / OAuth2 / API Key / Session]
41
- **Token Storage**: [Where tokens are stored]
42
- **Expiration**: [Token lifetime]
43
-
44
57
  ---
45
58
 
46
59
  ## Authorization
47
60
 
48
- ### Pattern
61
+ <!-- Find permission/role checking patterns -->
49
62
 
50
- ```[language]
51
- # Source: [file:lines]
52
- [authz_pattern]
63
+ ### Permission Model
64
+
65
+ **Type**: [RBAC | ABAC | Simple roles | Custom]
66
+
67
+ | Role/Permission | Access Level | Defined In |
68
+ |-----------------|--------------|------------|
69
+ | `[role/permission]` | [What it allows] | `[file:line]` |
70
+ | `[role/permission]` | [What it allows] | `[file:line]` |
71
+
72
+ ### Enforce Permissions
73
+
74
+ ```[lang]
75
+ // Source: [file:lines]
76
+ [Extract authorization check pattern]
53
77
  ```
54
78
 
55
- **Roles**: [List roles and permissions]
79
+ ### Check User Permissions
80
+
81
+ ```[lang]
82
+ // How to check permissions in code:
83
+ [Extract permission checking syntax]
84
+ ```
56
85
 
57
86
  ---
58
87
 
59
88
  ## Input Validation
60
89
 
61
- ### Pattern
90
+ <!-- Find validation at API boundaries -->
91
+
92
+ ### Validation Layer
62
93
 
63
- ```[language]
64
- # Source: [file:lines]
65
- [validation_pattern]
94
+ **Library**: `[Zod / Joi / class-validator / Pydantic / etc.]`
95
+ **Applied At**: `[Middleware / Decorator / Controller]`
96
+
97
+ ```[lang]
98
+ // Source: [file:lines]
99
+ [Extract validation schema example]
100
+ ```
101
+
102
+ ### Sanitization
103
+
104
+ ```[lang]
105
+ // Source: [file:lines] - if explicit sanitization exists
106
+ [Extract sanitization pattern or note "handled by validation library"]
66
107
  ```
67
108
 
68
- **Rules**:
69
- - ✅ Validate all input at boundaries
70
- - ✅ Use validation library/framework
71
- - ✅ Whitelist (not blacklist)
72
- - ❌ Trust user input
109
+ ### Rules
110
+
111
+ - ✅ Validate at `[detected boundary - controller/middleware]`
112
+ - ✅ Use schemas from `[validation path]`
113
+ - ❌ Never trust: query params, body, headers, path params
73
114
 
74
115
  ---
75
116
 
76
117
  ## Secrets Management
77
118
 
78
- ### Environment Variables
119
+ <!-- Find how secrets are loaded and used -->
120
+
121
+ ### Loading Pattern
122
+
123
+ ```[lang]
124
+ // Source: [file:lines]
125
+ [Extract secrets/config loading]
126
+ ```
127
+
128
+ ### Secret Variables
129
+
130
+ | Variable | Purpose | Required |
131
+ |----------|---------|----------|
132
+ | `[SECRET_KEY/JWT_SECRET]` | [Token signing] | Yes |
133
+ | `[DATABASE_URL]` | [DB connection] | Yes |
134
+ | `[API_KEY_*]` | [External services] | Varies |
135
+
136
+ ### Access Secrets
79
137
 
80
- ```bash
81
- # NEVER commit these
82
- [SECRET_KEY]=[use env var]
83
- [API_KEY]=[use secrets manager in prod]
84
- [DB_PASSWORD]=[use secrets manager in prod]
138
+ ```[lang]
139
+ // Always access secrets via:
140
+ [Extract config/env access pattern - never hardcode]
85
141
  ```
86
142
 
87
- **Rules**:
88
- - ✅ Environment variables for dev
89
- - ✅ Secrets manager for production
90
- - ✅ Rotate regularly
91
- - ❌ Hardcode in code
92
- - ❌ Commit to git
93
- - ❌ Log secrets
143
+ ### Rules
144
+
145
+ - ✅ Load from `[env / secrets manager / vault]`
146
+ - ✅ Access via `[config module pattern]`
147
+ - ❌ Hardcode in source code
148
+ - ❌ Commit `.env` files
149
+ - ❌ Log secret values
94
150
 
95
151
  ---
96
152
 
97
- ## SQL Injection Prevention
153
+ ## Security Middleware
154
+
155
+ <!-- Find security-related middleware/headers -->
98
156
 
99
- ```[language]
100
- # Good: Parameterized
101
- [good_sql_example]
157
+ ### Configured Protections
102
158
 
103
- # Bad: String interpolation
104
- [bad_sql_example]
159
+ | Protection | Implementation | Source |
160
+ |------------|----------------|--------|
161
+ | Security Headers | `[helmet / manual / framework]` | `[file:line]` |
162
+ | CORS | `[cors config location]` | `[file:line]` |
163
+ | Rate Limiting | `[rate-limit implementation]` | `[file:line]` |
164
+ | CSRF | `[csrf protection or N/A]` | `[file:line]` |
165
+
166
+ ### Headers Set
167
+
168
+ ```[lang]
169
+ // Source: [file:lines]
170
+ [Extract security headers configuration]
171
+ ```
172
+
173
+ ### CORS Configuration
174
+
175
+ ```[lang]
176
+ // Source: [file:lines]
177
+ [Extract CORS config - allowed origins, methods]
178
+ ```
179
+
180
+ ### Rate Limiting
181
+
182
+ ```[lang]
183
+ // Source: [file:lines]
184
+ [Extract rate limit configuration]
105
185
  ```
106
186
 
107
- **Rule**: ALWAYS use parameterized queries
187
+ **Limits**: `[X requests per Y time window]`
188
+
189
+ ---
190
+
191
+ ## SQL Injection Prevention
192
+
193
+ <!-- Verify ORM/query builder or parameterized queries -->
194
+
195
+ **Protection**: `[ORM: name | Query Builder: name | Parameterized queries]`
196
+
197
+ ```[lang]
198
+ // ✅ Safe - Source: [file:lines]
199
+ [Extract parameterized query example]
200
+
201
+ // ❌ NEVER - vulnerable to injection
202
+ [Show anti-pattern if found, or generic example]
203
+ ```
108
204
 
109
205
  ---
110
206
 
111
207
  ## XSS Prevention
112
208
 
113
- ```[language]
114
- # Source: [file:lines]
115
- [xss_prevention]
209
+ <!-- Find output encoding/escaping -->
210
+
211
+ **Protection**: `[Framework auto-escaping | Manual escaping | CSP]`
212
+
213
+ ```[lang]
214
+ // Source: [file:lines]
215
+ [Extract output escaping or template rendering pattern]
116
216
  ```
117
217
 
118
- **Rules**:
119
- - ✅ Escape output
120
- - ✅ Use framework defaults
121
- - ✅ Content Security Policy headers
122
- - ❌ Trust user content
218
+ **Content Security Policy**: `[Configured / Not configured]`
123
219
 
124
220
  ---
125
221
 
126
- ## Security Headers
222
+ ## File Upload Security
127
223
 
128
- ```[language]
129
- # Source: [file:lines]
130
- [security_headers]
224
+ <!-- If file uploads exist, document protections -->
225
+
226
+ ```[lang]
227
+ // Source: [file:lines]
228
+ [Extract file upload validation - type, size, name sanitization]
131
229
  ```
132
230
 
133
- **Required Headers**:
134
- - `[Header1]`: `[Value]`
135
- - `[Header2]`: `[Value]`
231
+ | Protection | Implementation |
232
+ |------------|----------------|
233
+ | File type validation | `[how enforced]` |
234
+ | Size limit | `[max size]` |
235
+ | Storage location | `[path - outside webroot?]` |
236
+ | Filename sanitization | `[yes/no, how]` |
136
237
 
137
238
  ---
138
239
 
139
- ## HTTPS/TLS
240
+ ## Audit Logging
241
+
242
+ <!-- Find security event logging -->
243
+
244
+ **Logged Events**:
140
245
 
141
- **Rules**:
142
- - ✅ HTTPS everywhere in production
143
- - Valid TLS certificates
144
- - Minimum TLS 1.2+
145
- - Plain HTTP for sensitive data
246
+ | Event | Log Level | Source |
247
+ |-------|-----------|--------|
248
+ | Login success/failure | `[level]` | `[file:line]` |
249
+ | Permission denied | `[level]` | `[file:line]` |
250
+ | Password change | `[level]` | `[file:line]` |
251
+ | Sensitive data access | `[level]` | `[file:line]` |
252
+
253
+ ```[lang]
254
+ // Source: [file:lines]
255
+ [Extract audit log example]
256
+ ```
146
257
 
147
258
  ---
148
259
 
149
- ## Security Checklist
260
+ ## Dependency Security
150
261
 
151
- - [ ] Authentication on protected endpoints
152
- - [ ] Authorization checks enforced
153
- - [ ] All input validated
154
- - [ ] SQL queries parameterized
155
- - [ ] Secrets in env vars (not code)
156
- - [ ] HTTPS in production
157
- - [ ] Security headers configured
158
- - [ ] Sensitive data encrypted
159
- - [ ] Error messages don't leak info
160
- - [ ] Logging excludes secrets/PII
262
+ <!-- Find vulnerability scanning setup -->
263
+
264
+ | Tool | Command | Frequency |
265
+ |------|---------|-----------|
266
+ | `[npm audit / safety / snyk / dependabot]` | `[command]` | `[CI / manual]` |
161
267
 
162
268
  ---
163
269
 
164
- ## References
270
+ ## Security Anti-Patterns
271
+
272
+ <!-- Extract from code review or detected issues -->
165
273
 
166
- - **Auth Implementation**: `[path/to/auth]`
167
- - **Validation**: `[path/to/validation]`
168
- - **OWASP Top 10**: https://owasp.org/www-project-top-ten/
274
+ | NEVER | ✅ INSTEAD | Risk |
275
+ |----------|-----------|------|
276
+ | `[detected or common anti-pattern]` | `[correct pattern]` | [Risk type] |
277
+ | `[detected or common anti-pattern]` | `[correct pattern]` | [Risk type] |
278
+ | `[detected or common anti-pattern]` | `[correct pattern]` | [Risk type] |
279
+ | Log user passwords/tokens | Log user ID only | Data exposure |
280
+ | Return stack traces to client | Generic error messages | Info leakage |
169
281
 
170
282
  ---
283
+
284
+ ## Quick Reference
285
+
286
+ | Security Need | Location | Pattern |
287
+ |---------------|----------|---------|
288
+ | Auth middleware | `[path]` | `[usage syntax]` |
289
+ | Permission check | `[path]` | `[usage syntax]` |
290
+ | Input validation | `[path]` | `[usage syntax]` |
291
+ | Secrets config | `[path]` | `[access pattern]` |
292
+ | Security headers | `[path]` | - |
293
+ | Audit logging | `[path]` | `[log function]` |
294
+
295
+ ---
@@ -1,150 +1,186 @@
1
+ ---
1
2
  # Code Quality Standards
2
3
 
3
- ## Quick Summary
4
+ <!--
5
+ GENERATION INSTRUCTIONS:
6
+ 1. Parse linter config for active rules
7
+ 2. Extract formatter settings
8
+ 3. Scan codebase for consistent patterns
9
+ 4. Identify type checking strictness level
10
+ 5. Find pre-commit/CI quality gates
11
+ 6. Extract actual good/bad examples from codebase
12
+ 7. Output: 150-250 lines max
13
+ -->
14
+
15
+ **Project**: [Extract from config]
16
+ **Linter**: [Detect tool + config file]
17
+ **Formatter**: [Detect tool + config file]
18
+ **Type Checker**: [Detect tool + config file or N/A]
19
+
20
+ ---
21
+
22
+ ## Quality Commands
23
+
24
+ <!-- Extract exact commands from package.json, Makefile, pyproject.toml -->
4
25
 
5
- Code quality standards for [PROJECT_NAME]: linting, formatting, type safety, and naming conventions.
26
+ | Action | Command | Description |
27
+ |--------|---------|-------------|
28
+ | Check all | `[combined command if exists]` | Run all quality checks |
29
+ | Lint | `[lint command]` | Check code issues |
30
+ | Lint fix | `[lint fix command]` | Auto-fix issues |
31
+ | Format | `[format command]` | Format code |
32
+ | Type check | `[type check command or N/A]` | Verify types |
6
33
 
7
- **Category**: Standards
8
- **Complexity**: Simple
9
- **Prerequisites**: [LANGUAGE], [LINTER], [FORMATTER]
34
+ **Before committing, run**: `[primary quality command]`
10
35
 
11
36
  ---
12
37
 
13
- ## 🚨 SIZE LIMIT WARNING
38
+ ## Enforced Rules
14
39
 
15
- **This generated guide MUST be 200-400 lines maximum.**
40
+ <!-- Extract key rules from linter/formatter config -->
16
41
 
17
- **When filling this template**:
18
- - ✅ Code examples: 5-15 lines (NEVER > 20)
19
- - ✅ ONE example per pattern
20
- - ✅ Use file:line references, not full code
21
- - ✅ Use tables for multiple patterns
22
- - ❌ NO multiple examples for same pattern
23
- - ❌ NO verbose explanations
24
- - ❌ NO copying entire functions
42
+ ### From Linter (`[config file]`)
25
43
 
26
- **Validate line count after generation**: `wc -l [this-file]`
27
- **If > 400 lines**: Condense immediately before continuing!
44
+ | Rule | Setting | Rationale |
45
+ |------|---------|-----------|
46
+ | `[rule-name]` | `[error/warn/value]` | [Brief why] |
47
+ | `[rule-name]` | `[error/warn/value]` | [Brief why] |
48
+ | `[rule-name]` | `[error/warn/value]` | [Brief why] |
49
+ | `[rule-name]` | `[error/warn/value]` | [Brief why] |
50
+
51
+ ### From Formatter (`[config file]`)
52
+
53
+ | Setting | Value |
54
+ |---------|-------|
55
+ | Line length | `[value]` |
56
+ | Indentation | `[tabs/spaces, size]` |
57
+ | Quotes | `[single/double]` |
58
+ | Trailing comma | `[yes/no/es5]` |
59
+ | Semicolons | `[yes/no]` |
28
60
 
29
61
  ---
30
62
 
31
- ## Tools
63
+ ## Naming Standards
64
+
65
+ <!-- Extract from linter rules + analyze codebase patterns -->
32
66
 
33
- | Tool | Purpose | Config |
34
- |------|---------|--------|
35
- | [Linter] | Code quality | `[config_file]` |
36
- | [Formatter] | Formatting | `[config_file]` |
37
- | [Type Checker] | Type checking | `[config_file]` |
67
+ | Element | Rule | Correct | ❌ Wrong |
68
+ |---------|------|-----------|----------|
69
+ | Variables | `[camelCase/snake_case]` | `userName` | `user_name` / `UserName` |
70
+ | Functions | `[camelCase/snake_case]` | `getUserById` | `GetUserById` |
71
+ | Classes | `[PascalCase]` | `UserService` | `userService` |
72
+ | Constants | `[UPPER_SNAKE]` | `MAX_RETRIES` | `maxRetries` |
73
+ | Files | `[kebab/snake/pascal]` | `[actual example]` | `[counter example]` |
74
+ | Boolean vars | `[is/has/should prefix]` | `isActive` | `active` |
38
75
 
39
76
  ---
40
77
 
41
- ## Commands
78
+ ## Type Safety
42
79
 
43
- ```bash
44
- # Lint (check)
45
- [lint_check]
80
+ <!-- Detect type checking level and requirements -->
46
81
 
47
- # Lint (fix)
48
- [lint_fix]
82
+ **Strictness**: `[strict / moderate / basic / none]`
83
+ **Config**: `[tsconfig.json / mypy.ini / pyproject.toml section]`
49
84
 
50
- # Format
51
- [format]
85
+ ### Required Typing
52
86
 
53
- # Type check
54
- [type_check]
55
- ```
87
+ ```[lang]
88
+ // ✅ Correct - Source: [file:lines]
89
+ [Extract well-typed function example]
56
90
 
57
- ---
91
+ // ❌ Missing types - would fail type check
92
+ [Show same function without types]
93
+ ```
58
94
 
59
- ## Naming Conventions
95
+ ### Type Rules
60
96
 
61
- | Element | Convention | Example |
62
- |---------|------------|---------|
63
- | Variables | [convention] | `[example]` |
64
- | Functions | [convention] | `[example]` |
65
- | Classes | [convention] | `[Example]` |
66
- | Constants | [convention] | `[EXAMPLE]` |
67
- | Files | [convention] | `[example]` |
97
+ | Rule | Required |
98
+ |------|----------|
99
+ | Function parameters | Always |
100
+ | Function returns | Always |
101
+ | Variables | `[inferred OK / explicit required]` |
102
+ | `any` / `unknown` | `[forbidden / discouraged / allowed]` |
68
103
 
69
104
  ---
70
105
 
71
- ## Type Annotations
106
+ ## Code Complexity Limits
72
107
 
73
- ```[language]
74
- # Source: [file:lines]
75
- [type_example]
76
- ```
108
+ <!-- Extract from linter config or establish from codebase patterns -->
77
109
 
78
- **Required**:
79
- - ✅ All function parameters
80
- - All function returns
81
- - Public APIs
110
+ | Metric | Limit | Enforced By |
111
+ |--------|-------|-------------|
112
+ | Function length | `[max lines]` | `[rule name or convention]` |
113
+ | File length | `[max lines]` | `[rule name or convention]` |
114
+ | Cyclomatic complexity | `[max value]` | `[rule name or N/A]` |
115
+ | Nesting depth | `[max levels]` | `[rule name or convention]` |
116
+ | Parameters per function | `[max count]` | `[rule name or convention]` |
82
117
 
83
- ---
118
+ ### Reduce Complexity
84
119
 
85
- ## Imports
120
+ ```[lang]
121
+ // ❌ Too complex
122
+ [Extract or create example of deep nesting/long function]
86
123
 
87
- ```[language]
88
- # Order
89
- [import_example]
124
+ // ✅ Refactored
125
+ [Show extracted/simplified version]
90
126
  ```
91
127
 
92
- **Order**: Standard library → Third-party → Local
93
- **Rules**: One per line, sorted, no wildcards
94
-
95
128
  ---
96
129
 
97
- ## Code Structure
130
+ ## Import Organization
98
131
 
99
- **Guidelines**:
100
- - Functions < [X] lines
101
- - Files < [Y] lines
102
- - One responsibility per function
103
- - Limit parameters < [Z]
132
+ <!-- Extract from linter rules (import-order, isort, etc.) -->
104
133
 
105
- ---
134
+ ```[lang]
135
+ // Source: [well-organized file:lines]
106
136
 
107
- ## Comments
137
+ // Group 1: [Built-in/Standard library]
138
+ [imports]
108
139
 
109
- ```[language]
110
- # Source: [file:lines]
111
- [docstring_example]
140
+ // Group 2: [External/Third-party packages]
141
+ [imports]
142
+
143
+ // Group 3: [Internal/Local modules]
144
+ [imports]
112
145
  ```
113
146
 
114
- **When to Comment**:
115
- - ✅ Public APIs
116
- - ✅ Complex algorithms
117
- - Non-obvious decisions
118
- - ❌ Self-explanatory code
147
+ **Rules**:
148
+ - ✅ Sorted alphabetically within groups
149
+ - ✅ One import per line (or `[grouped style if used]`)
150
+ - Wildcard imports (`import *`)
151
+ - ❌ Unused imports
119
152
 
120
153
  ---
121
154
 
122
- ## Pre-Commit Hooks
155
+ ## Documentation Standards
123
156
 
124
- ```bash
125
- # Install
126
- [install_hooks]
127
- ```
157
+ <!-- Extract from docstring linter rules or conventions -->
128
158
 
129
- **Checks**: Linting, formatting, type checking
159
+ ### Required Documentation
130
160
 
131
- ---
161
+ | Element | Required | Format |
162
+ |---------|----------|--------|
163
+ | Public functions | ✅ | `[JSDoc / docstring / etc.]` |
164
+ | Public classes | ✅ | `[format]` |
165
+ | Complex logic | ✅ | Inline comments |
166
+ | Private/internal | Optional | - |
132
167
 
133
- ## Best Practices
168
+ ### Format
134
169
 
135
- | ✅ DO | ❌ DON'T |
136
- |-------|----------|
137
- | Descriptive names | Single letters (except i, j, k in loops) |
138
- | Keep functions small | 100+ line functions |
139
- | Use type hints | Skip types |
140
- | Follow conventions | Mix styles |
141
- | Early returns | Deep nesting |
170
+ ```[lang]
171
+ // Source: [file:lines]
172
+ [Extract canonical documentation example]
173
+ ```
142
174
 
143
175
  ---
144
176
 
145
- ## References
177
+ ## Common Violations & Fixes
146
178
 
147
- - **Config**: `[config_files]`
148
- - **Linter Docs**: [Link]
179
+ <!-- Extract from common linter errors in codebase or CI logs -->
149
180
 
150
- ---
181
+ | Violation | Fix |
182
+ |-----------|-----|
183
+ | `[linter-error-code]`: [description] | [How to fix] |
184
+ | `[linter-error-code]`: [description] | [How to fix] |
185
+ | `[linter-error-code]`: [description] | [How to fix] |
186
+ |