oh-my-customcode 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -12
- package/dist/cli/index.js +518 -274
- package/dist/index.js +304 -101
- package/package.json +1 -1
- package/templates/.claude/agents/db-postgres-expert.md +106 -0
- package/templates/.claude/agents/db-redis-expert.md +101 -0
- package/templates/.claude/agents/de-airflow-expert.md +71 -0
- package/templates/.claude/agents/de-dbt-expert.md +72 -0
- package/templates/.claude/agents/de-kafka-expert.md +81 -0
- package/templates/.claude/agents/de-pipeline-expert.md +92 -0
- package/templates/.claude/agents/de-snowflake-expert.md +89 -0
- package/templates/.claude/agents/de-spark-expert.md +80 -0
- package/templates/.claude/rules/SHOULD-agent-teams.md +47 -1
- package/templates/.claude/skills/airflow-best-practices/SKILL.md +56 -0
- package/templates/.claude/skills/dbt-best-practices/SKILL.md +54 -0
- package/templates/.claude/skills/de-lead-routing/SKILL.md +230 -0
- package/templates/.claude/skills/dev-lead-routing/SKILL.md +15 -0
- package/templates/.claude/skills/kafka-best-practices/SKILL.md +52 -0
- package/templates/.claude/skills/pipeline-architecture-patterns/SKILL.md +83 -0
- package/templates/.claude/skills/postgres-best-practices/SKILL.md +66 -0
- package/templates/.claude/skills/redis-best-practices/SKILL.md +83 -0
- package/templates/.claude/skills/secretary-routing/SKILL.md +12 -0
- package/templates/.claude/skills/snowflake-best-practices/SKILL.md +65 -0
- package/templates/.claude/skills/spark-best-practices/SKILL.md +52 -0
- package/templates/.codex/agents/arch-documenter.md +97 -0
- package/templates/.codex/agents/arch-speckit-agent.md +134 -0
- package/templates/.codex/agents/be-express-expert.md +80 -0
- package/templates/.codex/agents/be-fastapi-expert.md +43 -0
- package/templates/.codex/agents/be-go-backend-expert.md +43 -0
- package/templates/.codex/agents/be-nestjs-expert.md +60 -0
- package/templates/.codex/agents/be-springboot-expert.md +85 -0
- package/templates/.codex/agents/db-postgres-expert.md +106 -0
- package/templates/.codex/agents/db-redis-expert.md +101 -0
- package/templates/.codex/agents/db-supabase-expert.md +71 -0
- package/templates/.codex/agents/de-airflow-expert.md +71 -0
- package/templates/.codex/agents/de-dbt-expert.md +72 -0
- package/templates/.codex/agents/de-kafka-expert.md +81 -0
- package/templates/.codex/agents/de-pipeline-expert.md +92 -0
- package/templates/.codex/agents/de-snowflake-expert.md +89 -0
- package/templates/.codex/agents/de-spark-expert.md +80 -0
- package/templates/.codex/agents/fe-svelte-agent.md +65 -0
- package/templates/.codex/agents/fe-vercel-agent.md +69 -0
- package/templates/.codex/agents/fe-vuejs-agent.md +65 -0
- package/templates/.codex/agents/infra-aws-expert.md +47 -0
- package/templates/.codex/agents/infra-docker-expert.md +47 -0
- package/templates/.codex/agents/lang-golang-expert.md +43 -0
- package/templates/.codex/agents/lang-java21-expert.md +65 -0
- package/templates/.codex/agents/lang-kotlin-expert.md +43 -0
- package/templates/.codex/agents/lang-python-expert.md +43 -0
- package/templates/.codex/agents/lang-rust-expert.md +43 -0
- package/templates/.codex/agents/lang-typescript-expert.md +43 -0
- package/templates/.codex/agents/mgr-claude-code-bible.md +246 -0
- package/templates/.codex/agents/mgr-creator.md +120 -0
- package/templates/.codex/agents/mgr-gitnerd.md +113 -0
- package/templates/.codex/agents/mgr-sauron.md +154 -0
- package/templates/.codex/agents/mgr-supplier.md +120 -0
- package/templates/.codex/agents/mgr-sync-checker.md +99 -0
- package/templates/.codex/agents/mgr-updater.md +103 -0
- package/templates/.codex/agents/qa-engineer.md +96 -0
- package/templates/.codex/agents/qa-planner.md +74 -0
- package/templates/.codex/agents/qa-writer.md +97 -0
- package/templates/.codex/agents/sys-memory-keeper.md +117 -0
- package/templates/.codex/agents/sys-naggy.md +90 -0
- package/templates/.codex/agents/tool-bun-expert.md +71 -0
- package/templates/.codex/agents/tool-npm-expert.md +88 -0
- package/templates/.codex/agents/tool-optimizer.md +87 -0
- package/templates/.codex/codex-native-hash.txt +1 -0
- package/templates/.codex/contexts/dev.md +20 -0
- package/templates/.codex/contexts/ecomode.md +63 -0
- package/templates/.codex/contexts/index.yaml +41 -0
- package/templates/.codex/contexts/research.md +28 -0
- package/templates/.codex/contexts/review.md +23 -0
- package/templates/.codex/hooks/hooks.json +151 -0
- package/templates/.codex/install-hooks.sh +100 -0
- package/templates/.codex/rules/MAY-optimization.md +93 -0
- package/templates/.codex/rules/MUST-agent-design.md +162 -0
- package/templates/.codex/rules/MUST-agent-identification.md +108 -0
- package/templates/.codex/rules/MUST-continuous-improvement.md +132 -0
- package/templates/.codex/rules/MUST-intent-transparency.md +199 -0
- package/templates/.codex/rules/MUST-language-policy.md +62 -0
- package/templates/.codex/rules/MUST-orchestrator-coordination.md +471 -0
- package/templates/.codex/rules/MUST-parallel-execution.md +469 -0
- package/templates/.codex/rules/MUST-permissions.md +84 -0
- package/templates/.codex/rules/MUST-safety.md +69 -0
- package/templates/.codex/rules/MUST-sync-verification.md +281 -0
- package/templates/.codex/rules/MUST-tool-identification.md +195 -0
- package/templates/.codex/rules/SHOULD-agent-teams.md +183 -0
- package/templates/.codex/rules/SHOULD-ecomode.md +145 -0
- package/templates/.codex/rules/SHOULD-error-handling.md +102 -0
- package/templates/.codex/rules/SHOULD-hud-statusline.md +112 -0
- package/templates/.codex/rules/SHOULD-interaction.md +103 -0
- package/templates/.codex/rules/SHOULD-memory-integration.md +132 -0
- package/templates/.codex/rules/index.yaml +141 -0
- package/templates/.codex/skills/airflow-best-practices/SKILL.md +56 -0
- package/templates/.codex/skills/audit-agents/SKILL.md +116 -0
- package/templates/.codex/skills/aws-best-practices/SKILL.md +280 -0
- package/templates/.codex/skills/claude-code-bible/SKILL.md +180 -0
- package/templates/.codex/skills/claude-code-bible/scripts/fetch-docs.js +244 -0
- package/templates/.codex/skills/create-agent/SKILL.md +91 -0
- package/templates/.codex/skills/dbt-best-practices/SKILL.md +54 -0
- package/templates/.codex/skills/de-lead-routing/SKILL.md +230 -0
- package/templates/.codex/skills/dev-lead-routing/SKILL.md +253 -0
- package/templates/.codex/skills/dev-refactor/SKILL.md +123 -0
- package/templates/.codex/skills/dev-review/SKILL.md +81 -0
- package/templates/.codex/skills/docker-best-practices/SKILL.md +275 -0
- package/templates/.codex/skills/fastapi-best-practices/SKILL.md +270 -0
- package/templates/.codex/skills/fix-refs/SKILL.md +107 -0
- package/templates/.codex/skills/go-backend-best-practices/SKILL.md +338 -0
- package/templates/.codex/skills/go-best-practices/CLAUDE.md +9 -0
- package/templates/.codex/skills/go-best-practices/SKILL.md +203 -0
- package/templates/.codex/skills/help/SKILL.md +125 -0
- package/templates/.codex/skills/intent-detection/SKILL.md +215 -0
- package/templates/.codex/skills/intent-detection/patterns/agent-triggers.yaml +349 -0
- package/templates/.codex/skills/kafka-best-practices/SKILL.md +52 -0
- package/templates/.codex/skills/kotlin-best-practices/SKILL.md +256 -0
- package/templates/.codex/skills/lists/SKILL.md +78 -0
- package/templates/.codex/skills/memory-management/SKILL.md +195 -0
- package/templates/.codex/skills/memory-recall/SKILL.md +152 -0
- package/templates/.codex/skills/memory-save/SKILL.md +126 -0
- package/templates/.codex/skills/monitoring-setup/SKILL.md +115 -0
- package/templates/.codex/skills/npm-audit/SKILL.md +72 -0
- package/templates/.codex/skills/npm-publish/SKILL.md +63 -0
- package/templates/.codex/skills/npm-version/SKILL.md +75 -0
- package/templates/.codex/skills/optimize-analyze/SKILL.md +55 -0
- package/templates/.codex/skills/optimize-bundle/SKILL.md +67 -0
- package/templates/.codex/skills/optimize-report/SKILL.md +74 -0
- package/templates/.codex/skills/pipeline-architecture-patterns/SKILL.md +83 -0
- package/templates/.codex/skills/postgres-best-practices/SKILL.md +66 -0
- package/templates/.codex/skills/python-best-practices/SKILL.md +222 -0
- package/templates/.codex/skills/qa-lead-routing/SKILL.md +277 -0
- package/templates/.codex/skills/react-best-practices/SKILL.md +101 -0
- package/templates/.codex/skills/redis-best-practices/SKILL.md +83 -0
- package/templates/.codex/skills/result-aggregation/SKILL.md +164 -0
- package/templates/.codex/skills/rust-best-practices/SKILL.md +267 -0
- package/templates/.codex/skills/sauron-watch/SKILL.md +144 -0
- package/templates/.codex/skills/secretary-routing/SKILL.md +190 -0
- package/templates/.codex/skills/snowflake-best-practices/SKILL.md +65 -0
- package/templates/.codex/skills/spark-best-practices/SKILL.md +52 -0
- package/templates/.codex/skills/springboot-best-practices/SKILL.md +357 -0
- package/templates/.codex/skills/status/SKILL.md +153 -0
- package/templates/.codex/skills/supabase-postgres-best-practices/SKILL.md +99 -0
- package/templates/.codex/skills/typescript-best-practices/SKILL.md +321 -0
- package/templates/.codex/skills/update-docs/SKILL.md +140 -0
- package/templates/.codex/skills/update-external/SKILL.md +149 -0
- package/templates/.codex/skills/vercel-deploy/SKILL.md +73 -0
- package/templates/.codex/skills/web-design-guidelines/SKILL.md +118 -0
- package/templates/.codex/skills/writing-clearly-and-concisely/SKILL.md +64 -0
- package/templates/.codex/uninstall-hooks.sh +52 -0
- package/templates/AGENTS.md.en +39 -0
- package/templates/AGENTS.md.ko +39 -0
- package/templates/CLAUDE.md.en +7 -5
- package/templates/CLAUDE.md.ko +7 -5
- package/templates/guides/airflow/README.md +32 -0
- package/templates/guides/dbt/README.md +32 -0
- package/templates/guides/iceberg/README.md +49 -0
- package/templates/guides/kafka/README.md +32 -0
- package/templates/guides/postgres/README.md +58 -0
- package/templates/guides/redis/README.md +50 -0
- package/templates/guides/snowflake/README.md +32 -0
- package/templates/guides/spark/README.md +32 -0
- package/templates/manifest.codex.json +43 -0
- package/templates/manifest.json +5 -5
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-best-practices
|
|
3
|
+
description: React/Next.js performance optimization with 40+ rules in 8 categories
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
- Writing React/Next.js components
|
|
10
|
+
- Data fetching implementation
|
|
11
|
+
- Performance review
|
|
12
|
+
- Bundle size optimization
|
|
13
|
+
|
|
14
|
+
## Categories by Priority
|
|
15
|
+
|
|
16
|
+
### Critical Priority
|
|
17
|
+
|
|
18
|
+
#### Waterfall Elimination
|
|
19
|
+
```
|
|
20
|
+
- Avoid sequential data fetching
|
|
21
|
+
- Use parallel data fetching
|
|
22
|
+
- Implement proper loading states
|
|
23
|
+
- Prefetch critical data
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Bundle Optimization
|
|
27
|
+
```
|
|
28
|
+
- Minimize client-side JavaScript
|
|
29
|
+
- Use dynamic imports
|
|
30
|
+
- Tree-shake unused code
|
|
31
|
+
- Analyze bundle with tools
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### High Priority
|
|
35
|
+
|
|
36
|
+
#### Server-Side Performance
|
|
37
|
+
```
|
|
38
|
+
- Use Server Components by default
|
|
39
|
+
- Minimize 'use client' directives
|
|
40
|
+
- Implement streaming where possible
|
|
41
|
+
- Cache server responses
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Medium-High Priority
|
|
45
|
+
|
|
46
|
+
#### Client-Side Fetching
|
|
47
|
+
```
|
|
48
|
+
- Use SWR or React Query
|
|
49
|
+
- Implement optimistic updates
|
|
50
|
+
- Handle loading/error states
|
|
51
|
+
- Cache API responses
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Medium Priority
|
|
55
|
+
|
|
56
|
+
#### Rendering
|
|
57
|
+
```
|
|
58
|
+
- Avoid unnecessary re-renders
|
|
59
|
+
- Use React.memo strategically
|
|
60
|
+
- Implement useMemo/useCallback properly
|
|
61
|
+
- Virtualize long lists
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Caching
|
|
65
|
+
```
|
|
66
|
+
- Implement proper cache headers
|
|
67
|
+
- Use ISR for dynamic content
|
|
68
|
+
- Cache database queries
|
|
69
|
+
- CDN caching strategies
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Code Splitting
|
|
73
|
+
```
|
|
74
|
+
- Split by route
|
|
75
|
+
- Lazy load below-fold content
|
|
76
|
+
- Dynamic import heavy libraries
|
|
77
|
+
- Preload critical chunks
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Low-Medium Priority
|
|
81
|
+
|
|
82
|
+
#### Image Optimization
|
|
83
|
+
```
|
|
84
|
+
- Use next/image
|
|
85
|
+
- Implement proper sizing
|
|
86
|
+
- Use modern formats (WebP, AVIF)
|
|
87
|
+
- Lazy load off-screen images
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Execution Flow
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
1. Identify optimization area
|
|
94
|
+
2. Check relevant category rules
|
|
95
|
+
3. Apply recommendations
|
|
96
|
+
4. Verify improvements
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Scripts
|
|
100
|
+
|
|
101
|
+
See `scripts/` directory for automation helpers.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: redis-best-practices
|
|
3
|
+
description: Redis best practices for caching, data structures, and in-memory data architecture
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Redis Best Practices
|
|
8
|
+
|
|
9
|
+
## Caching Patterns
|
|
10
|
+
|
|
11
|
+
### Cache-Aside (CRITICAL)
|
|
12
|
+
- Read: check cache → miss → read DB → set cache
|
|
13
|
+
- Write: update DB → invalidate cache
|
|
14
|
+
- Best for read-heavy workloads
|
|
15
|
+
|
|
16
|
+
### Write-Through
|
|
17
|
+
- Write: update cache AND DB simultaneously
|
|
18
|
+
- Ensures consistency
|
|
19
|
+
- Higher write latency
|
|
20
|
+
|
|
21
|
+
### Write-Behind
|
|
22
|
+
- Write: update cache → async DB update
|
|
23
|
+
- Lowest latency
|
|
24
|
+
- Risk of data loss
|
|
25
|
+
|
|
26
|
+
## Data Structures
|
|
27
|
+
|
|
28
|
+
### String
|
|
29
|
+
- Simple key-value: `SET key value`
|
|
30
|
+
- Counters: `INCR`, `DECR`, `INCRBY`
|
|
31
|
+
- Bit operations: `SETBIT`, `BITCOUNT`
|
|
32
|
+
|
|
33
|
+
### Hash
|
|
34
|
+
- Object storage: `HSET user:1 name "Alice"`
|
|
35
|
+
- Partial updates: `HINCRBY user:1 visits 1`
|
|
36
|
+
- Memory efficient for small hashes
|
|
37
|
+
|
|
38
|
+
### List
|
|
39
|
+
- Queues: `LPUSH`, `RPOP` (FIFO)
|
|
40
|
+
- Stacks: `LPUSH`, `LPOP` (LIFO)
|
|
41
|
+
- Capped collections: `LTRIM`
|
|
42
|
+
|
|
43
|
+
### Set
|
|
44
|
+
- Unique collections: `SADD`, `SMEMBERS`
|
|
45
|
+
- Intersections: `SINTER`
|
|
46
|
+
- Random sampling: `SRANDMEMBER`
|
|
47
|
+
|
|
48
|
+
### Sorted Set
|
|
49
|
+
- Leaderboards: `ZADD`, `ZRANGEBYSCORE`
|
|
50
|
+
- Rate limiting: `ZADD timestamp`
|
|
51
|
+
- Priority queues
|
|
52
|
+
|
|
53
|
+
### Stream
|
|
54
|
+
- Event log: `XADD`, `XREAD`
|
|
55
|
+
- Consumer groups: `XGROUP`, `XACK`
|
|
56
|
+
- Pub/Sub with persistence
|
|
57
|
+
|
|
58
|
+
## Performance
|
|
59
|
+
|
|
60
|
+
### Memory Optimization
|
|
61
|
+
- Set maxmemory policy: `allkeys-lru`, `volatile-lru`
|
|
62
|
+
- Monitor memory: `INFO memory`
|
|
63
|
+
- Use appropriate data structures (Hash vs String)
|
|
64
|
+
|
|
65
|
+
### Pipelining
|
|
66
|
+
- Batch multiple commands
|
|
67
|
+
- Reduces round-trip latency
|
|
68
|
+
- Use for bulk operations
|
|
69
|
+
|
|
70
|
+
## High Availability
|
|
71
|
+
|
|
72
|
+
### Redis Cluster
|
|
73
|
+
- Horizontal scaling
|
|
74
|
+
- Automatic sharding (16384 slots)
|
|
75
|
+
- Multi-master replication
|
|
76
|
+
|
|
77
|
+
### Redis Sentinel
|
|
78
|
+
- Automatic failover
|
|
79
|
+
- Monitoring and notifications
|
|
80
|
+
- Configuration provider
|
|
81
|
+
|
|
82
|
+
## References
|
|
83
|
+
- [Redis Best Practices](https://redis.io/docs/manual/patterns/)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: result-aggregation
|
|
3
|
+
description: Aggregate parallel agent results into concise output
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Aggregate and format results from multiple parallel agent executions into concise, scannable output.
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
- After parallel agent execution completes
|
|
14
|
+
- When ecomode is active
|
|
15
|
+
- For batch operation summaries
|
|
16
|
+
- When reporting multi-agent task results
|
|
17
|
+
|
|
18
|
+
## Aggregation Formats
|
|
19
|
+
|
|
20
|
+
### Standard Batch Format
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
[Batch Complete] {completed}/{total}
|
|
24
|
+
├── {agent}: {icon} {summary}
|
|
25
|
+
├── {agent}: {icon} {summary}
|
|
26
|
+
└── {agent}: {icon} {summary}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Detailed Batch Format
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
[Batch Complete] {completed}/{total}
|
|
33
|
+
|
|
34
|
+
[1] {agent-name}
|
|
35
|
+
Status: {success|failed|partial}
|
|
36
|
+
Target: {file/path}
|
|
37
|
+
Result: {summary}
|
|
38
|
+
|
|
39
|
+
[2] {agent-name}
|
|
40
|
+
Status: {success|failed|partial}
|
|
41
|
+
Target: {file/path}
|
|
42
|
+
Result: {summary}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Error Summary Format
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
[Batch Complete] {completed}/{total} ({failures} failed)
|
|
49
|
+
|
|
50
|
+
Failures:
|
|
51
|
+
├── {agent}: {error summary}
|
|
52
|
+
└── {agent}: {error summary}
|
|
53
|
+
|
|
54
|
+
Successes:
|
|
55
|
+
├── {agent}: ✓ {summary}
|
|
56
|
+
└── {agent}: ✓ {summary}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Status Icons
|
|
60
|
+
|
|
61
|
+
| Icon | Status | Use When |
|
|
62
|
+
|------|--------|----------|
|
|
63
|
+
| ✓ | Success | Task completed successfully |
|
|
64
|
+
| ✗ | Failed | Task failed with error |
|
|
65
|
+
| ⚠ | Warning | Completed with warnings |
|
|
66
|
+
| ⏳ | Pending | Still in progress |
|
|
67
|
+
| ⊘ | Skipped | Task was skipped |
|
|
68
|
+
|
|
69
|
+
## Aggregation Rules
|
|
70
|
+
|
|
71
|
+
### 1. Ordering
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
order:
|
|
75
|
+
- Failed results first (need attention)
|
|
76
|
+
- Warnings second
|
|
77
|
+
- Successes last
|
|
78
|
+
- Within category: alphabetical by agent
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2. Summary Length
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
ecomode_on:
|
|
85
|
+
max_length: 50 characters
|
|
86
|
+
truncate_with: "..."
|
|
87
|
+
|
|
88
|
+
ecomode_off:
|
|
89
|
+
max_length: 200 characters
|
|
90
|
+
allow_multiline: true
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 3. Grouping
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
group_by:
|
|
97
|
+
- status (success/failed/warning)
|
|
98
|
+
- agent_type (when mixed types)
|
|
99
|
+
- target_path (when same agent, different targets)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Integration
|
|
103
|
+
|
|
104
|
+
### With Secretary
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
Secretary receives:
|
|
108
|
+
- List of agent results
|
|
109
|
+
- Ecomode status
|
|
110
|
+
- User display preferences
|
|
111
|
+
|
|
112
|
+
Secretary outputs:
|
|
113
|
+
- Aggregated summary using this skill
|
|
114
|
+
- Individual details if requested
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### With Ecomode
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
When ecomode active:
|
|
121
|
+
- Use compact format
|
|
122
|
+
- One line per agent
|
|
123
|
+
- Icons for status
|
|
124
|
+
- Truncate long summaries
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Examples
|
|
128
|
+
|
|
129
|
+
### Code Review Batch
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
[Batch Complete] 4/4
|
|
133
|
+
|
|
134
|
+
├── lang-golang-expert: ✓ src/main.go - 2 issues (1 naming, 1 error handling)
|
|
135
|
+
├── lang-python-expert: ✓ scripts/*.py - Clean
|
|
136
|
+
├── lang-rust-expert: ⚠ lib/core.rs - 1 unsafe block flagged
|
|
137
|
+
└── lang-typescript-expert: ✓ web/app.tsx - 3 suggestions
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Agent Creation Batch
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
[Batch Complete] 3/4 (1 failed)
|
|
144
|
+
|
|
145
|
+
✗ lang-kotlin-expert: Skill not found: kotlin-best-practices
|
|
146
|
+
✓ lang-golang-expert: Agent created at .codex/agents/lang-golang-expert.md
|
|
147
|
+
✓ lang-python-expert: Agent created at .codex/agents/lang-python-expert.md
|
|
148
|
+
✓ lang-rust-expert: Agent created at .codex/agents/lang-rust-expert.md
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Audit Batch
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
[Batch Complete] 5/5
|
|
155
|
+
|
|
156
|
+
Agents Audited:
|
|
157
|
+
├── mgr-creator: ✓ All refs valid
|
|
158
|
+
├── mgr-updater: ✓ All refs valid
|
|
159
|
+
├── mgr-supplier: ⚠ 1 deprecated ref
|
|
160
|
+
├── lang-golang-expert: ✓ All refs valid
|
|
161
|
+
└── lang-python-expert: ✓ All refs valid
|
|
162
|
+
|
|
163
|
+
Summary: 5 agents checked, 1 warning
|
|
164
|
+
```
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rust-best-practices
|
|
3
|
+
description: Idiomatic Rust patterns from official guidelines
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Apply idiomatic Rust patterns and best practices from official documentation.
|
|
10
|
+
|
|
11
|
+
## Core Principles
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Safety without garbage collection
|
|
15
|
+
Zero-cost abstractions
|
|
16
|
+
Fearless concurrency
|
|
17
|
+
Ownership as a feature
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
### 1. Naming Conventions
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
crates:
|
|
26
|
+
style: snake_case or kebab-case
|
|
27
|
+
example: my_crate, my-crate
|
|
28
|
+
|
|
29
|
+
modules:
|
|
30
|
+
style: snake_case
|
|
31
|
+
example: my_module
|
|
32
|
+
|
|
33
|
+
types:
|
|
34
|
+
style: UpperCamelCase
|
|
35
|
+
example: MyStruct, MyEnum
|
|
36
|
+
|
|
37
|
+
traits:
|
|
38
|
+
style: UpperCamelCase
|
|
39
|
+
example: Iterator, Display
|
|
40
|
+
|
|
41
|
+
functions_methods:
|
|
42
|
+
style: snake_case
|
|
43
|
+
example: my_function, get_value
|
|
44
|
+
|
|
45
|
+
constants:
|
|
46
|
+
style: SCREAMING_SNAKE_CASE
|
|
47
|
+
example: MAX_SIZE
|
|
48
|
+
|
|
49
|
+
type_parameters:
|
|
50
|
+
style: single uppercase or CamelCase
|
|
51
|
+
example: T, E, Item
|
|
52
|
+
|
|
53
|
+
lifetimes:
|
|
54
|
+
style: short lowercase
|
|
55
|
+
example: 'a, 'b, 'static
|
|
56
|
+
|
|
57
|
+
macros:
|
|
58
|
+
style: snake_case!
|
|
59
|
+
example: vec!, println!
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 2. Ownership and Borrowing
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
principles:
|
|
66
|
+
- Each value has exactly one owner
|
|
67
|
+
- References cannot outlive the data they reference
|
|
68
|
+
- Either one mutable reference OR many immutable references
|
|
69
|
+
|
|
70
|
+
prefer:
|
|
71
|
+
- "&T over T" when not needing ownership
|
|
72
|
+
- "&mut T over T" when modifying without consuming
|
|
73
|
+
- "T over Box<T>" when size is known at compile time
|
|
74
|
+
|
|
75
|
+
avoid:
|
|
76
|
+
- Clone when borrowing suffices
|
|
77
|
+
- RefCell unless interior mutability is needed
|
|
78
|
+
- Unsafe unless absolutely necessary
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 3. Error Handling
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
result_type:
|
|
85
|
+
- Return Result<T, E> for recoverable errors
|
|
86
|
+
- Use ? operator for propagation
|
|
87
|
+
- Define custom error types for libraries
|
|
88
|
+
|
|
89
|
+
option_type:
|
|
90
|
+
- Use Option<T> for nullable values
|
|
91
|
+
- Prefer map/and_then over match when appropriate
|
|
92
|
+
- Use unwrap_or, unwrap_or_else, unwrap_or_default
|
|
93
|
+
|
|
94
|
+
panic:
|
|
95
|
+
- Only for unrecoverable errors
|
|
96
|
+
- Use in tests with assert!, assert_eq!
|
|
97
|
+
- Avoid in library code
|
|
98
|
+
|
|
99
|
+
patterns: |
|
|
100
|
+
// Propagation with ?
|
|
101
|
+
fn read_file() -> Result<String, io::Error> {
|
|
102
|
+
let mut file = File::open("file.txt")?;
|
|
103
|
+
let mut contents = String::new();
|
|
104
|
+
file.read_to_string(&mut contents)?;
|
|
105
|
+
Ok(contents)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Custom error type
|
|
109
|
+
#[derive(Debug)]
|
|
110
|
+
enum MyError {
|
|
111
|
+
Io(io::Error),
|
|
112
|
+
Parse(ParseIntError),
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 4. Traits and Generics
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
trait_design:
|
|
120
|
+
- Keep traits focused and small
|
|
121
|
+
- Use associated types for output types
|
|
122
|
+
- Implement standard traits: Debug, Clone, Default, PartialEq
|
|
123
|
+
|
|
124
|
+
standard_traits:
|
|
125
|
+
- Debug: for debugging output
|
|
126
|
+
- Clone: explicit duplication
|
|
127
|
+
- Default: default value construction
|
|
128
|
+
- PartialEq, Eq: equality comparison
|
|
129
|
+
- PartialOrd, Ord: ordering
|
|
130
|
+
- Hash: for HashMap keys
|
|
131
|
+
- Display: user-facing output
|
|
132
|
+
- From/Into: type conversion
|
|
133
|
+
|
|
134
|
+
generics:
|
|
135
|
+
- Use trait bounds to specify requirements
|
|
136
|
+
- Prefer impl Trait in argument position
|
|
137
|
+
- Use where clauses for complex bounds
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 5. Memory Management
|
|
141
|
+
|
|
142
|
+
```yaml
|
|
143
|
+
stack_vs_heap:
|
|
144
|
+
- Stack: fixed-size, Copy types
|
|
145
|
+
- Heap: dynamic-size, Box, Vec, String
|
|
146
|
+
|
|
147
|
+
smart_pointers:
|
|
148
|
+
- Box<T>: heap allocation with single owner
|
|
149
|
+
- Rc<T>: reference counting (single-threaded)
|
|
150
|
+
- Arc<T>: atomic reference counting (multi-threaded)
|
|
151
|
+
- RefCell<T>: interior mutability
|
|
152
|
+
|
|
153
|
+
avoid_leaks:
|
|
154
|
+
- Drop trait for cleanup
|
|
155
|
+
- RAII pattern for resources
|
|
156
|
+
- Weak references to break cycles
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 6. Concurrency
|
|
160
|
+
|
|
161
|
+
```yaml
|
|
162
|
+
send_sync:
|
|
163
|
+
- Send: safe to transfer between threads
|
|
164
|
+
- Sync: safe to share references between threads
|
|
165
|
+
|
|
166
|
+
primitives:
|
|
167
|
+
- Mutex<T>: mutual exclusion
|
|
168
|
+
- RwLock<T>: multiple readers or one writer
|
|
169
|
+
- Arc<T>: thread-safe reference counting
|
|
170
|
+
- mpsc: channels for message passing
|
|
171
|
+
|
|
172
|
+
patterns: |
|
|
173
|
+
// Shared state with Arc and Mutex
|
|
174
|
+
let counter = Arc::new(Mutex::new(0));
|
|
175
|
+
let counter_clone = Arc::clone(&counter);
|
|
176
|
+
|
|
177
|
+
thread::spawn(move || {
|
|
178
|
+
let mut num = counter_clone.lock().unwrap();
|
|
179
|
+
*num += 1;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Message passing
|
|
183
|
+
let (tx, rx) = mpsc::channel();
|
|
184
|
+
thread::spawn(move || {
|
|
185
|
+
tx.send(value).unwrap();
|
|
186
|
+
});
|
|
187
|
+
let received = rx.recv().unwrap();
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 7. API Design
|
|
191
|
+
|
|
192
|
+
```yaml
|
|
193
|
+
guidelines:
|
|
194
|
+
- Accept borrowed data when possible
|
|
195
|
+
- Return owned data when the caller needs it
|
|
196
|
+
- Use Into/AsRef for flexible parameters
|
|
197
|
+
- Implement standard conversion traits
|
|
198
|
+
|
|
199
|
+
constructors:
|
|
200
|
+
- new() for primary constructor
|
|
201
|
+
- with_* for alternative constructors
|
|
202
|
+
- Builder pattern for many parameters
|
|
203
|
+
|
|
204
|
+
methods:
|
|
205
|
+
- is_* for boolean queries
|
|
206
|
+
- as_* for cheap conversions (borrows)
|
|
207
|
+
- to_* for expensive conversions (copies)
|
|
208
|
+
- into_* for ownership transfers
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 8. Documentation
|
|
212
|
+
|
|
213
|
+
```yaml
|
|
214
|
+
rules:
|
|
215
|
+
- Document all public items
|
|
216
|
+
- Include examples in doc comments
|
|
217
|
+
- Use # Examples section
|
|
218
|
+
- Document panics, errors, safety
|
|
219
|
+
|
|
220
|
+
format: |
|
|
221
|
+
/// Brief description.
|
|
222
|
+
///
|
|
223
|
+
/// More detailed explanation if needed.
|
|
224
|
+
///
|
|
225
|
+
/// # Examples
|
|
226
|
+
///
|
|
227
|
+
/// ```
|
|
228
|
+
/// let result = my_function(42);
|
|
229
|
+
/// assert_eq!(result, 84);
|
|
230
|
+
/// ```
|
|
231
|
+
///
|
|
232
|
+
/// # Panics
|
|
233
|
+
///
|
|
234
|
+
/// Panics if the input is zero.
|
|
235
|
+
pub fn my_function(x: i32) -> i32 {
|
|
236
|
+
x * 2
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### 9. Project Structure
|
|
241
|
+
|
|
242
|
+
```yaml
|
|
243
|
+
layout:
|
|
244
|
+
- src/lib.rs or src/main.rs: crate root
|
|
245
|
+
- src/bin/: additional binaries
|
|
246
|
+
- tests/: integration tests
|
|
247
|
+
- benches/: benchmarks
|
|
248
|
+
- examples/: example programs
|
|
249
|
+
|
|
250
|
+
modules:
|
|
251
|
+
- One module per file
|
|
252
|
+
- mod.rs or filename.rs for module
|
|
253
|
+
- pub use for re-exports
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Application
|
|
257
|
+
|
|
258
|
+
When writing or reviewing Rust code:
|
|
259
|
+
|
|
260
|
+
1. **Always** handle ownership correctly
|
|
261
|
+
2. **Always** handle errors with Result/Option
|
|
262
|
+
3. **Prefer** borrowing over cloning
|
|
263
|
+
4. **Prefer** zero-cost abstractions
|
|
264
|
+
5. **Implement** standard traits (Debug, Clone, etc.)
|
|
265
|
+
6. **Document** public APIs with examples
|
|
266
|
+
7. **Avoid** unsafe unless necessary
|
|
267
|
+
8. **Use** clippy for linting
|