Design Patterns
Rust design pattern reference for RTK CLI filter modules: Newtype, Builder, RAII, and more.
- CCM score
- 69 of 100
- skills.sh installs
- 2.1K
- GitHub stars
- 88.2K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers seven patterns: Newtype, Builder, State Machine, Trait Object, RAII, Strategy, and Extension Trait, each with a when-to-use rule
- Includes a selection table mapping situations like multi-phase output parsing or adding methods to
&strto the right pattern - Lists anti-patterns to avoid, such as singleton registries, async traits, and over-generic filter abstractions in a single-threaded tool
- Designed for developers designing new
*_cmd.rsfilter modules or refactoring existing ones in the RTK codebase
Install
$ npx -y skills add rtk-ai/rtk --skill design-patterns -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
RTK Rust Design Patterns
Patterns that apply to RTK's filter module architecture. Focused on CLI tool patterns, not web/service patterns.
Pattern 1: Newtype (Type Safety)
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 }
}
Pattern 2: Builder (Complex Configuration)
Use when: a struct has 4+ optional fields, many with defaults.
Details
- Repository
- github.com/rtk-ai/rtk
- Categories
- Rust, CLI & Terminal
- First seen
- Jun 3, 2026
Questions
What does the design-patterns skill help with?
It gives Rust design patterns for RTK's CLI filter modules, including Newtype, Builder, RAII, Trait Objects and State Machine. It is meant for designing new modules or refactoring existing ones.
How do I install the design-patterns skill?
Run npx -y skills add rtk-ai/rtk --skill design-patterns -y in your project. Once installed, the agent can read the pattern guidance to choose a fitting pattern for a filter module.
Where does design-patterns rank among Rust skills?
It sits in the Rust category on Claude Marketplaces and ranks in the top 50 there. It focuses on architecture patterns for RTK filter code, where a general Rust skill would cover broader topics.
When should an agent use the Builder or State Machine pattern from this skill?
The skill suggests Builder for a struct with four or more optional fields, and State Machine for parsing multi-section output such as test results. It also warns against over-engineering simple cases.
More from rtk-ai/rtk
All 7Similar to Design Patterns
More Rusttdd-rustSkillrtk-ai/rtk1.6K installsTest-driven workflow for building RTK output filters in Rust, with real fixtures and enforced token-savings checks.
code-simplifierSkillrtk-ai/rtk2.4K installsRust simplification guide for RTK that removes verbosity while preserving the project's required constraints.
robotics-design-patternsSkillarpitg1304/robotics-agent-skills294 installsArchitecture patterns and recipes for robot software, covering behavior trees, state machines, and safety design.
loop-libraryPluginalirezarezvani/claude-skills30.7K starsDiscover, compare, audit, repair, adapt, and design repeatable AI-agent loops with explicit triggers, actions, verification, stopping conditions, guardrails, an