oh-my-customcode 0.12.1 → 0.12.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.
- package/README.md +4 -8
- package/dist/cli/index.js +137 -336
- package/dist/index.js +99 -260
- package/package.json +2 -4
- package/templates/.codex/agents/arch-documenter.md +0 -33
- package/templates/.codex/agents/arch-speckit-agent.md +0 -47
- package/templates/.codex/agents/be-express-expert.md +0 -30
- package/templates/.codex/agents/be-fastapi-expert.md +0 -43
- package/templates/.codex/agents/be-go-backend-expert.md +0 -43
- package/templates/.codex/agents/be-nestjs-expert.md +0 -28
- package/templates/.codex/agents/be-springboot-expert.md +0 -40
- package/templates/.codex/agents/db-postgres-expert.md +0 -36
- package/templates/.codex/agents/db-redis-expert.md +0 -36
- package/templates/.codex/agents/db-supabase-expert.md +0 -35
- package/templates/.codex/agents/de-airflow-expert.md +0 -34
- package/templates/.codex/agents/de-dbt-expert.md +0 -34
- package/templates/.codex/agents/de-kafka-expert.md +0 -81
- package/templates/.codex/agents/de-pipeline-expert.md +0 -32
- package/templates/.codex/agents/de-snowflake-expert.md +0 -36
- package/templates/.codex/agents/de-spark-expert.md +0 -36
- package/templates/.codex/agents/fe-svelte-agent.md +0 -29
- package/templates/.codex/agents/fe-vercel-agent.md +0 -37
- package/templates/.codex/agents/fe-vuejs-agent.md +0 -30
- package/templates/.codex/agents/infra-aws-expert.md +0 -47
- package/templates/.codex/agents/infra-docker-expert.md +0 -47
- package/templates/.codex/agents/lang-golang-expert.md +0 -43
- package/templates/.codex/agents/lang-java21-expert.md +0 -39
- package/templates/.codex/agents/lang-kotlin-expert.md +0 -43
- package/templates/.codex/agents/lang-python-expert.md +0 -43
- package/templates/.codex/agents/lang-rust-expert.md +0 -43
- package/templates/.codex/agents/lang-typescript-expert.md +0 -43
- package/templates/.codex/agents/mgr-claude-code-bible.md +0 -58
- package/templates/.codex/agents/mgr-creator.md +0 -39
- package/templates/.codex/agents/mgr-gitnerd.md +0 -45
- package/templates/.codex/agents/mgr-sauron.md +0 -161
- package/templates/.codex/agents/mgr-supplier.md +0 -35
- package/templates/.codex/agents/mgr-sync-checker.md +0 -38
- package/templates/.codex/agents/mgr-updater.md +0 -33
- package/templates/.codex/agents/qa-engineer.md +0 -32
- package/templates/.codex/agents/qa-planner.md +0 -73
- package/templates/.codex/agents/qa-writer.md +0 -27
- package/templates/.codex/agents/sys-memory-keeper.md +0 -43
- package/templates/.codex/agents/sys-naggy.md +0 -37
- package/templates/.codex/agents/tool-bun-expert.md +0 -26
- package/templates/.codex/agents/tool-npm-expert.md +0 -30
- package/templates/.codex/agents/tool-optimizer.md +0 -34
- package/templates/.codex/codex-native-hash.txt +0 -1
- package/templates/.codex/contexts/dev.md +0 -20
- package/templates/.codex/contexts/ecomode.md +0 -63
- package/templates/.codex/contexts/index.yaml +0 -41
- package/templates/.codex/contexts/research.md +0 -28
- package/templates/.codex/contexts/review.md +0 -23
- package/templates/.codex/hooks/hooks.json +0 -150
- package/templates/.codex/install-hooks.sh +0 -100
- package/templates/.codex/rules/MAY-optimization.md +0 -29
- package/templates/.codex/rules/MUST-agent-design.md +0 -57
- package/templates/.codex/rules/MUST-agent-identification.md +0 -29
- package/templates/.codex/rules/MUST-continuous-improvement.md +0 -25
- package/templates/.codex/rules/MUST-intent-transparency.md +0 -42
- package/templates/.codex/rules/MUST-language-policy.md +0 -27
- package/templates/.codex/rules/MUST-orchestrator-coordination.md +0 -128
- package/templates/.codex/rules/MUST-parallel-execution.md +0 -97
- package/templates/.codex/rules/MUST-permissions.md +0 -30
- package/templates/.codex/rules/MUST-safety.md +0 -23
- package/templates/.codex/rules/MUST-sync-verification.md +0 -125
- package/templates/.codex/rules/MUST-tool-identification.md +0 -82
- package/templates/.codex/rules/SHOULD-agent-teams.md +0 -39
- package/templates/.codex/rules/SHOULD-ecomode.md +0 -37
- package/templates/.codex/rules/SHOULD-error-handling.md +0 -33
- package/templates/.codex/rules/SHOULD-hud-statusline.md +0 -32
- package/templates/.codex/rules/SHOULD-interaction.md +0 -34
- package/templates/.codex/rules/SHOULD-memory-integration.md +0 -39
- package/templates/.codex/rules/index.yaml +0 -141
- package/templates/.codex/skills/airflow-best-practices/SKILL.md +0 -56
- package/templates/.codex/skills/audit-agents/SKILL.md +0 -116
- package/templates/.codex/skills/aws-best-practices/SKILL.md +0 -280
- package/templates/.codex/skills/claude-code-bible/SKILL.md +0 -100
- package/templates/.codex/skills/claude-code-bible/scripts/fetch-docs.js +0 -272
- package/templates/.codex/skills/create-agent/SKILL.md +0 -91
- package/templates/.codex/skills/dbt-best-practices/SKILL.md +0 -54
- package/templates/.codex/skills/de-lead-routing/SKILL.md +0 -243
- package/templates/.codex/skills/dev-lead-routing/SKILL.md +0 -94
- package/templates/.codex/skills/dev-refactor/SKILL.md +0 -123
- package/templates/.codex/skills/dev-review/SKILL.md +0 -81
- package/templates/.codex/skills/docker-best-practices/SKILL.md +0 -275
- package/templates/.codex/skills/fastapi-best-practices/SKILL.md +0 -270
- package/templates/.codex/skills/fix-refs/SKILL.md +0 -107
- package/templates/.codex/skills/go-backend-best-practices/SKILL.md +0 -338
- package/templates/.codex/skills/go-best-practices/SKILL.md +0 -203
- package/templates/.codex/skills/help/SKILL.md +0 -125
- package/templates/.codex/skills/intent-detection/SKILL.md +0 -215
- package/templates/.codex/skills/intent-detection/patterns/agent-triggers.yaml +0 -349
- package/templates/.codex/skills/kafka-best-practices/SKILL.md +0 -52
- package/templates/.codex/skills/kotlin-best-practices/SKILL.md +0 -256
- package/templates/.codex/skills/lists/SKILL.md +0 -78
- package/templates/.codex/skills/memory-management/SKILL.md +0 -195
- package/templates/.codex/skills/memory-recall/SKILL.md +0 -152
- package/templates/.codex/skills/memory-save/SKILL.md +0 -126
- package/templates/.codex/skills/monitoring-setup/SKILL.md +0 -115
- package/templates/.codex/skills/npm-audit/SKILL.md +0 -72
- package/templates/.codex/skills/npm-publish/SKILL.md +0 -63
- package/templates/.codex/skills/npm-version/SKILL.md +0 -75
- package/templates/.codex/skills/optimize-analyze/SKILL.md +0 -55
- package/templates/.codex/skills/optimize-bundle/SKILL.md +0 -67
- package/templates/.codex/skills/optimize-report/SKILL.md +0 -74
- package/templates/.codex/skills/pipeline-architecture-patterns/SKILL.md +0 -83
- package/templates/.codex/skills/postgres-best-practices/SKILL.md +0 -66
- package/templates/.codex/skills/python-best-practices/SKILL.md +0 -222
- package/templates/.codex/skills/qa-lead-routing/SKILL.md +0 -290
- package/templates/.codex/skills/react-best-practices/SKILL.md +0 -101
- package/templates/.codex/skills/redis-best-practices/SKILL.md +0 -83
- package/templates/.codex/skills/result-aggregation/SKILL.md +0 -164
- package/templates/.codex/skills/rust-best-practices/SKILL.md +0 -267
- package/templates/.codex/skills/sauron-watch/SKILL.md +0 -144
- package/templates/.codex/skills/secretary-routing/SKILL.md +0 -203
- package/templates/.codex/skills/snowflake-best-practices/SKILL.md +0 -65
- package/templates/.codex/skills/spark-best-practices/SKILL.md +0 -52
- package/templates/.codex/skills/springboot-best-practices/SKILL.md +0 -218
- package/templates/.codex/skills/status/SKILL.md +0 -153
- package/templates/.codex/skills/supabase-postgres-best-practices/SKILL.md +0 -99
- package/templates/.codex/skills/typescript-best-practices/SKILL.md +0 -321
- package/templates/.codex/skills/update-docs/SKILL.md +0 -140
- package/templates/.codex/skills/update-external/SKILL.md +0 -149
- package/templates/.codex/skills/vercel-deploy/SKILL.md +0 -73
- package/templates/.codex/skills/web-design-guidelines/SKILL.md +0 -118
- package/templates/.codex/skills/writing-clearly-and-concisely/SKILL.md +0 -64
- package/templates/.codex/uninstall-hooks.sh +0 -52
- package/templates/AGENTS.md.en +0 -39
- package/templates/AGENTS.md.ko +0 -39
- package/templates/manifest.codex.json +0 -43
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dev-lead-routing
|
|
3
|
-
description: Routes development tasks to the correct language or framework expert agent. Use when user requests code review, implementation, refactoring, or debugging.
|
|
4
|
-
user-invocable: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Dev Lead Routing
|
|
8
|
-
|
|
9
|
-
## Engineers
|
|
10
|
-
|
|
11
|
-
| Type | Agents |
|
|
12
|
-
|------|--------|
|
|
13
|
-
| Language | lang-golang-expert, lang-python-expert, lang-rust-expert, lang-kotlin-expert, lang-typescript-expert, lang-java21-expert |
|
|
14
|
-
| Frontend | fe-vercel-agent, fe-vuejs-agent, fe-svelte-agent |
|
|
15
|
-
| Backend | be-fastapi-expert, be-springboot-expert, be-go-backend-expert, be-nestjs-expert, be-express-expert |
|
|
16
|
-
| Tooling | tool-npm-expert, tool-optimizer, tool-bun-expert |
|
|
17
|
-
| Database | db-supabase-expert, db-postgres-expert, db-redis-expert |
|
|
18
|
-
| Architect | arch-documenter, arch-speckit-agent |
|
|
19
|
-
| Infra | infra-docker-expert, infra-aws-expert |
|
|
20
|
-
|
|
21
|
-
## File Extension Mapping
|
|
22
|
-
|
|
23
|
-
| Extension | Agent |
|
|
24
|
-
|-----------|-------|
|
|
25
|
-
| `.go` | lang-golang-expert |
|
|
26
|
-
| `.py` | lang-python-expert |
|
|
27
|
-
| `.rs` | lang-rust-expert |
|
|
28
|
-
| `.kt`, `.kts` | lang-kotlin-expert |
|
|
29
|
-
| `.ts`, `.tsx` | lang-typescript-expert |
|
|
30
|
-
| `.java` | lang-java21-expert |
|
|
31
|
-
| `.js/.jsx` (React) | fe-vercel-agent |
|
|
32
|
-
| `.vue` | fe-vuejs-agent |
|
|
33
|
-
| `.svelte` | fe-svelte-agent |
|
|
34
|
-
| `.sql` (PG) | db-postgres-expert |
|
|
35
|
-
| `.sql` (Supabase) | db-supabase-expert |
|
|
36
|
-
| `Dockerfile`, `*.dockerfile` | infra-docker-expert |
|
|
37
|
-
| `*.tf`, `*.tfvars` | infra-aws-expert |
|
|
38
|
-
| `*.yaml`, `*.yml` (CloudFormation) | infra-aws-expert |
|
|
39
|
-
|
|
40
|
-
## Keyword Mapping
|
|
41
|
-
|
|
42
|
-
| Keywords | Agent |
|
|
43
|
-
|----------|-------|
|
|
44
|
-
| go, golang | lang-golang-expert |
|
|
45
|
-
| python, py | lang-python-expert |
|
|
46
|
-
| rust | lang-rust-expert |
|
|
47
|
-
| kotlin | lang-kotlin-expert |
|
|
48
|
-
| typescript, ts | lang-typescript-expert |
|
|
49
|
-
| java | lang-java21-expert |
|
|
50
|
-
| react, next.js, vercel | fe-vercel-agent |
|
|
51
|
-
| vue | fe-vuejs-agent |
|
|
52
|
-
| svelte | fe-svelte-agent |
|
|
53
|
-
| fastapi | be-fastapi-expert |
|
|
54
|
-
| spring, springboot | be-springboot-expert |
|
|
55
|
-
| nestjs | be-nestjs-expert |
|
|
56
|
-
| express | be-express-expert |
|
|
57
|
-
| npm | tool-npm-expert |
|
|
58
|
-
| optimize, bundle | tool-optimizer |
|
|
59
|
-
| bun | tool-bun-expert |
|
|
60
|
-
| postgres, postgresql, psql, pg_stat | db-postgres-expert |
|
|
61
|
-
| redis, cache, pub/sub, sorted set | db-redis-expert |
|
|
62
|
-
| supabase, rls, edge function | db-supabase-expert |
|
|
63
|
-
| docker, dockerfile, container, compose | infra-docker-expert |
|
|
64
|
-
| aws, cloudformation, vpc, iam, s3, lambda, cdk, terraform | infra-aws-expert |
|
|
65
|
-
| architecture, adr, openapi, swagger, diagram | arch-documenter |
|
|
66
|
-
| spec, specification, tdd, requirements | arch-speckit-agent |
|
|
67
|
-
|
|
68
|
-
## Model Selection
|
|
69
|
-
|
|
70
|
-
| Task | Model |
|
|
71
|
-
|------|-------|
|
|
72
|
-
| Architecture analysis | reasoning |
|
|
73
|
-
| Code review/implementation | balanced |
|
|
74
|
-
| Quick validation/search | fast |
|
|
75
|
-
|
|
76
|
-
## Routing Rules
|
|
77
|
-
|
|
78
|
-
Multi-language: detect all languages, route to parallel experts (max 4). Single-language: route to matching expert. Cross-layer (frontend + backend): multiple experts in parallel.
|
|
79
|
-
|
|
80
|
-
## Agent Teams Awareness
|
|
81
|
-
|
|
82
|
-
Before routing via Task tool, check if Agent Teams is available (`CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1` or TeamCreate/SendMessage tools present).
|
|
83
|
-
|
|
84
|
-
**Self-check:** Does this task need 3+ agents, shared state, or inter-agent communication? If yes, prefer Agent Teams over Task tool. See R018 for the full decision matrix.
|
|
85
|
-
|
|
86
|
-
| Scenario | Preferred |
|
|
87
|
-
|----------|-----------|
|
|
88
|
-
| Single-language review | Task Tool |
|
|
89
|
-
| Multi-language code review (3+) | Agent Teams |
|
|
90
|
-
| Code review + fix cycle | Agent Teams |
|
|
91
|
-
| Cross-layer debugging (FE + BE + DB) | Agent Teams |
|
|
92
|
-
| Simple file search/validation | Task Tool |
|
|
93
|
-
|
|
94
|
-
Not user-invocable. Auto-triggered on development intent.
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dev-refactor
|
|
3
|
-
description: Refactor code for better structure and patterns
|
|
4
|
-
argument-hint: "<file-or-directory> [--lang <language>]"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Code Refactoring Skill
|
|
8
|
-
|
|
9
|
-
Refactor code for better structure, naming, and patterns using language-specific expert agents.
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Name | Type | Required | Description |
|
|
14
|
-
|------|------|----------|-------------|
|
|
15
|
-
| path | string | yes | File or directory to refactor |
|
|
16
|
-
|
|
17
|
-
## Options
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
--lang, -l Language (auto-detected if not specified)
|
|
21
|
-
Values: go, python, rust, kotlin, typescript, java
|
|
22
|
-
--focus, -f Focus area (structure, naming, patterns, all)
|
|
23
|
-
--dry-run Show proposed changes without applying
|
|
24
|
-
--verbose, -v Detailed output
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Workflow
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
1. Detect language (or use --lang)
|
|
31
|
-
2. Select appropriate expert agent
|
|
32
|
-
3. Load language-specific skill
|
|
33
|
-
4. Analyze code structure
|
|
34
|
-
5. Propose refactoring changes
|
|
35
|
-
6. Apply changes (if not --dry-run)
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Agent Selection
|
|
39
|
-
|
|
40
|
-
| File Extension | Agent | Skill |
|
|
41
|
-
|----------------|-------|-------|
|
|
42
|
-
| .go | lang-golang-expert | go-best-practices |
|
|
43
|
-
| .py | lang-python-expert | python-best-practices |
|
|
44
|
-
| .rs | lang-rust-expert | rust-best-practices |
|
|
45
|
-
| .kt | lang-kotlin-expert | kotlin-best-practices |
|
|
46
|
-
| .ts, .tsx | lang-typescript-expert | typescript-best-practices |
|
|
47
|
-
| .java | be-springboot-expert | springboot-best-practices |
|
|
48
|
-
| .jsx, .js (React) | fe-vercel-agent | react-best-practices |
|
|
49
|
-
|
|
50
|
-
## Refactoring Categories
|
|
51
|
-
|
|
52
|
-
| Category | Description |
|
|
53
|
-
|----------|-------------|
|
|
54
|
-
| structure | File/module organization, package structure |
|
|
55
|
-
| naming | Variable, function, type naming conventions |
|
|
56
|
-
| patterns | Design patterns, idiomatic code |
|
|
57
|
-
| duplication | Extract common code, reduce repetition |
|
|
58
|
-
| complexity | Simplify complex functions, reduce nesting |
|
|
59
|
-
|
|
60
|
-
## Output Format
|
|
61
|
-
|
|
62
|
-
### Dry Run
|
|
63
|
-
```
|
|
64
|
-
[dev:refactor src/utils.go --dry-run]
|
|
65
|
-
|
|
66
|
-
┌─ Agent: lang-golang-expert (sw-engineer)
|
|
67
|
-
├─ Skill: go-best-practices
|
|
68
|
-
└─ File: src/utils.go
|
|
69
|
-
|
|
70
|
-
Analysis:
|
|
71
|
-
|
|
72
|
-
[Structure] Lines 10-45
|
|
73
|
-
Issue: Function too long (35 lines)
|
|
74
|
-
Suggest: Extract helper functions
|
|
75
|
-
|
|
76
|
-
[Naming] Line 12
|
|
77
|
-
Issue: Abbreviation in function name
|
|
78
|
-
Found: func procData()
|
|
79
|
-
Suggest: func processData()
|
|
80
|
-
|
|
81
|
-
[Patterns] Lines 20-30
|
|
82
|
-
Issue: Repeated error handling pattern
|
|
83
|
-
Suggest: Create handleError() helper
|
|
84
|
-
|
|
85
|
-
Proposed Changes:
|
|
86
|
-
1. Extract lines 15-25 into validateInput()
|
|
87
|
-
2. Rename procData → processData
|
|
88
|
-
3. Create handleError() helper function
|
|
89
|
-
|
|
90
|
-
No changes made (dry-run mode).
|
|
91
|
-
Run without --dry-run to apply changes.
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Apply Changes
|
|
95
|
-
```
|
|
96
|
-
[dev:refactor src/utils.go]
|
|
97
|
-
|
|
98
|
-
┌─ Agent: lang-golang-expert (sw-engineer)
|
|
99
|
-
├─ Skill: go-best-practices
|
|
100
|
-
└─ File: src/utils.go
|
|
101
|
-
|
|
102
|
-
Refactoring:
|
|
103
|
-
|
|
104
|
-
[1/3] Extracting validateInput()...
|
|
105
|
-
✓ Created function at line 50
|
|
106
|
-
✓ Updated calls at lines 15, 22
|
|
107
|
-
|
|
108
|
-
[2/3] Renaming procData → processData...
|
|
109
|
-
✓ Renamed function definition
|
|
110
|
-
✓ Updated 3 call sites
|
|
111
|
-
|
|
112
|
-
[3/3] Creating handleError() helper...
|
|
113
|
-
✓ Created function at line 60
|
|
114
|
-
✓ Replaced 5 error handling blocks
|
|
115
|
-
|
|
116
|
-
Summary:
|
|
117
|
-
Changes applied: 3
|
|
118
|
-
Lines modified: 28
|
|
119
|
-
Functions added: 2
|
|
120
|
-
Functions renamed: 1
|
|
121
|
-
|
|
122
|
-
Recommendation: Run tests to verify changes.
|
|
123
|
-
```
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dev-review
|
|
3
|
-
description: Review code against language-specific best practices
|
|
4
|
-
argument-hint: "<file-or-directory> [--lang <language>]"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Code Review Skill
|
|
8
|
-
|
|
9
|
-
Review code for best practices using language-specific expert agents.
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Name | Type | Required | Description |
|
|
14
|
-
|------|------|----------|-------------|
|
|
15
|
-
| path | string | yes | File or directory to review |
|
|
16
|
-
|
|
17
|
-
## Options
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
--lang, -l Language (auto-detected if not specified)
|
|
21
|
-
Values: go, python, rust, kotlin, typescript, java
|
|
22
|
-
--focus, -f Focus area (style, performance, security, all)
|
|
23
|
-
--verbose, -v Detailed output
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Workflow
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
1. Detect language (or use --lang)
|
|
30
|
-
2. Select appropriate expert agent
|
|
31
|
-
3. Load language-specific skill
|
|
32
|
-
4. Analyze code against best practices
|
|
33
|
-
5. Generate review report
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Agent Selection
|
|
37
|
-
|
|
38
|
-
| File Extension | Agent | Skill |
|
|
39
|
-
|----------------|-------|-------|
|
|
40
|
-
| .go | lang-golang-expert | go-best-practices |
|
|
41
|
-
| .py | lang-python-expert | python-best-practices |
|
|
42
|
-
| .rs | lang-rust-expert | rust-best-practices |
|
|
43
|
-
| .kt | lang-kotlin-expert | kotlin-best-practices |
|
|
44
|
-
| .ts, .tsx | lang-typescript-expert | typescript-best-practices |
|
|
45
|
-
| .java | be-springboot-expert | springboot-best-practices |
|
|
46
|
-
| .jsx, .js (React) | fe-vercel-agent | react-best-practices |
|
|
47
|
-
|
|
48
|
-
## Output Format
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
[dev:review src/main.go]
|
|
52
|
-
|
|
53
|
-
┌─ Agent: lang-golang-expert (sw-engineer)
|
|
54
|
-
├─ Skill: go-best-practices
|
|
55
|
-
└─ File: src/main.go
|
|
56
|
-
|
|
57
|
-
Review Results:
|
|
58
|
-
|
|
59
|
-
[Style] Line 15
|
|
60
|
-
Issue: Variable name should be camelCase
|
|
61
|
-
Found: user_name
|
|
62
|
-
Suggest: userName
|
|
63
|
-
|
|
64
|
-
[Error Handling] Line 42
|
|
65
|
-
Issue: Error not checked
|
|
66
|
-
Found: file.Close()
|
|
67
|
-
Suggest: if err := file.Close(); err != nil { ... }
|
|
68
|
-
|
|
69
|
-
[Performance] Line 78
|
|
70
|
-
Issue: Inefficient string concatenation in loop
|
|
71
|
-
Found: str += item
|
|
72
|
-
Suggest: Use strings.Builder
|
|
73
|
-
|
|
74
|
-
Summary:
|
|
75
|
-
Style: 1 issue
|
|
76
|
-
Error Handling: 1 issue
|
|
77
|
-
Performance: 1 issue
|
|
78
|
-
Total: 3 issues
|
|
79
|
-
|
|
80
|
-
Recommendation: Fix error handling issues first.
|
|
81
|
-
```
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: docker-best-practices
|
|
3
|
-
description: Docker patterns for optimized containerization
|
|
4
|
-
user-invocable: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Purpose
|
|
8
|
-
|
|
9
|
-
Apply Docker patterns for building optimized and secure container images.
|
|
10
|
-
|
|
11
|
-
## Rules
|
|
12
|
-
|
|
13
|
-
### 1. Layer Optimization
|
|
14
|
-
|
|
15
|
-
```yaml
|
|
16
|
-
principles:
|
|
17
|
-
- Combine related RUN commands
|
|
18
|
-
- Sort multi-line arguments alphabetically
|
|
19
|
-
- Clean up in same layer
|
|
20
|
-
|
|
21
|
-
patterns: |
|
|
22
|
-
# GOOD: Single layer, clean cache
|
|
23
|
-
RUN apt-get update && apt-get install -y \
|
|
24
|
-
curl \
|
|
25
|
-
git \
|
|
26
|
-
vim \
|
|
27
|
-
&& rm -rf /var/lib/apt/lists/*
|
|
28
|
-
|
|
29
|
-
# BAD: Multiple layers, cache remains
|
|
30
|
-
RUN apt-get update
|
|
31
|
-
RUN apt-get install -y curl
|
|
32
|
-
RUN apt-get install -y git
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 2. Multi-Stage Builds
|
|
36
|
-
|
|
37
|
-
```yaml
|
|
38
|
-
purpose:
|
|
39
|
-
- Reduce final image size
|
|
40
|
-
- Separate build and runtime dependencies
|
|
41
|
-
- Security (no build tools in production)
|
|
42
|
-
|
|
43
|
-
pattern: |
|
|
44
|
-
# Build stage
|
|
45
|
-
FROM golang:1.21 AS builder
|
|
46
|
-
WORKDIR /app
|
|
47
|
-
COPY go.mod go.sum ./
|
|
48
|
-
RUN go mod download
|
|
49
|
-
COPY . .
|
|
50
|
-
RUN CGO_ENABLED=0 go build -o /app/server ./cmd/server
|
|
51
|
-
|
|
52
|
-
# Runtime stage
|
|
53
|
-
FROM gcr.io/distroless/static:nonroot
|
|
54
|
-
COPY --from=builder /app/server /server
|
|
55
|
-
USER nonroot:nonroot
|
|
56
|
-
ENTRYPOINT ["/server"]
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### 3. Security
|
|
60
|
-
|
|
61
|
-
```yaml
|
|
62
|
-
principles:
|
|
63
|
-
- Run as non-root user
|
|
64
|
-
- Pin base image versions
|
|
65
|
-
- Use minimal base images
|
|
66
|
-
- Don't store secrets in images
|
|
67
|
-
|
|
68
|
-
patterns: |
|
|
69
|
-
# Pin version with digest
|
|
70
|
-
FROM node:20-slim@sha256:abc123...
|
|
71
|
-
|
|
72
|
-
# Create non-root user
|
|
73
|
-
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
|
|
74
|
-
USER appuser
|
|
75
|
-
|
|
76
|
-
# Use secrets mount (BuildKit)
|
|
77
|
-
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc \
|
|
78
|
-
npm install
|
|
79
|
-
|
|
80
|
-
# .dockerignore for secrets
|
|
81
|
-
# .env
|
|
82
|
-
# *.pem
|
|
83
|
-
# credentials.json
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### 4. Image Size Reduction
|
|
87
|
-
|
|
88
|
-
```yaml
|
|
89
|
-
strategies:
|
|
90
|
-
- Use slim/alpine base images
|
|
91
|
-
- Remove build dependencies
|
|
92
|
-
- Use .dockerignore
|
|
93
|
-
- Multi-stage builds
|
|
94
|
-
|
|
95
|
-
minimal_bases:
|
|
96
|
-
distroless: "gcr.io/distroless/static"
|
|
97
|
-
alpine: "alpine:3.19"
|
|
98
|
-
slim: "debian:12-slim"
|
|
99
|
-
|
|
100
|
-
patterns: |
|
|
101
|
-
# Alpine for size
|
|
102
|
-
FROM python:3.12-alpine
|
|
103
|
-
RUN apk add --no-cache gcc musl-dev
|
|
104
|
-
|
|
105
|
-
# Distroless for security
|
|
106
|
-
FROM gcr.io/distroless/python3
|
|
107
|
-
COPY --from=builder /app /app
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### 5. Cache Optimization
|
|
111
|
-
|
|
112
|
-
```yaml
|
|
113
|
-
principles:
|
|
114
|
-
- Order from least to most frequently changing
|
|
115
|
-
- Copy dependency files first
|
|
116
|
-
- Use BuildKit cache mounts
|
|
117
|
-
|
|
118
|
-
patterns: |
|
|
119
|
-
# Copy dependency files first
|
|
120
|
-
COPY package.json package-lock.json ./
|
|
121
|
-
RUN npm ci
|
|
122
|
-
|
|
123
|
-
# Then copy source (changes frequently)
|
|
124
|
-
COPY . .
|
|
125
|
-
RUN npm run build
|
|
126
|
-
|
|
127
|
-
# BuildKit cache mount
|
|
128
|
-
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
129
|
-
pip install -r requirements.txt
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### 6. ENTRYPOINT vs CMD
|
|
133
|
-
|
|
134
|
-
```yaml
|
|
135
|
-
entrypoint:
|
|
136
|
-
purpose: Main executable
|
|
137
|
-
form: exec form ["executable"]
|
|
138
|
-
|
|
139
|
-
cmd:
|
|
140
|
-
purpose: Default arguments
|
|
141
|
-
form: exec form ["arg1", "arg2"]
|
|
142
|
-
|
|
143
|
-
patterns: |
|
|
144
|
-
# Fixed command with variable args
|
|
145
|
-
ENTRYPOINT ["python", "app.py"]
|
|
146
|
-
CMD ["--port", "8080"]
|
|
147
|
-
|
|
148
|
-
# docker run myapp --port 3000
|
|
149
|
-
# Executes: python app.py --port 3000
|
|
150
|
-
|
|
151
|
-
# Flexible command
|
|
152
|
-
CMD ["python", "app.py"]
|
|
153
|
-
|
|
154
|
-
# docker run myapp bash
|
|
155
|
-
# Executes: bash
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### 7. Health Checks
|
|
159
|
-
|
|
160
|
-
```yaml
|
|
161
|
-
purpose: Container health monitoring
|
|
162
|
-
interval: how often to check
|
|
163
|
-
timeout: max time for check
|
|
164
|
-
retries: failures before unhealthy
|
|
165
|
-
|
|
166
|
-
pattern: |
|
|
167
|
-
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
|
|
168
|
-
CMD curl -f http://localhost:8080/health || exit 1
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### 8. Docker Compose
|
|
172
|
-
|
|
173
|
-
```yaml
|
|
174
|
-
best_practices:
|
|
175
|
-
- Use named volumes
|
|
176
|
-
- Define networks explicitly
|
|
177
|
-
- Use environment files
|
|
178
|
-
- Set resource limits
|
|
179
|
-
|
|
180
|
-
pattern: |
|
|
181
|
-
version: "3.8"
|
|
182
|
-
|
|
183
|
-
services:
|
|
184
|
-
app:
|
|
185
|
-
build:
|
|
186
|
-
context: .
|
|
187
|
-
target: production
|
|
188
|
-
environment:
|
|
189
|
-
- DATABASE_URL
|
|
190
|
-
env_file:
|
|
191
|
-
- .env
|
|
192
|
-
ports:
|
|
193
|
-
- "8080:8080"
|
|
194
|
-
depends_on:
|
|
195
|
-
db:
|
|
196
|
-
condition: service_healthy
|
|
197
|
-
deploy:
|
|
198
|
-
resources:
|
|
199
|
-
limits:
|
|
200
|
-
cpus: "1"
|
|
201
|
-
memory: 512M
|
|
202
|
-
networks:
|
|
203
|
-
- backend
|
|
204
|
-
|
|
205
|
-
db:
|
|
206
|
-
image: postgres:16-alpine
|
|
207
|
-
volumes:
|
|
208
|
-
- postgres_data:/var/lib/postgresql/data
|
|
209
|
-
healthcheck:
|
|
210
|
-
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
211
|
-
interval: 10s
|
|
212
|
-
timeout: 5s
|
|
213
|
-
retries: 5
|
|
214
|
-
networks:
|
|
215
|
-
- backend
|
|
216
|
-
|
|
217
|
-
volumes:
|
|
218
|
-
postgres_data:
|
|
219
|
-
|
|
220
|
-
networks:
|
|
221
|
-
backend:
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### 9. Common Patterns by Language
|
|
225
|
-
|
|
226
|
-
```yaml
|
|
227
|
-
nodejs: |
|
|
228
|
-
FROM node:20-slim AS builder
|
|
229
|
-
WORKDIR /app
|
|
230
|
-
COPY package*.json ./
|
|
231
|
-
RUN npm ci --only=production
|
|
232
|
-
|
|
233
|
-
FROM gcr.io/distroless/nodejs20
|
|
234
|
-
WORKDIR /app
|
|
235
|
-
COPY --from=builder /app/node_modules ./node_modules
|
|
236
|
-
COPY . .
|
|
237
|
-
CMD ["server.js"]
|
|
238
|
-
|
|
239
|
-
python: |
|
|
240
|
-
FROM python:3.12-slim AS builder
|
|
241
|
-
WORKDIR /app
|
|
242
|
-
RUN pip install --user -r requirements.txt
|
|
243
|
-
|
|
244
|
-
FROM python:3.12-slim
|
|
245
|
-
WORKDIR /app
|
|
246
|
-
COPY --from=builder /root/.local /root/.local
|
|
247
|
-
COPY . .
|
|
248
|
-
ENV PATH=/root/.local/bin:$PATH
|
|
249
|
-
CMD ["python", "app.py"]
|
|
250
|
-
|
|
251
|
-
go: |
|
|
252
|
-
FROM golang:1.21 AS builder
|
|
253
|
-
WORKDIR /app
|
|
254
|
-
COPY go.* ./
|
|
255
|
-
RUN go mod download
|
|
256
|
-
COPY . .
|
|
257
|
-
RUN CGO_ENABLED=0 go build -o /server
|
|
258
|
-
|
|
259
|
-
FROM scratch
|
|
260
|
-
COPY --from=builder /server /server
|
|
261
|
-
ENTRYPOINT ["/server"]
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
## Application
|
|
265
|
-
|
|
266
|
-
When writing Dockerfiles:
|
|
267
|
-
|
|
268
|
-
1. **Always** use multi-stage builds
|
|
269
|
-
2. **Always** run as non-root user
|
|
270
|
-
3. **Always** pin base image versions
|
|
271
|
-
4. **Prefer** minimal base images
|
|
272
|
-
5. **Order** layers for cache efficiency
|
|
273
|
-
6. **Clean** package caches in same layer
|
|
274
|
-
7. **Use** .dockerignore
|
|
275
|
-
8. **Add** health checks
|