Install any skill in seconds. Free to start, no credit card required.
Get Started Free →rtk-ai/design-patterns
Rust design patterns for RTK. Newtype, Builder, RAII, Trait Objects, State Machine. Applied to CLI filter modules.
Passed 20 of 22 test cases with the skill, and 14 of 22 without it.
and 5 more in the full report
7 fixed13 passed either way1 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 7 test cases the skill fixed. Same model, same prompt, with and without the skill.
What is the recommended design pattern when implementing a Rust parser that handles multi-phase output with changing context, and what alternative pattern should be specifically avoided?
| Checked | Without skill | With skill |
|---|---|---|
| recommends a state machine pattern | Passed | Passed |
| advises avoiding deeply nested if-else statements | Missed | Passed |
The instructions your model reads when the skill loads.
Patterns that apply to RTK's filter module architecture. Focused on CLI tool patterns, not web/service patterns.
Use when: wrapping primitive types to prevent misuse (command names, paths, token counts).
// Without Newtype — easy to mix up
fn track(input_tokens: usize, output_tokens: usize) { ... }
track(output_tokens, input_tokens); // Silent bug!
// With Newtype — compile error on swap
pub struct InputTokens(pub usize);
pub struct OutputTokens(pub usize);
fn track(input: InputTokens, output: OutputTokens) { ... }
track(OutputTokens(100), InputTokens(400)); // Compile error ✅
// Practical RTK example: command name validation
pub struct CommandName(String);
impl CommandName {
pub fn new(s: &str) -> Result<Self> {
if s.contains(';') || s.contains('|') || s.contains('`') {
anyhow::bail!("Invalid command name: shell metacharacters");
}
Ok(Self(s.to_string()))
}
pub fn as_str(&self) -> &str { &self.0 }
}
Use when: a struct has 4+ optional fields, many with defaults.
#[derive(Default)]
test cases passed, vs 14 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.