@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.
- package/README.md +73 -7
- package/bin/codemie-opencode.js +11 -0
- package/dist/agents/codemie-code/agent.d.ts +17 -1
- package/dist/agents/codemie-code/agent.d.ts.map +1 -1
- package/dist/agents/codemie-code/agent.js +62 -3
- package/dist/agents/codemie-code/agent.js.map +1 -1
- package/dist/agents/codemie-code/index.d.ts +1 -0
- package/dist/agents/codemie-code/index.d.ts.map +1 -1
- package/dist/agents/codemie-code/index.js +28 -2
- package/dist/agents/codemie-code/index.js.map +1 -1
- package/dist/agents/codemie-code/prompts.d.ts +12 -3
- package/dist/agents/codemie-code/prompts.d.ts.map +1 -1
- package/dist/agents/codemie-code/prompts.js +25 -5
- package/dist/agents/codemie-code/prompts.js.map +1 -1
- package/dist/agents/codemie-code/types.d.ts +3 -0
- package/dist/agents/codemie-code/types.d.ts.map +1 -1
- package/dist/agents/codemie-code/types.js.map +1 -1
- package/dist/agents/core/AgentCLI.d.ts.map +1 -1
- package/dist/agents/core/AgentCLI.js +3 -1
- package/dist/agents/core/AgentCLI.js.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.js +33 -0
- package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
- package/dist/agents/core/session/BaseSessionAdapter.d.ts +25 -0
- package/dist/agents/core/session/BaseSessionAdapter.d.ts.map +1 -1
- package/dist/agents/core/session/discovery-types.d.ts +53 -0
- package/dist/agents/core/session/discovery-types.d.ts.map +1 -0
- package/dist/agents/core/session/discovery-types.js +8 -0
- package/dist/agents/core/session/discovery-types.js.map +1 -0
- package/dist/agents/core/types.d.ts +45 -0
- package/dist/agents/core/types.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude.plugin.d.ts +44 -1
- package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/claude/claude.plugin.js +214 -0
- package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
- package/dist/agents/plugins/claude/plugin/README.md +40 -2
- package/dist/agents/plugins/claude/plugin/claude-templates/README.md +5 -5
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/CLAUDE.md.template +177 -436
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/code-review-agent-template.md.template +49 -82
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/refactor-cleaner-agent.md.template +337 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/solution-architect-agent.md.template +129 -419
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/unit-tester-agent.md.template +146 -693
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/api/api-patterns.md.template +110 -138
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/architecture.md.template +197 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/data/database-patterns.md.template +171 -91
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/development/development-practices.md.template +219 -131
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/security/security-practices.md.template +223 -98
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/standards/code-quality.md.template +131 -95
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/testing/testing-patterns.md.template +247 -75
- package/dist/agents/plugins/claude/plugin/commands/README.md +133 -0
- package/dist/agents/plugins/claude/plugin/commands/codemie-init.md +336 -544
- package/dist/agents/plugins/claude/plugin/commands/codemie-subagents.md +232 -503
- package/dist/agents/plugins/claude/plugin/commands/memory-add.md +311 -30
- package/dist/agents/plugins/claude/plugin/commands/memory-refresh.md +218 -39
- package/dist/agents/plugins/gemini/gemini.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/gemini/gemini.plugin.js +0 -3
- package/dist/agents/plugins/gemini/gemini.plugin.js.map +1 -1
- package/dist/agents/plugins/opencode/index.d.ts +8 -0
- package/dist/agents/plugins/opencode/index.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/index.js +12 -0
- package/dist/agents/plugins/opencode/index.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode-message-types.d.ts +207 -0
- package/dist/agents/plugins/opencode/opencode-message-types.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode-message-types.js +59 -0
- package/dist/agents/plugins/opencode/opencode-message-types.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.d.ts +65 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.js +184 -0
- package/dist/agents/plugins/opencode/opencode-model-configs.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.paths.d.ts +62 -0
- package/dist/agents/plugins/opencode/opencode.paths.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.paths.js +148 -0
- package/dist/agents/plugins/opencode/opencode.paths.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.plugin.d.ts +35 -0
- package/dist/agents/plugins/opencode/opencode.plugin.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.plugin.js +338 -0
- package/dist/agents/plugins/opencode/opencode.plugin.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.session.d.ts +77 -0
- package/dist/agents/plugins/opencode/opencode.session.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.session.js +424 -0
- package/dist/agents/plugins/opencode/opencode.session.js.map +1 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts +25 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.js +96 -0
- package/dist/agents/plugins/opencode/opencode.storage-utils.js.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts +30 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js +116 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts +102 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts.map +1 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js +584 -0
- package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js.map +1 -0
- package/dist/agents/registry.d.ts.map +1 -1
- package/dist/agents/registry.js +2 -0
- package/dist/agents/registry.js.map +1 -1
- package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts +5 -0
- package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts.map +1 -1
- package/dist/cli/commands/doctor/checks/AgentsCheck.js +29 -0
- package/dist/cli/commands/doctor/checks/AgentsCheck.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +86 -7
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/opencode-metrics.d.ts +13 -0
- package/dist/cli/commands/opencode-metrics.d.ts.map +1 -0
- package/dist/cli/commands/opencode-metrics.js +200 -0
- package/dist/cli/commands/opencode-metrics.js.map +1 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +113 -0
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/skill.d.ts +6 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +196 -0
- package/dist/cli/commands/skill.js.map +1 -0
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +34 -6
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/migrations/003-remove-hooks-node.migration.d.ts +22 -0
- package/dist/migrations/003-remove-hooks-node.migration.d.ts.map +1 -0
- package/dist/migrations/003-remove-hooks-node.migration.js +103 -0
- package/dist/migrations/003-remove-hooks-node.migration.js.map +1 -0
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +1 -1
- package/dist/migrations/index.js.map +1 -1
- package/dist/providers/plugins/sso/sso.http-client.js +2 -2
- package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.js +14 -10
- package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
- package/dist/skills/core/SkillDiscovery.d.ts +83 -0
- package/dist/skills/core/SkillDiscovery.d.ts.map +1 -0
- package/dist/skills/core/SkillDiscovery.js +237 -0
- package/dist/skills/core/SkillDiscovery.js.map +1 -0
- package/dist/skills/core/SkillManager.d.ts +86 -0
- package/dist/skills/core/SkillManager.d.ts.map +1 -0
- package/dist/skills/core/SkillManager.js +155 -0
- package/dist/skills/core/SkillManager.js.map +1 -0
- package/dist/skills/core/types.d.ts +120 -0
- package/dist/skills/core/types.d.ts.map +1 -0
- package/dist/skills/core/types.js +20 -0
- package/dist/skills/core/types.js.map +1 -0
- package/dist/skills/index.d.ts +12 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +12 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/utils/content-loader.d.ts +25 -0
- package/dist/skills/utils/content-loader.d.ts.map +1 -0
- package/dist/skills/utils/content-loader.js +161 -0
- package/dist/skills/utils/content-loader.js.map +1 -0
- package/dist/skills/utils/frontmatter.d.ts +60 -0
- package/dist/skills/utils/frontmatter.d.ts.map +1 -0
- package/dist/skills/utils/frontmatter.js +114 -0
- package/dist/skills/utils/frontmatter.js.map +1 -0
- package/dist/skills/utils/pattern-matcher.d.ts +60 -0
- package/dist/skills/utils/pattern-matcher.d.ts.map +1 -0
- package/dist/skills/utils/pattern-matcher.js +97 -0
- package/dist/skills/utils/pattern-matcher.js.map +1 -0
- package/dist/utils/installation-detector.d.ts +22 -0
- package/dist/utils/installation-detector.d.ts.map +1 -0
- package/dist/utils/installation-detector.js +49 -0
- package/dist/utils/installation-detector.js.map +1 -0
- package/dist/utils/native-installer.d.ts +49 -0
- package/dist/utils/native-installer.d.ts.map +1 -0
- package/dist/utils/native-installer.js +194 -0
- package/dist/utils/native-installer.js.map +1 -0
- package/dist/utils/version-utils.d.ts +50 -0
- package/dist/utils/version-utils.d.ts.map +1 -0
- package/dist/utils/version-utils.js +92 -0
- package/dist/utils/version-utils.js.map +1 -0
- package/package.json +5 -2
- package/scripts/copy-mr-skill-to-global.ts +252 -0
- package/scripts/demo-hooks.sh +125 -0
- package/scripts/test-hooks.sh +196 -0
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/INDEX.md +0 -205
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/TEMPLATE_SIZES.md +0 -74
- package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/layered-architecture.md.template +0 -143
- 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
|
-
|
|
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
|
-
|
|
19
|
+
---
|
|
6
20
|
|
|
7
|
-
|
|
8
|
-
**Complexity**: High
|
|
9
|
-
**Prerequisites**: OWASP Top 10, [AUTH_METHOD]
|
|
21
|
+
## Authentication Flow
|
|
10
22
|
|
|
11
|
-
|
|
23
|
+
<!-- Extract actual auth implementation -->
|
|
12
24
|
|
|
13
|
-
|
|
25
|
+
### How Auth Works
|
|
14
26
|
|
|
15
|
-
|
|
27
|
+
```
|
|
28
|
+
[Request] → [Auth Middleware] → [Token/Session Validation] → [User Context]
|
|
29
|
+
│
|
|
30
|
+
▼ (on failure)
|
|
31
|
+
401 Unauthorized
|
|
32
|
+
```
|
|
16
33
|
|
|
17
|
-
|
|
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
|
-
|
|
27
|
-
|
|
36
|
+
```[lang]
|
|
37
|
+
// Source: [file:lines]
|
|
38
|
+
[Extract auth middleware/guard usage]
|
|
39
|
+
```
|
|
28
40
|
|
|
29
|
-
|
|
41
|
+
### Token/Session Details
|
|
30
42
|
|
|
31
|
-
|
|
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
|
-
###
|
|
50
|
+
### Protect a Route
|
|
34
51
|
|
|
35
|
-
```[
|
|
36
|
-
|
|
37
|
-
[
|
|
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
|
-
|
|
61
|
+
<!-- Find permission/role checking patterns -->
|
|
49
62
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
[
|
|
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
|
-
|
|
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
|
-
|
|
90
|
+
<!-- Find validation at API boundaries -->
|
|
91
|
+
|
|
92
|
+
### Validation Layer
|
|
62
93
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
- ✅
|
|
71
|
-
- ✅
|
|
72
|
-
- ❌
|
|
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
|
-
|
|
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
|
-
```
|
|
81
|
-
|
|
82
|
-
[
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
- ✅
|
|
90
|
-
- ✅
|
|
91
|
-
- ❌ Hardcode in code
|
|
92
|
-
- ❌ Commit
|
|
93
|
-
- ❌ Log
|
|
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
|
-
##
|
|
153
|
+
## Security Middleware
|
|
154
|
+
|
|
155
|
+
<!-- Find security-related middleware/headers -->
|
|
98
156
|
|
|
99
|
-
|
|
100
|
-
# Good: Parameterized
|
|
101
|
-
[good_sql_example]
|
|
157
|
+
### Configured Protections
|
|
102
158
|
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
[
|
|
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
|
-
**
|
|
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
|
|
222
|
+
## File Upload Security
|
|
127
223
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
[
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
##
|
|
240
|
+
## Audit Logging
|
|
241
|
+
|
|
242
|
+
<!-- Find security event logging -->
|
|
243
|
+
|
|
244
|
+
**Logged Events**:
|
|
140
245
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
|
260
|
+
## Dependency Security
|
|
150
261
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
##
|
|
270
|
+
## Security Anti-Patterns
|
|
271
|
+
|
|
272
|
+
<!-- Extract from code review or detected issues -->
|
|
165
273
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
**
|
|
8
|
-
**Complexity**: Simple
|
|
9
|
-
**Prerequisites**: [LANGUAGE], [LINTER], [FORMATTER]
|
|
34
|
+
**Before committing, run**: `[primary quality command]`
|
|
10
35
|
|
|
11
36
|
---
|
|
12
37
|
|
|
13
|
-
##
|
|
38
|
+
## Enforced Rules
|
|
14
39
|
|
|
15
|
-
|
|
40
|
+
<!-- Extract key rules from linter/formatter config -->
|
|
16
41
|
|
|
17
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
-
##
|
|
63
|
+
## Naming Standards
|
|
64
|
+
|
|
65
|
+
<!-- Extract from linter rules + analyze codebase patterns -->
|
|
32
66
|
|
|
33
|
-
|
|
|
34
|
-
|
|
35
|
-
| [
|
|
36
|
-
| [
|
|
37
|
-
| [
|
|
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
|
-
##
|
|
78
|
+
## Type Safety
|
|
42
79
|
|
|
43
|
-
|
|
44
|
-
# Lint (check)
|
|
45
|
-
[lint_check]
|
|
80
|
+
<!-- Detect type checking level and requirements -->
|
|
46
81
|
|
|
47
|
-
|
|
48
|
-
[
|
|
82
|
+
**Strictness**: `[strict / moderate / basic / none]`
|
|
83
|
+
**Config**: `[tsconfig.json / mypy.ini / pyproject.toml section]`
|
|
49
84
|
|
|
50
|
-
|
|
51
|
-
[format]
|
|
85
|
+
### Required Typing
|
|
52
86
|
|
|
53
|
-
|
|
54
|
-
[
|
|
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
|
-
|
|
95
|
+
### Type Rules
|
|
60
96
|
|
|
61
|
-
|
|
|
62
|
-
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
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
|
-
##
|
|
106
|
+
## Code Complexity Limits
|
|
72
107
|
|
|
73
|
-
|
|
74
|
-
# Source: [file:lines]
|
|
75
|
-
[type_example]
|
|
76
|
-
```
|
|
108
|
+
<!-- Extract from linter config or establish from codebase patterns -->
|
|
77
109
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
120
|
+
```[lang]
|
|
121
|
+
// ❌ Too complex
|
|
122
|
+
[Extract or create example of deep nesting/long function]
|
|
86
123
|
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
##
|
|
130
|
+
## Import Organization
|
|
98
131
|
|
|
99
|
-
|
|
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
|
-
|
|
137
|
+
// Group 1: [Built-in/Standard library]
|
|
138
|
+
[imports]
|
|
108
139
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
140
|
+
// Group 2: [External/Third-party packages]
|
|
141
|
+
[imports]
|
|
142
|
+
|
|
143
|
+
// Group 3: [Internal/Local modules]
|
|
144
|
+
[imports]
|
|
112
145
|
```
|
|
113
146
|
|
|
114
|
-
**
|
|
115
|
-
- ✅
|
|
116
|
-
- ✅
|
|
117
|
-
-
|
|
118
|
-
- ❌
|
|
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
|
-
##
|
|
155
|
+
## Documentation Standards
|
|
123
156
|
|
|
124
|
-
|
|
125
|
-
# Install
|
|
126
|
-
[install_hooks]
|
|
127
|
-
```
|
|
157
|
+
<!-- Extract from docstring linter rules or conventions -->
|
|
128
158
|
|
|
129
|
-
|
|
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
|
-
|
|
168
|
+
### Format
|
|
134
169
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
##
|
|
177
|
+
## Common Violations & Fixes
|
|
146
178
|
|
|
147
|
-
|
|
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
|
+
|
|