Skip to content

Commit 255cd78

Browse files
ChaseTheAgentFatherChaseTheAgentFather
authored andcommitted
chore(workspace): add agent skills
1 parent aeb94a7 commit 255cd78

100 files changed

Lines changed: 17430 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
name: coding-guidelines
3+
description: "Use when asking about Rust code style or best practices. Keywords: naming, formatting, comment, clippy, rustfmt, lint, code style, best practice, P.NAM, G.FMT, code review, naming convention, variable naming, function naming, type naming, 命名规范, 代码风格, 格式化, 最佳实践, 代码审查, 怎么命名"
4+
source: https://rust-coding-guidelines.github.io/rust-coding-guidelines-zh/
5+
user-invocable: false
6+
---
7+
8+
# Rust Coding Guidelines (50 Core Rules)
9+
10+
## Naming (Rust-Specific)
11+
12+
| Rule | Guideline |
13+
|------|-----------|
14+
| No `get_` prefix | `fn name()` not `fn get_name()` |
15+
| Iterator convention | `iter()` / `iter_mut()` / `into_iter()` |
16+
| Conversion naming | `as_` (cheap &), `to_` (expensive), `into_` (ownership) |
17+
| Static var prefix | `G_CONFIG` for `static`, no prefix for `const` |
18+
19+
## Data Types
20+
21+
| Rule | Guideline |
22+
|------|-----------|
23+
| Use newtypes | `struct Email(String)` for domain semantics |
24+
| Prefer slice patterns | `if let [first, .., last] = slice` |
25+
| Pre-allocate | `Vec::with_capacity()`, `String::with_capacity()` |
26+
| Avoid Vec abuse | Use arrays for fixed sizes |
27+
28+
## Strings
29+
30+
| Rule | Guideline |
31+
|------|-----------|
32+
| Prefer bytes | `s.bytes()` over `s.chars()` when ASCII |
33+
| Use `Cow<str>` | When might modify borrowed data |
34+
| Use `format!` | Over string concatenation with `+` |
35+
| Avoid nested iteration | `contains()` on string is O(n*m) |
36+
37+
## Error Handling
38+
39+
| Rule | Guideline |
40+
|------|-----------|
41+
| Use `?` propagation | Not `try!()` macro |
42+
| `expect()` over `unwrap()` | When value guaranteed |
43+
| Assertions for invariants | `assert!` at function entry |
44+
45+
## Memory
46+
47+
| Rule | Guideline |
48+
|------|-----------|
49+
| Meaningful lifetimes | `'src`, `'ctx` not just `'a` |
50+
| `try_borrow()` for RefCell | Avoid panic |
51+
| Shadowing for transformation | `let x = x.parse()?` |
52+
53+
## Concurrency
54+
55+
| Rule | Guideline |
56+
|------|-----------|
57+
| Identify lock ordering | Prevent deadlocks |
58+
| Atomics for primitives | Not Mutex for bool/usize |
59+
| Choose memory order carefully | Relaxed/Acquire/Release/SeqCst |
60+
61+
## Async
62+
63+
| Rule | Guideline |
64+
|------|-----------|
65+
| Sync for CPU-bound | Async is for I/O |
66+
| Don't hold locks across await | Use scoped guards |
67+
68+
## Macros
69+
70+
| Rule | Guideline |
71+
|------|-----------|
72+
| Avoid unless necessary | Prefer functions/generics |
73+
| Follow Rust syntax | Macro input should look like Rust |
74+
75+
## Deprecated → Better
76+
77+
| Deprecated | Better | Since |
78+
|------------|--------|-------|
79+
| `lazy_static!` | `std::sync::OnceLock` | 1.70 |
80+
| `once_cell::Lazy` | `std::sync::LazyLock` | 1.80 |
81+
| `std::sync::mpsc` | `crossbeam::channel` | - |
82+
| `std::sync::Mutex` | `parking_lot::Mutex` | - |
83+
| `failure`/`error-chain` | `thiserror`/`anyhow` | - |
84+
| `try!()` | `?` operator | 2018 |
85+
86+
## Quick Reference
87+
88+
```
89+
Naming: snake_case (fn/var), CamelCase (type), SCREAMING_CASE (const)
90+
Format: rustfmt (just use it)
91+
Docs: /// for public items, //! for module docs
92+
Lint: #![warn(clippy::all)]
93+
```
94+
95+
Claude knows Rust conventions well. These are the non-obvious Rust-specific rules.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Complete Rules Reference
2+
3+
For the full 500+ rules, see:
4+
- Source: https://rust-coding-guidelines.github.io/rust-coding-guidelines-zh/
5+
6+
Core rules are in `../SKILL.md`.

