.forge/skills/dry-principles/SKILL.md
# DRY Principles Eliminate duplication to improve maintainability. Every piece of knowledge should have a single, authoritative representation in the codebase. ## Before Writing Code - Search for existing functions/utilities that solve the problem - Check if similar patterns exist elsewhere that should be unified - Consider if this logic belongs in a shared module ## Duplication Red Flags - Copy-pasting code blocks (extract to function) - Similar functions with minor variations (parameteriz
npx skillsauth add jdsingh122918/forge .forge/skills/dry-principlesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Eliminate duplication to improve maintainability. Every piece of knowledge should have a single, authoritative representation in the codebase.
// Before: Duplicated validation
fn create_user(name: &str) -> Result<User> {
if name.is_empty() { bail!("name required"); }
// ...
}
fn update_user(name: &str) -> Result<User> {
if name.is_empty() { bail!("name required"); }
// ...
}
// After: Extracted validator
fn validate_name(name: &str) -> Result<()> {
ensure!(!name.is_empty(), "name required");
Ok(())
}
fn create_user(name: &str) -> Result<User> {
validate_name(name)?;
// ...
}
When you identify duplication:
Premature abstraction is worse than duplication. Only abstract when:
development
# Testing Strategy Apply this testing strategy for all new code: ## Test Levels 1. **Unit Tests** - Test individual functions in isolation - Located in `mod tests` at the bottom of each file - Mock external dependencies - Fast, deterministic, no I/O 2. **Integration Tests** - Test modules working together - Located in `tests/` directory - Use real dependencies where practical - May involve filesystem, database, or network 3. **End-to-End Tests** - Test complete user workflo
development
# TDD Workflow Apply Test-Driven Development when implementing new functionality. Use your judgment to determine when TDD is appropriate — it's most valuable for business logic, algorithms, and complex state management. ## When to Use TDD - New functions with defined inputs/outputs - Bug fixes (write failing test first, then fix) - Refactoring existing code (ensure tests exist first) - API endpoints and data transformations ## When TDD May Not Apply - Configuration files, constants, types/i
tools
# Secure Coding Follow these secure coding practices for all code in this project. ## Input Validation - Validate all external input (user input, API responses, file contents) - Use allowlists over denylists when validating - Sanitize data before use in SQL, shell commands, or HTML output - Validate early, at system boundaries (CLI args, file reads, network responses) ## Rust-Specific Security - Minimize `unsafe` blocks; document safety invariants when used - Use established crypto librarie
tools
# Rust Conventions Follow these Rust conventions for all code in this project: ## Code Style - Use `rustfmt` defaults for formatting - Run `cargo clippy` and address all warnings before committing - Prefer `?` operator for error propagation over `.unwrap()` in library code - Use `.expect("meaningful message")` only when failure indicates a bug ## Error Handling - Use `anyhow::Result` for application code and CLI - Use `thiserror` for library errors that callers need to match on - Provide cont