What problem does it solve?
This Skill solves the pervasive pain of writing code that is prone to accidental misuse, silent state corruption, and hard-to-reproduce bugs in large, long-lived codebases, where unenforced invariants and overly permissive access lead to costly maintenance, unexpected outages, and security gaps from unintentional errors.
Core Features & Use Cases
- Defensive Coding Principles: Enforces immutability by default, minimal visibility, explicit design by contract, boundary validation, and resource safety to eliminate entire classes of common bugs.
- Language-Specific Idioms: Provides idiomatic implementation patterns for C++, Java, Python, and Rust, so you can apply defensive practices without fighting your language's standard conventions.
- Real-World Use Case: When building a public SDK used by external teams, use this Skill to ensure all public APIs have strict preconditions, internal state is fully protected from accidental modification, and resources are always cleaned up properly to prevent leaks in long-running processes.
Quick Start
Use the defensive-programming skill to refactor the existing UserService class to make all internal fields immutable, restrict all helper methods to private visibility, and add precondition assertions to the public create_user() method.