oh-my-customcode 0.1.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/LICENSE +21 -0
- package/README.md +287 -0
- package/dist/cli/index.js +13299 -0
- package/dist/index.js +927 -0
- package/package.json +74 -0
- package/templates/.claude/contexts/dev.md +20 -0
- package/templates/.claude/contexts/ecomode.md +63 -0
- package/templates/.claude/contexts/index.yaml +41 -0
- package/templates/.claude/contexts/research.md +28 -0
- package/templates/.claude/contexts/review.md +23 -0
- package/templates/.claude/hooks/hooks.json +185 -0
- package/templates/.claude/hooks/hud/index.yaml +27 -0
- package/templates/.claude/hooks/hud/update-status.sh +32 -0
- package/templates/.claude/hooks/index.yaml +46 -0
- package/templates/.claude/hooks/memory-persistence/pre-compact.sh +37 -0
- package/templates/.claude/hooks/memory-persistence/session-end.sh +64 -0
- package/templates/.claude/hooks/memory-persistence/session-start.sh +41 -0
- package/templates/.claude/hooks/strategic-compact/suggest-compact.sh +50 -0
- package/templates/.claude/install-hooks.sh +100 -0
- package/templates/.claude/rules/MAY-optimization.md +93 -0
- package/templates/.claude/rules/MUST-agent-design.md +107 -0
- package/templates/.claude/rules/MUST-agent-identification.md +108 -0
- package/templates/.claude/rules/MUST-continuous-improvement.md +132 -0
- package/templates/.claude/rules/MUST-intent-transparency.md +199 -0
- package/templates/.claude/rules/MUST-language-policy.md +62 -0
- package/templates/.claude/rules/MUST-orchestrator-coordination.md +266 -0
- package/templates/.claude/rules/MUST-parallel-execution.md +341 -0
- package/templates/.claude/rules/MUST-permissions.md +84 -0
- package/templates/.claude/rules/MUST-safety.md +69 -0
- package/templates/.claude/rules/MUST-sync-verification.md +219 -0
- package/templates/.claude/rules/MUST-tool-identification.md +112 -0
- package/templates/.claude/rules/SHOULD-ecomode.md +145 -0
- package/templates/.claude/rules/SHOULD-error-handling.md +102 -0
- package/templates/.claude/rules/SHOULD-hud-statusline.md +89 -0
- package/templates/.claude/rules/SHOULD-interaction.md +103 -0
- package/templates/.claude/rules/SHOULD-memory-integration.md +114 -0
- package/templates/.claude/rules/SHOULD-pipeline-mode.md +165 -0
- package/templates/.claude/rules/index.yaml +125 -0
- package/templates/.claude/uninstall-hooks.sh +52 -0
- package/templates/CLAUDE.md.en +259 -0
- package/templates/CLAUDE.md.ko +259 -0
- package/templates/agents/index.yaml +237 -0
- package/templates/agents/infra-engineer/aws-expert/AGENT.md +47 -0
- package/templates/agents/infra-engineer/aws-expert/index.yaml +27 -0
- package/templates/agents/infra-engineer/docker-expert/AGENT.md +47 -0
- package/templates/agents/infra-engineer/docker-expert/index.yaml +27 -0
- package/templates/agents/manager/creator/AGENT.md +274 -0
- package/templates/agents/manager/creator/index.yaml +66 -0
- package/templates/agents/manager/gitnerd/AGENT.md +91 -0
- package/templates/agents/manager/gitnerd/index.yaml +55 -0
- package/templates/agents/manager/sauron/AGENT.md +153 -0
- package/templates/agents/manager/sauron/index.yaml +52 -0
- package/templates/agents/manager/supplier/AGENT.md +142 -0
- package/templates/agents/manager/supplier/index.yaml +31 -0
- package/templates/agents/manager/sync-checker/AGENT.md +34 -0
- package/templates/agents/manager/sync-checker/index.yaml +32 -0
- package/templates/agents/manager/updater/AGENT.md +125 -0
- package/templates/agents/manager/updater/index.yaml +31 -0
- package/templates/agents/orchestrator/dev-lead/AGENT.md +116 -0
- package/templates/agents/orchestrator/dev-lead/index.yaml +73 -0
- package/templates/agents/orchestrator/planner/AGENT.md +102 -0
- package/templates/agents/orchestrator/planner/index.yaml +38 -0
- package/templates/agents/orchestrator/qa-lead/AGENT.md +92 -0
- package/templates/agents/orchestrator/qa-lead/index.yaml +40 -0
- package/templates/agents/orchestrator/secretary/AGENT.md +132 -0
- package/templates/agents/orchestrator/secretary/index.yaml +55 -0
- package/templates/agents/qa-team/qa-engineer/AGENT.md +98 -0
- package/templates/agents/qa-team/qa-engineer/index.yaml +59 -0
- package/templates/agents/qa-team/qa-planner/AGENT.md +75 -0
- package/templates/agents/qa-team/qa-planner/index.yaml +47 -0
- package/templates/agents/qa-team/qa-writer/AGENT.md +98 -0
- package/templates/agents/qa-team/qa-writer/index.yaml +44 -0
- package/templates/agents/sw-architect/documenter/AGENT.md +120 -0
- package/templates/agents/sw-architect/documenter/index.yaml +39 -0
- package/templates/agents/sw-architect/speckit-agent/AGENT.md +127 -0
- package/templates/agents/sw-architect/speckit-agent/index.yaml +78 -0
- package/templates/agents/sw-engineer/backend/express-expert/AGENT.md +132 -0
- package/templates/agents/sw-engineer/backend/express-expert/index.yaml +36 -0
- package/templates/agents/sw-engineer/backend/fastapi-expert/AGENT.md +47 -0
- package/templates/agents/sw-engineer/backend/fastapi-expert/index.yaml +27 -0
- package/templates/agents/sw-engineer/backend/go-backend-expert/AGENT.md +47 -0
- package/templates/agents/sw-engineer/backend/go-backend-expert/index.yaml +27 -0
- package/templates/agents/sw-engineer/backend/nestjs-expert/AGENT.md +107 -0
- package/templates/agents/sw-engineer/backend/nestjs-expert/index.yaml +43 -0
- package/templates/agents/sw-engineer/backend/springboot-expert/AGENT.md +103 -0
- package/templates/agents/sw-engineer/backend/springboot-expert/index.yaml +69 -0
- package/templates/agents/sw-engineer/frontend/svelte-agent/AGENT.md +71 -0
- package/templates/agents/sw-engineer/frontend/svelte-agent/index.yaml +41 -0
- package/templates/agents/sw-engineer/frontend/vercel-agent/AGENT.md +67 -0
- package/templates/agents/sw-engineer/frontend/vercel-agent/index.yaml +43 -0
- package/templates/agents/sw-engineer/frontend/vuejs-agent/AGENT.md +71 -0
- package/templates/agents/sw-engineer/frontend/vuejs-agent/index.yaml +48 -0
- package/templates/agents/sw-engineer/language/golang-expert/AGENT.md +47 -0
- package/templates/agents/sw-engineer/language/golang-expert/index.yaml +27 -0
- package/templates/agents/sw-engineer/language/java21-expert/AGENT.md +122 -0
- package/templates/agents/sw-engineer/language/java21-expert/index.yaml +51 -0
- package/templates/agents/sw-engineer/language/kotlin-expert/AGENT.md +47 -0
- package/templates/agents/sw-engineer/language/kotlin-expert/index.yaml +27 -0
- package/templates/agents/sw-engineer/language/python-expert/AGENT.md +47 -0
- package/templates/agents/sw-engineer/language/python-expert/index.yaml +27 -0
- package/templates/agents/sw-engineer/language/rust-expert/AGENT.md +47 -0
- package/templates/agents/sw-engineer/language/rust-expert/index.yaml +27 -0
- package/templates/agents/sw-engineer/language/typescript-expert/AGENT.md +47 -0
- package/templates/agents/sw-engineer/language/typescript-expert/index.yaml +27 -0
- package/templates/agents/sw-engineer/tooling/bun-expert/AGENT.md +73 -0
- package/templates/agents/sw-engineer/tooling/bun-expert/index.yaml +46 -0
- package/templates/agents/sw-engineer/tooling/npm-expert/AGENT.md +160 -0
- package/templates/agents/sw-engineer/tooling/npm-expert/index.yaml +45 -0
- package/templates/agents/sw-engineer/tooling/optimizer/AGENT.md +170 -0
- package/templates/agents/sw-engineer/tooling/optimizer/index.yaml +45 -0
- package/templates/agents/system/memory-keeper/AGENT.md +126 -0
- package/templates/agents/system/memory-keeper/index.yaml +45 -0
- package/templates/agents/system/naggy/AGENT.md +72 -0
- package/templates/agents/system/naggy/index.yaml +35 -0
- package/templates/commands/COMMANDS.md +136 -0
- package/templates/commands/creator/agent.md +121 -0
- package/templates/commands/dev/refactor.md +126 -0
- package/templates/commands/dev/review.md +82 -0
- package/templates/commands/git/branch.yaml +8 -0
- package/templates/commands/git/commit.yaml +4 -0
- package/templates/commands/git/pr.yaml +4 -0
- package/templates/commands/git/status.yaml +4 -0
- package/templates/commands/git/sync.yaml +4 -0
- package/templates/commands/index.yaml +225 -0
- package/templates/commands/intent/explain.md +144 -0
- package/templates/commands/memory/recall.md +164 -0
- package/templates/commands/memory/save.md +128 -0
- package/templates/commands/naggy/add.yaml +8 -0
- package/templates/commands/naggy/done.yaml +8 -0
- package/templates/commands/naggy/list.yaml +4 -0
- package/templates/commands/naggy/priority.yaml +11 -0
- package/templates/commands/naggy/remind.yaml +4 -0
- package/templates/commands/npm/audit.yaml +62 -0
- package/templates/commands/npm/publish.yaml +52 -0
- package/templates/commands/npm/version.yaml +62 -0
- package/templates/commands/optimize/analyze.yaml +34 -0
- package/templates/commands/optimize/bundle.yaml +50 -0
- package/templates/commands/optimize/report.yaml +56 -0
- package/templates/commands/pipeline/list.md +81 -0
- package/templates/commands/pipeline/run.md +127 -0
- package/templates/commands/sauron/quick.yaml +4 -0
- package/templates/commands/sauron/report.yaml +4 -0
- package/templates/commands/sauron/watch.yaml +4 -0
- package/templates/commands/supplier/audit.md +133 -0
- package/templates/commands/supplier/fix.md +121 -0
- package/templates/commands/sync/agents.yaml +4 -0
- package/templates/commands/sync/check.yaml +4 -0
- package/templates/commands/sync/commands.yaml +4 -0
- package/templates/commands/sync/docs.yaml +4 -0
- package/templates/commands/sync/fix.yaml +4 -0
- package/templates/commands/system/help.md +137 -0
- package/templates/commands/system/lists.md +86 -0
- package/templates/commands/system/status.md +163 -0
- package/templates/commands/updater/docs.md +165 -0
- package/templates/commands/updater/external.md +214 -0
- package/templates/guides/aws/common-patterns.md +169 -0
- package/templates/guides/aws/index.yaml +26 -0
- package/templates/guides/aws/well-architected.md +143 -0
- package/templates/guides/claude-code/01-overview.md +42 -0
- package/templates/guides/claude-code/03-tools.md +107 -0
- package/templates/guides/claude-code/04-agent-skills.md +90 -0
- package/templates/guides/claude-code/05-agent-sdk.md +129 -0
- package/templates/guides/claude-code/06-mcp.md +165 -0
- package/templates/guides/claude-code/07-prompt-engineering.md +100 -0
- package/templates/guides/claude-code/08-testing.md +58 -0
- package/templates/guides/claude-code/09-guardrails.md +80 -0
- package/templates/guides/claude-code/10-monitoring.md +89 -0
- package/templates/guides/claude-code/index.yaml +51 -0
- package/templates/guides/docker/compose-best-practices.md +284 -0
- package/templates/guides/docker/dockerfile-best-practices.md +262 -0
- package/templates/guides/docker/index.yaml +26 -0
- package/templates/guides/fastapi/best-practices.md +232 -0
- package/templates/guides/fastapi/index.yaml +21 -0
- package/templates/guides/go-backend/index.yaml +26 -0
- package/templates/guides/go-backend/project-layout.md +243 -0
- package/templates/guides/go-backend/uber-style.md +212 -0
- package/templates/guides/golang/concurrency.md +282 -0
- package/templates/guides/golang/effective-go.md +309 -0
- package/templates/guides/golang/error-handling.md +250 -0
- package/templates/guides/golang/index.yaml +27 -0
- package/templates/guides/index.yaml +101 -0
- package/templates/guides/kotlin/coding-conventions.md +247 -0
- package/templates/guides/kotlin/idioms.md +234 -0
- package/templates/guides/kotlin/index.yaml +26 -0
- package/templates/guides/python/index.yaml +26 -0
- package/templates/guides/python/pep8-style-guide.md +202 -0
- package/templates/guides/python/zen-of-python.md +79 -0
- package/templates/guides/rust/error-handling.md +262 -0
- package/templates/guides/rust/index.yaml +26 -0
- package/templates/guides/rust/ownership.md +180 -0
- package/templates/guides/springboot/best-practices.md +361 -0
- package/templates/guides/springboot/index.yaml +22 -0
- package/templates/guides/typescript/advanced-types.md +225 -0
- package/templates/guides/typescript/index.yaml +26 -0
- package/templates/guides/typescript/type-system.md +219 -0
- package/templates/guides/web-design/accessibility.md +66 -0
- package/templates/guides/web-design/index.yaml +20 -0
- package/templates/guides/web-design/performance.md +102 -0
- package/templates/pipelines/examples/code-review.yaml +66 -0
- package/templates/pipelines/index.yaml +18 -0
- package/templates/pipelines/templates/pipeline-template.yaml +50 -0
- package/templates/skills/backend/fastapi-best-practices/SKILL.md +269 -0
- package/templates/skills/backend/fastapi-best-practices/index.yaml +25 -0
- package/templates/skills/backend/go-backend-best-practices/SKILL.md +337 -0
- package/templates/skills/backend/go-backend-best-practices/index.yaml +26 -0
- package/templates/skills/backend/springboot-best-practices/SKILL.md +356 -0
- package/templates/skills/backend/springboot-best-practices/index.yaml +27 -0
- package/templates/skills/development/go-best-practices/SKILL.md +202 -0
- package/templates/skills/development/go-best-practices/index.yaml +25 -0
- package/templates/skills/development/kotlin-best-practices/SKILL.md +255 -0
- package/templates/skills/development/kotlin-best-practices/index.yaml +27 -0
- package/templates/skills/development/python-best-practices/SKILL.md +221 -0
- package/templates/skills/development/python-best-practices/index.yaml +25 -0
- package/templates/skills/development/react-best-practices/SKILL.md +100 -0
- package/templates/skills/development/react-best-practices/index.yaml +39 -0
- package/templates/skills/development/rust-best-practices/SKILL.md +266 -0
- package/templates/skills/development/rust-best-practices/index.yaml +26 -0
- package/templates/skills/development/typescript-best-practices/SKILL.md +320 -0
- package/templates/skills/development/typescript-best-practices/index.yaml +28 -0
- package/templates/skills/development/vercel-deploy/SKILL.md +73 -0
- package/templates/skills/development/vercel-deploy/index.yaml +30 -0
- package/templates/skills/development/web-design-guidelines/SKILL.md +117 -0
- package/templates/skills/development/web-design-guidelines/index.yaml +34 -0
- package/templates/skills/index.yaml +129 -0
- package/templates/skills/infrastructure/aws-best-practices/SKILL.md +279 -0
- package/templates/skills/infrastructure/aws-best-practices/index.yaml +27 -0
- package/templates/skills/infrastructure/docker-best-practices/SKILL.md +274 -0
- package/templates/skills/infrastructure/docker-best-practices/index.yaml +26 -0
- package/templates/skills/orchestration/intent-detection/SKILL.md +214 -0
- package/templates/skills/orchestration/intent-detection/index.yaml +30 -0
- package/templates/skills/orchestration/intent-detection/patterns/agent-triggers.yaml +333 -0
- package/templates/skills/orchestration/pipeline-execution/SKILL.md +188 -0
- package/templates/skills/orchestration/pipeline-execution/index.yaml +27 -0
- package/templates/skills/system/memory-management/SKILL.md +194 -0
- package/templates/skills/system/memory-management/index.yaml +30 -0
- package/templates/skills/system/result-aggregation/SKILL.md +163 -0
- package/templates/skills/system/result-aggregation/index.yaml +36 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Rust Best Practices Skill
|
|
2
|
+
|
|
3
|
+
> **Category**: Development
|
|
4
|
+
> **Source**: Internal (based on Rust API Guidelines and The Book)
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
|
|
8
|
+
Apply idiomatic Rust patterns and best practices from official documentation.
|
|
9
|
+
|
|
10
|
+
## Core Principles
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Safety without garbage collection
|
|
14
|
+
Zero-cost abstractions
|
|
15
|
+
Fearless concurrency
|
|
16
|
+
Ownership as a feature
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
### 1. Naming Conventions
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
crates:
|
|
25
|
+
style: snake_case or kebab-case
|
|
26
|
+
example: my_crate, my-crate
|
|
27
|
+
|
|
28
|
+
modules:
|
|
29
|
+
style: snake_case
|
|
30
|
+
example: my_module
|
|
31
|
+
|
|
32
|
+
types:
|
|
33
|
+
style: UpperCamelCase
|
|
34
|
+
example: MyStruct, MyEnum
|
|
35
|
+
|
|
36
|
+
traits:
|
|
37
|
+
style: UpperCamelCase
|
|
38
|
+
example: Iterator, Display
|
|
39
|
+
|
|
40
|
+
functions_methods:
|
|
41
|
+
style: snake_case
|
|
42
|
+
example: my_function, get_value
|
|
43
|
+
|
|
44
|
+
constants:
|
|
45
|
+
style: SCREAMING_SNAKE_CASE
|
|
46
|
+
example: MAX_SIZE
|
|
47
|
+
|
|
48
|
+
type_parameters:
|
|
49
|
+
style: single uppercase or CamelCase
|
|
50
|
+
example: T, E, Item
|
|
51
|
+
|
|
52
|
+
lifetimes:
|
|
53
|
+
style: short lowercase
|
|
54
|
+
example: 'a, 'b, 'static
|
|
55
|
+
|
|
56
|
+
macros:
|
|
57
|
+
style: snake_case!
|
|
58
|
+
example: vec!, println!
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 2. Ownership and Borrowing
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
principles:
|
|
65
|
+
- Each value has exactly one owner
|
|
66
|
+
- References cannot outlive the data they reference
|
|
67
|
+
- Either one mutable reference OR many immutable references
|
|
68
|
+
|
|
69
|
+
prefer:
|
|
70
|
+
- "&T over T" when not needing ownership
|
|
71
|
+
- "&mut T over T" when modifying without consuming
|
|
72
|
+
- "T over Box<T>" when size is known at compile time
|
|
73
|
+
|
|
74
|
+
avoid:
|
|
75
|
+
- Clone when borrowing suffices
|
|
76
|
+
- RefCell unless interior mutability is needed
|
|
77
|
+
- Unsafe unless absolutely necessary
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 3. Error Handling
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
result_type:
|
|
84
|
+
- Return Result<T, E> for recoverable errors
|
|
85
|
+
- Use ? operator for propagation
|
|
86
|
+
- Define custom error types for libraries
|
|
87
|
+
|
|
88
|
+
option_type:
|
|
89
|
+
- Use Option<T> for nullable values
|
|
90
|
+
- Prefer map/and_then over match when appropriate
|
|
91
|
+
- Use unwrap_or, unwrap_or_else, unwrap_or_default
|
|
92
|
+
|
|
93
|
+
panic:
|
|
94
|
+
- Only for unrecoverable errors
|
|
95
|
+
- Use in tests with assert!, assert_eq!
|
|
96
|
+
- Avoid in library code
|
|
97
|
+
|
|
98
|
+
patterns: |
|
|
99
|
+
// Propagation with ?
|
|
100
|
+
fn read_file() -> Result<String, io::Error> {
|
|
101
|
+
let mut file = File::open("file.txt")?;
|
|
102
|
+
let mut contents = String::new();
|
|
103
|
+
file.read_to_string(&mut contents)?;
|
|
104
|
+
Ok(contents)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Custom error type
|
|
108
|
+
#[derive(Debug)]
|
|
109
|
+
enum MyError {
|
|
110
|
+
Io(io::Error),
|
|
111
|
+
Parse(ParseIntError),
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 4. Traits and Generics
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
trait_design:
|
|
119
|
+
- Keep traits focused and small
|
|
120
|
+
- Use associated types for output types
|
|
121
|
+
- Implement standard traits: Debug, Clone, Default, PartialEq
|
|
122
|
+
|
|
123
|
+
standard_traits:
|
|
124
|
+
- Debug: for debugging output
|
|
125
|
+
- Clone: explicit duplication
|
|
126
|
+
- Default: default value construction
|
|
127
|
+
- PartialEq, Eq: equality comparison
|
|
128
|
+
- PartialOrd, Ord: ordering
|
|
129
|
+
- Hash: for HashMap keys
|
|
130
|
+
- Display: user-facing output
|
|
131
|
+
- From/Into: type conversion
|
|
132
|
+
|
|
133
|
+
generics:
|
|
134
|
+
- Use trait bounds to specify requirements
|
|
135
|
+
- Prefer impl Trait in argument position
|
|
136
|
+
- Use where clauses for complex bounds
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 5. Memory Management
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
stack_vs_heap:
|
|
143
|
+
- Stack: fixed-size, Copy types
|
|
144
|
+
- Heap: dynamic-size, Box, Vec, String
|
|
145
|
+
|
|
146
|
+
smart_pointers:
|
|
147
|
+
- Box<T>: heap allocation with single owner
|
|
148
|
+
- Rc<T>: reference counting (single-threaded)
|
|
149
|
+
- Arc<T>: atomic reference counting (multi-threaded)
|
|
150
|
+
- RefCell<T>: interior mutability
|
|
151
|
+
|
|
152
|
+
avoid_leaks:
|
|
153
|
+
- Drop trait for cleanup
|
|
154
|
+
- RAII pattern for resources
|
|
155
|
+
- Weak references to break cycles
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 6. Concurrency
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
send_sync:
|
|
162
|
+
- Send: safe to transfer between threads
|
|
163
|
+
- Sync: safe to share references between threads
|
|
164
|
+
|
|
165
|
+
primitives:
|
|
166
|
+
- Mutex<T>: mutual exclusion
|
|
167
|
+
- RwLock<T>: multiple readers or one writer
|
|
168
|
+
- Arc<T>: thread-safe reference counting
|
|
169
|
+
- mpsc: channels for message passing
|
|
170
|
+
|
|
171
|
+
patterns: |
|
|
172
|
+
// Shared state with Arc and Mutex
|
|
173
|
+
let counter = Arc::new(Mutex::new(0));
|
|
174
|
+
let counter_clone = Arc::clone(&counter);
|
|
175
|
+
|
|
176
|
+
thread::spawn(move || {
|
|
177
|
+
let mut num = counter_clone.lock().unwrap();
|
|
178
|
+
*num += 1;
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Message passing
|
|
182
|
+
let (tx, rx) = mpsc::channel();
|
|
183
|
+
thread::spawn(move || {
|
|
184
|
+
tx.send(value).unwrap();
|
|
185
|
+
});
|
|
186
|
+
let received = rx.recv().unwrap();
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 7. API Design
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
guidelines:
|
|
193
|
+
- Accept borrowed data when possible
|
|
194
|
+
- Return owned data when the caller needs it
|
|
195
|
+
- Use Into/AsRef for flexible parameters
|
|
196
|
+
- Implement standard conversion traits
|
|
197
|
+
|
|
198
|
+
constructors:
|
|
199
|
+
- new() for primary constructor
|
|
200
|
+
- with_* for alternative constructors
|
|
201
|
+
- Builder pattern for many parameters
|
|
202
|
+
|
|
203
|
+
methods:
|
|
204
|
+
- is_* for boolean queries
|
|
205
|
+
- as_* for cheap conversions (borrows)
|
|
206
|
+
- to_* for expensive conversions (copies)
|
|
207
|
+
- into_* for ownership transfers
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 8. Documentation
|
|
211
|
+
|
|
212
|
+
```yaml
|
|
213
|
+
rules:
|
|
214
|
+
- Document all public items
|
|
215
|
+
- Include examples in doc comments
|
|
216
|
+
- Use # Examples section
|
|
217
|
+
- Document panics, errors, safety
|
|
218
|
+
|
|
219
|
+
format: |
|
|
220
|
+
/// Brief description.
|
|
221
|
+
///
|
|
222
|
+
/// More detailed explanation if needed.
|
|
223
|
+
///
|
|
224
|
+
/// # Examples
|
|
225
|
+
///
|
|
226
|
+
/// ```
|
|
227
|
+
/// let result = my_function(42);
|
|
228
|
+
/// assert_eq!(result, 84);
|
|
229
|
+
/// ```
|
|
230
|
+
///
|
|
231
|
+
/// # Panics
|
|
232
|
+
///
|
|
233
|
+
/// Panics if the input is zero.
|
|
234
|
+
pub fn my_function(x: i32) -> i32 {
|
|
235
|
+
x * 2
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 9. Project Structure
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
layout:
|
|
243
|
+
- src/lib.rs or src/main.rs: crate root
|
|
244
|
+
- src/bin/: additional binaries
|
|
245
|
+
- tests/: integration tests
|
|
246
|
+
- benches/: benchmarks
|
|
247
|
+
- examples/: example programs
|
|
248
|
+
|
|
249
|
+
modules:
|
|
250
|
+
- One module per file
|
|
251
|
+
- mod.rs or filename.rs for module
|
|
252
|
+
- pub use for re-exports
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Application
|
|
256
|
+
|
|
257
|
+
When writing or reviewing Rust code:
|
|
258
|
+
|
|
259
|
+
1. **Always** handle ownership correctly
|
|
260
|
+
2. **Always** handle errors with Result/Option
|
|
261
|
+
3. **Prefer** borrowing over cloning
|
|
262
|
+
4. **Prefer** zero-cost abstractions
|
|
263
|
+
5. **Implement** standard traits (Debug, Clone, etc.)
|
|
264
|
+
6. **Document** public APIs with examples
|
|
265
|
+
7. **Avoid** unsafe unless necessary
|
|
266
|
+
8. **Use** clippy for linting
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Rust Best Practices Skill
|
|
2
|
+
|
|
3
|
+
metadata:
|
|
4
|
+
name: rust-best-practices
|
|
5
|
+
category: development
|
|
6
|
+
description: Idiomatic Rust patterns from official guidelines
|
|
7
|
+
|
|
8
|
+
source:
|
|
9
|
+
type: internal
|
|
10
|
+
reference:
|
|
11
|
+
- https://doc.rust-lang.org/book/
|
|
12
|
+
- https://rust-lang.github.io/api-guidelines/
|
|
13
|
+
- https://doc.rust-lang.org/nightly/style-guide/
|
|
14
|
+
|
|
15
|
+
provides:
|
|
16
|
+
- Rust naming conventions
|
|
17
|
+
- Ownership and borrowing patterns
|
|
18
|
+
- Error handling patterns
|
|
19
|
+
- Trait and generic design
|
|
20
|
+
- Memory management guidelines
|
|
21
|
+
- Concurrency patterns
|
|
22
|
+
- API design guidelines
|
|
23
|
+
- Documentation standards
|
|
24
|
+
|
|
25
|
+
used_by:
|
|
26
|
+
- rust-expert
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# TypeScript Best Practices Skill
|
|
2
|
+
|
|
3
|
+
> **Category**: Development
|
|
4
|
+
> **Source**: Internal (based on Google TypeScript Style Guide and TypeScript Handbook)
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
|
|
8
|
+
Apply type-safe TypeScript patterns and best practices from industry standards.
|
|
9
|
+
|
|
10
|
+
## Core Principles
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
Type safety over convenience
|
|
14
|
+
Explicit over implicit
|
|
15
|
+
Prefer strict mode
|
|
16
|
+
Use inference wisely
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
### 1. Type System
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
type_inference:
|
|
25
|
+
rely_on: trivially inferred types (primitives, literals)
|
|
26
|
+
annotate: complex expressions, return types, public APIs
|
|
27
|
+
|
|
28
|
+
any_vs_unknown:
|
|
29
|
+
prefer: unknown (requires type narrowing)
|
|
30
|
+
avoid: any (disables type checking)
|
|
31
|
+
if_any_needed: add suppressing comment
|
|
32
|
+
|
|
33
|
+
nullable:
|
|
34
|
+
prefer: "field?: Type"
|
|
35
|
+
avoid: "field: Type | undefined"
|
|
36
|
+
compare_enums: explicitly, not boolean coercion
|
|
37
|
+
|
|
38
|
+
patterns: |
|
|
39
|
+
// Good: unknown with narrowing
|
|
40
|
+
function process(data: unknown): void {
|
|
41
|
+
if (typeof data === 'string') {
|
|
42
|
+
console.log(data.toUpperCase());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Avoid: any
|
|
47
|
+
function process(data: any): void {
|
|
48
|
+
console.log(data.toUpperCase()); // No type checking!
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Interfaces vs Types
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
prefer_interfaces:
|
|
56
|
+
- Object type definitions
|
|
57
|
+
- Public API contracts
|
|
58
|
+
- Extendable types
|
|
59
|
+
|
|
60
|
+
use_types_for:
|
|
61
|
+
- Union types
|
|
62
|
+
- Intersection types
|
|
63
|
+
- Mapped types
|
|
64
|
+
- Utility types
|
|
65
|
+
|
|
66
|
+
patterns: |
|
|
67
|
+
// Interface for objects
|
|
68
|
+
interface User {
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
email: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Type for unions/utilities
|
|
75
|
+
type Status = 'pending' | 'active' | 'completed';
|
|
76
|
+
type ReadonlyUser = Readonly<User>;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 3. Arrays and Generics
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
array_syntax:
|
|
83
|
+
simple_types: "T[]"
|
|
84
|
+
complex_types: "Array<T>"
|
|
85
|
+
|
|
86
|
+
generics:
|
|
87
|
+
naming: single uppercase (T, K, V) or descriptive (TItem, TResult)
|
|
88
|
+
constraints: use extends for type bounds
|
|
89
|
+
defaults: provide when appropriate
|
|
90
|
+
|
|
91
|
+
patterns: |
|
|
92
|
+
// Array syntax
|
|
93
|
+
const numbers: number[] = [1, 2, 3];
|
|
94
|
+
const items: Array<{ id: string; value: number }> = [];
|
|
95
|
+
|
|
96
|
+
// Generic constraints
|
|
97
|
+
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
|
|
98
|
+
return obj[key];
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 4. Variables and Constants
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
declarations:
|
|
106
|
+
prefer: const
|
|
107
|
+
when_needed: let
|
|
108
|
+
never: var
|
|
109
|
+
|
|
110
|
+
one_per_statement: true
|
|
111
|
+
|
|
112
|
+
patterns: |
|
|
113
|
+
// Good
|
|
114
|
+
const name = 'TypeScript';
|
|
115
|
+
const version = 5.0;
|
|
116
|
+
|
|
117
|
+
// Avoid
|
|
118
|
+
var name = 'TypeScript', version = 5.0;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 5. Functions
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
function_declarations:
|
|
125
|
+
named_functions: function declaration
|
|
126
|
+
callbacks: arrow functions
|
|
127
|
+
methods: shorthand syntax
|
|
128
|
+
|
|
129
|
+
parameters:
|
|
130
|
+
prefer_rest: "...args: T[]"
|
|
131
|
+
avoid: arguments object
|
|
132
|
+
|
|
133
|
+
this_handling:
|
|
134
|
+
prefer: arrow functions or explicit parameter
|
|
135
|
+
avoid: rebinding with bind/call/apply
|
|
136
|
+
|
|
137
|
+
patterns: |
|
|
138
|
+
// Function declaration
|
|
139
|
+
function processData(data: Data): Result {
|
|
140
|
+
return transform(data);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Arrow function for callbacks
|
|
144
|
+
items.map((item) => item.value);
|
|
145
|
+
|
|
146
|
+
// Rest parameters
|
|
147
|
+
function concat(...strings: string[]): string {
|
|
148
|
+
return strings.join('');
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 6. Classes
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
visibility:
|
|
156
|
+
prefer: explicit modifiers (public, private, protected)
|
|
157
|
+
avoid: private fields (#)
|
|
158
|
+
|
|
159
|
+
initialization:
|
|
160
|
+
prefer: at declaration site
|
|
161
|
+
use: parameter properties in constructors
|
|
162
|
+
|
|
163
|
+
readonly:
|
|
164
|
+
apply_to: non-reassigned properties
|
|
165
|
+
|
|
166
|
+
patterns: |
|
|
167
|
+
class User {
|
|
168
|
+
readonly id: string;
|
|
169
|
+
private email: string;
|
|
170
|
+
|
|
171
|
+
constructor(
|
|
172
|
+
public name: string,
|
|
173
|
+
email: string,
|
|
174
|
+
) {
|
|
175
|
+
this.id = generateId();
|
|
176
|
+
this.email = email;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 7. Naming Conventions
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
UpperCamelCase:
|
|
185
|
+
- Classes
|
|
186
|
+
- Interfaces
|
|
187
|
+
- Type aliases
|
|
188
|
+
- Enums
|
|
189
|
+
- Type parameters
|
|
190
|
+
|
|
191
|
+
lowerCamelCase:
|
|
192
|
+
- Variables
|
|
193
|
+
- Parameters
|
|
194
|
+
- Functions
|
|
195
|
+
- Methods
|
|
196
|
+
- Properties
|
|
197
|
+
|
|
198
|
+
CONSTANT_CASE:
|
|
199
|
+
- Global constants
|
|
200
|
+
- Enum values
|
|
201
|
+
- Static readonly fields
|
|
202
|
+
|
|
203
|
+
rules:
|
|
204
|
+
- No leading/trailing underscores
|
|
205
|
+
- No abbreviations (except universal: URL, ID, DNS)
|
|
206
|
+
- Acronyms as whole words: loadHttpUrl, not loadHTTPURL
|
|
207
|
+
- Single-letter names only in 10-line scopes
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 8. Control Flow
|
|
211
|
+
|
|
212
|
+
```yaml
|
|
213
|
+
braces:
|
|
214
|
+
always: use braces for all control statements
|
|
215
|
+
|
|
216
|
+
equality:
|
|
217
|
+
always: "=== and !=="
|
|
218
|
+
never: "== and !="
|
|
219
|
+
|
|
220
|
+
loops:
|
|
221
|
+
arrays: for...of
|
|
222
|
+
objects: for...in with hasOwnProperty check
|
|
223
|
+
|
|
224
|
+
patterns: |
|
|
225
|
+
// Always braced
|
|
226
|
+
if (condition) {
|
|
227
|
+
doSomething();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// for...of for arrays
|
|
231
|
+
for (const item of items) {
|
|
232
|
+
process(item);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// for...in with check
|
|
236
|
+
for (const key in obj) {
|
|
237
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
238
|
+
process(obj[key]);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 9. Error Handling
|
|
244
|
+
|
|
245
|
+
```yaml
|
|
246
|
+
throwing:
|
|
247
|
+
only: Error instances
|
|
248
|
+
with_message: descriptive error messages
|
|
249
|
+
|
|
250
|
+
catching:
|
|
251
|
+
type: unknown
|
|
252
|
+
validate: before use
|
|
253
|
+
|
|
254
|
+
empty_catch:
|
|
255
|
+
require: rationale comment
|
|
256
|
+
|
|
257
|
+
patterns: |
|
|
258
|
+
// Throw Error instances
|
|
259
|
+
throw new Error('Invalid input');
|
|
260
|
+
|
|
261
|
+
// Catch with unknown
|
|
262
|
+
try {
|
|
263
|
+
riskyOperation();
|
|
264
|
+
} catch (error: unknown) {
|
|
265
|
+
if (error instanceof Error) {
|
|
266
|
+
console.error(error.message);
|
|
267
|
+
}
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### 10. Imports and Exports
|
|
273
|
+
|
|
274
|
+
```yaml
|
|
275
|
+
imports:
|
|
276
|
+
prefer: named imports
|
|
277
|
+
use_namespace: for large APIs
|
|
278
|
+
prefer_relative: within project
|
|
279
|
+
|
|
280
|
+
exports:
|
|
281
|
+
prefer: named exports
|
|
282
|
+
avoid: default exports
|
|
283
|
+
|
|
284
|
+
patterns: |
|
|
285
|
+
// Named imports
|
|
286
|
+
import { User, UserService } from './user';
|
|
287
|
+
|
|
288
|
+
// Namespace import for large APIs
|
|
289
|
+
import * as fs from 'fs';
|
|
290
|
+
|
|
291
|
+
// Named exports
|
|
292
|
+
export interface User { }
|
|
293
|
+
export function createUser() { }
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 11. Disallowed Features
|
|
297
|
+
|
|
298
|
+
```yaml
|
|
299
|
+
never_use:
|
|
300
|
+
- eval() or dynamic code evaluation
|
|
301
|
+
- with statements
|
|
302
|
+
- const enum (use plain enum)
|
|
303
|
+
- debugger statements in production
|
|
304
|
+
- Modifying built-in prototypes
|
|
305
|
+
- Wrapper objects (new String(), new Boolean())
|
|
306
|
+
- Automatic semicolon insertion reliance
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Application
|
|
310
|
+
|
|
311
|
+
When writing or reviewing TypeScript code:
|
|
312
|
+
|
|
313
|
+
1. **Always** enable strict mode
|
|
314
|
+
2. **Always** use explicit return types for public APIs
|
|
315
|
+
3. **Prefer** unknown over any
|
|
316
|
+
4. **Prefer** interfaces for object types
|
|
317
|
+
5. **Use** const by default
|
|
318
|
+
6. **Use** triple equals exclusively
|
|
319
|
+
7. **Handle** errors with typed catch blocks
|
|
320
|
+
8. **Avoid** default exports
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# TypeScript Best Practices Skill
|
|
2
|
+
|
|
3
|
+
metadata:
|
|
4
|
+
name: typescript-best-practices
|
|
5
|
+
category: development
|
|
6
|
+
description: Type-safe TypeScript patterns from industry standards
|
|
7
|
+
|
|
8
|
+
source:
|
|
9
|
+
type: internal
|
|
10
|
+
reference:
|
|
11
|
+
- https://www.typescriptlang.org/docs/handbook/
|
|
12
|
+
- https://google.github.io/styleguide/tsguide.html
|
|
13
|
+
- https://basarat.gitbook.io/typescript/
|
|
14
|
+
|
|
15
|
+
provides:
|
|
16
|
+
- TypeScript type system patterns
|
|
17
|
+
- Interface and type design
|
|
18
|
+
- Generic usage guidelines
|
|
19
|
+
- Variable and constant rules
|
|
20
|
+
- Function design patterns
|
|
21
|
+
- Class structure guidelines
|
|
22
|
+
- Naming conventions
|
|
23
|
+
- Control flow patterns
|
|
24
|
+
- Error handling patterns
|
|
25
|
+
- Import/export organization
|
|
26
|
+
|
|
27
|
+
used_by:
|
|
28
|
+
- typescript-expert
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Vercel Deploy
|
|
2
|
+
|
|
3
|
+
> **Source**: vercel-labs/agent-skills
|
|
4
|
+
> **Capability**: Instant deployment to Vercel
|
|
5
|
+
|
|
6
|
+
## When to Use
|
|
7
|
+
|
|
8
|
+
- Deploy application to Vercel
|
|
9
|
+
- Create preview deployments
|
|
10
|
+
- Generate shareable URLs
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
### Framework Detection
|
|
15
|
+
```
|
|
16
|
+
Auto-detects 40+ frameworks from package.json:
|
|
17
|
+
- Next.js
|
|
18
|
+
- React
|
|
19
|
+
- Vue
|
|
20
|
+
- Nuxt
|
|
21
|
+
- Svelte
|
|
22
|
+
- Astro
|
|
23
|
+
- and more...
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Auto Exclusions
|
|
27
|
+
```
|
|
28
|
+
Automatically excludes:
|
|
29
|
+
- node_modules/
|
|
30
|
+
- .git/
|
|
31
|
+
- .env files
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Output
|
|
35
|
+
```
|
|
36
|
+
On successful deployment:
|
|
37
|
+
1. Preview URL (view deployment)
|
|
38
|
+
2. Claim URL (transfer ownership)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Execution Flow
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
1. Detect project framework
|
|
45
|
+
2. Prepare deployment bundle
|
|
46
|
+
3. Upload to Vercel
|
|
47
|
+
4. Return URLs
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Output Format
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
[Deploy Success]
|
|
54
|
+
Preview: https://project-xxx.vercel.app
|
|
55
|
+
Claim: https://vercel.com/claim/xxx
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Scripts
|
|
59
|
+
|
|
60
|
+
See `scripts/deploy.sh` for deployment automation.
|
|
61
|
+
|
|
62
|
+
## Requirements
|
|
63
|
+
|
|
64
|
+
- Valid project structure
|
|
65
|
+
- package.json present
|
|
66
|
+
- Vercel CLI or API token (for authenticated deploys)
|
|
67
|
+
|
|
68
|
+
## Limitations
|
|
69
|
+
|
|
70
|
+
- Claimable deploys are anonymous
|
|
71
|
+
- Preview URLs are temporary
|
|
72
|
+
- Full features require Vercel account
|
|
73
|
+
```
|