.agents/skills/domain-cli/SKILL.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
name: domain-cli
3+
description: "Use when building CLI tools. Keywords: CLI, command line, terminal, clap, structopt, argument parsing, subcommand, interactive, TUI, ratatui, crossterm, indicatif, progress bar, colored output, shell completion, config file, environment variable, 命令行, 终端应用, 参数解析"
4+
globs: ["**/Cargo.toml"]
5+
user-invocable: false
6+
---
7+
8+
# CLI Domain
9+
10+
> **Layer 3: Domain Constraints**
11+
12+
## Domain Constraints → Design Implications
13+
14+
| Domain Rule | Design Constraint | Rust Implication |
15+
|-------------|-------------------|------------------|
16+
| User ergonomics | Clear help, errors | clap derive macros |
17+
| Config precedence | CLI > env > file | Layered config loading |
18+
| Exit codes | Non-zero on error | Proper Result handling |
19+
| Stdout/stderr | Data vs errors | eprintln! for errors |
20+
| Interruptible | Handle Ctrl+C | Signal handling |
21+
22+
---
23+
24+
## Critical Constraints
25+
26+
### User Communication
27+
28+
```
29+
RULE: Errors to stderr, data to stdout
30+
WHY: Pipeable output, scriptability
31+
RUST: eprintln! for errors, println! for data
32+
```
33+
34+
### Configuration Priority
35+
36+
```
37+
RULE: CLI args > env vars > config file > defaults
38+
WHY: User expectation, override capability
39+
RUST: Layered config with clap + figment/config
40+
```
41+
42+
### Exit Codes
43+
44+
```
45+
RULE: Return non-zero on any error
46+
WHY: Script integration, automation
47+
RUST: main() -> Result<(), Error> or explicit exit()
48+
```
49+
50+
---
51+
52+
## Trace Down ↓
53+
54+
From constraints to design (Layer 2):
55+
56+
```
57+
"Need argument parsing"
58+
↓ m05-type-driven: Derive structs for args
59+
↓ clap: #[derive(Parser)]
60+
61+
"Need config layering"
62+
↓ m09-domain: Config as domain object
63+
↓ figment/config: Layer sources
64+
65+
"Need progress display"
66+
↓ m12-lifecycle: Progress bar as RAII
67+
↓ indicatif: ProgressBar
68+
```
69+
70+
---
71+
72+
## Key Crates
73+
74+
| Purpose | Crate |
75+
|---------|-------|
76+
| Argument parsing | clap |
77+
| Interactive prompts | dialoguer |
78+
| Progress bars | indicatif |
79+
| Colored output | colored |
80+
| Terminal UI | ratatui |
81+
| Terminal control | crossterm |
82+
| Console utilities | console |
83+
84+
## Design Patterns
85+
86+
| Pattern | Purpose | Implementation |
87+
|---------|---------|----------------|
88+
| Args struct | Type-safe args | `#[derive(Parser)]` |
89+
| Subcommands | Command hierarchy | `#[derive(Subcommand)]` |
90+
| Config layers | Override precedence | CLI > env > file |
91+
| Progress | User feedback | `ProgressBar::new(len)` |
92+
93+
## Code Pattern: CLI Structure
94+
95+
```rust
96+
use clap::{Parser, Subcommand};
97+
98+
#[derive(Parser)]
99+
#[command(name = "myapp", about = "My CLI tool")]
100+
struct Cli {
101+
/// Enable verbose output
102+
#[arg(short, long)]
103+
verbose: bool,
104+
105+
#[command(subcommand)]
106+
command: Commands,
107+
}
108+
109+
#[derive(Subcommand)]
110+
enum Commands {
111+
/// Initialize a new project
112+
Init { name: String },
113+
/// Run the application
114+
Run {
115+
#[arg(short, long)]
116+
port: Option<u16>,
117+
},
118+
}
119+
120+
fn main() -> anyhow::Result<()> {
121+
let cli = Cli::parse();
122+
match cli.command {
123+
Commands::Init { name } => init_project(&name)?,
124+
Commands::Run { port } => run_server(port.unwrap_or(8080))?,
125+
}
126+
Ok(())
127+
}
128+
```
129+
130+
---
131+
132+
## Common Mistakes
133+
134+
| Mistake | Domain Violation | Fix |
135+
|---------|-----------------|-----|
136+
| Errors to stdout | Breaks piping | eprintln! |
137+
| No help text | Poor UX | #[arg(help = "...")] |
138+
| Panic on error | Bad exit code | Result + proper handling |
139+
| No progress for long ops | User uncertainty | indicatif |
140+
141+
---
142+
143+
## Trace to Layer 1
144+
145+
| Constraint | Layer 2 Pattern | Layer 1 Implementation |
146+
|------------|-----------------|------------------------|
147+
| Type-safe args | Derive macros | clap Parser |
148+
| Error handling | Result propagation | anyhow + exit codes |
149+
| User feedback | Progress RAII | indicatif ProgressBar |
150+
| Config precedence | Builder pattern | Layered sources |
151+
152+
---
153+
154+
## Related Skills
155+
156+
| When | See |
157+
|------|-----|
158+
| Error handling | m06-error-handling |
159+
| Type-driven args | m05-type-driven |
160+
| Progress lifecycle | m12-lifecycle |
161+
| Async CLI | m07-concurrency |

0 commit comments

Comments
 (0)