design-philosophy
Skill485 starsChanged 2 months agoApache-2.0View on GitHub
Core design principles for the codebase - cognitive load, progressive disclosure, type safety, abstraction worth. Use when designing APIs, modules, or data structures.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- microsoft/vscodetheir own version, first seen Nov 12, 2026
- connerkward/ckw-design-skilltheir own version, first seen Jun 16, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- microsoft/vscode★ 196ksame name
- connerkward/ckw-design-skill★ 9same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository29 other files it gives its agents.
- .agents/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- build-infra/AGENTS.mdAGENTS.md
- rust-analyzer-mcp-server/AGENTS.mdAGENTS.md
- task/AGENTS.mdAGENTS.md
- analyze-log-filesSkill
- analyze-performanceSkill
- audit-taskSkill
- batch-refactor-with-sub-agentsSkill
- check-bounds-safetySkill
- check-code-qualitySkill
- check-test-coverageSkill
- code-reviewSkill
- concurrency-safetySkill
- create-commit-messageSkill
- create-prSkill
- fast-string-allocationsSkill
- fix-issueSkill
- merge-prSkill
- organize-modulesSkill
- organize-testsSkill
- release-crateSkill
- remove-crate-prefixSkill
- review-prSkill
- run-clippySkill
- safe-renamingSkill
- test-cross-platformSkill
- write-documentationSkill
- write-structured-tracingSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
19 rules. About 0 are common, 7 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
When refactoring existing code
- Distinctive: line 14
When reviewing code for maintainability
- Very specific: line 27
Clean Imports: Use use statements at the top of files rather than inline absolute paths (e.g.
- Distinctive: line 29
Technical Precision: Use standard, precise terminology (e.g., Parameter vs.
- Distinctive: line 46
Use the type system to prevent bugs at compile time.
- Very specific: line 50
Prefer newtypes over primitives (e.g., Index instead of usize)
- Very specific: line 53
Constructor Conventions (
Defaultover No-Argnew()): If a type requires no arguments for construction, derive or implement Default … - Distinctive: line 64
If understanding the abstraction requires more effort than the concrete code, don't abstract
- Distinctive: line 71
Treat errors as a user interface (UI) for developers.
- Very specific: line 75
Standardize on
miette: All custom error types (enums/structs) must derive miette::Diagnostic in addition to thiserror::Error. - Very specific: line 76
Actionable Metadata: Use #[diagnostic(help(...))] to provide hints on how to resolve the error.
- Very specific: line 77
Searchable Codes: Use #[diagnostic(code(...))] to provide unique identifiers for errors, facilitating documentation and search.
- Very specific: line 78
Preserve Context: Avoid "lossy" error conversions (like turning a rich miette::Report into a plain string).
- Very specific: line 82
Use Enums with Const Generics (Algebraic Data Type Const Params) to control behavior without runtime overhead or boilerplate.
- Very specific: line 88
Zero-Cost Behavior: Prefer const POLICY: MyEnum over runtime fields.
- Very specific: line 90
Reduce Boilerplate: Prefer const Enums over the Trait-based Strategy pattern.
- Distinctive: line 91
Type-Level Identity: Use this pattern when you want different behaviors to result in different types, enabling compile-time enforcement of …
- Very specific: line 99
No
pubfor tests: Never make a field or method pub or pub(crate) if its only external caller is a test. - Very specific: line 100
Test-Only Accessors: Keep production fields strictly scoped (private or pub(in crate::...)).
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Design Philosophy Skill
Apply these principles when writing or reviewing code.
When to Use
- Proactively when designing new APIs, modules, or data structures
- When refactoring existing code
- When reviewing code for maintainability
Core Principles
1. Minimize Cognitive Load
Code should be easy to understand without loading too much into working memory.
Guidelines:
- Good Separation of Concerns (SoC) means fewer "things" to keep in mind
- Each module/function should have a single, clear responsibility
- Limit the number of concepts a reader must hold simultaneously
- Clean Imports: Use
usestatements at the top of files rather than inline absolute paths (e.g.crate::Type) to reduce visual noise and cognitive clutter in function bodies. - No Magic Numbers/Strings: Extract domain-specific numbers and strings (like ANSI mode integers or escape sequences) into named constants (e.g., in
tui/src/core/ansi/constants/). Do not use magic numbers directly in business logic or pattern matches, as this requires readers to memorize their meaning. - Technical Precision: Use standard, precise terminology (e.g., Parameter vs. Argument) to ensure the reader's mental model matches the implementation exactly. See the Terminology Precision guide.
2. Progressive Disclosure
Reveal complexity only when needed.
Guidelines:
- Public APIs should be minimal and intuitive
- Advanced features should be discoverable but not in-your-face
- Documentation follows inverted pyramid: high-level first, details later
- Module structure should guide users from simple to advanced
3. Make Illegal States Unrepresentable
Use the type system to prevent bugs at compile time.
Guidelines:
- Prefer newtypes over primitives (e.g.,
Indexinstead ofusize) - Eliminate Boolean Soup / Boolean Blindness: Avoid raw
boolflags, function parameters, or return values that obscure intent (e.g.fn process(flag: bool)orfn is_default() -> bool). Replace boolean soup with self-documenting domain enums (e.g.SyntaxHighlightPipeline::R3BLMarkdowninstead ofis_file_extension_default() -> bool, orHasSelection::Yes/No). Domain enums make call sites self-documenting and leverage Rust'smatchfor exhaustive compiler checking. - Avoid Boolean Blindness in Mutator Returns (
Option<T>/Option<()>): Mutator methods taking&mut selfthat delete or replace text cannot return borrowed slices (Option<&str>) or metadata offsets (DocSeg) because the borrow checker forbids returning a&strborrowing fromselfacross a&mut selfmutation, and deleted bytes no longer exist in memory. Returning a text payload from a&mut selfmutator unavoidably requires an owned heap allocation (Option<String>). Return a payloadOption<T>(e.g.Option<LineMetadata>for zero-allocation metrics orOption<String>for text) ONLY when callers genuinely consume it. If no text payload is consumed by callers, do not incur speculative allocations. ReturnOption<()>(Some(())for success,Nonefor failure).Option<()>achieves the exact same zero-allocation CPU-register performance asboolwhile eliminating boolean blindness and supporting?operator chaining. - Constructor Conventions (
Defaultover No-Argnew()): If a type requires no arguments for construction, derive or implementDefault(#[derive(Default)]) and do NOT create a redundantpub fn new() -> Selfmethod. Use parameterized constructors (with_capacity(...)ornew(arg: Type)) only when arguments are required. - Design enums and structs so invalid combinations cannot be constructed
- Move validation from runtime to compile time where possible
- See
check-bounds-safetyskill for exemplary patterns
4. Abstractions Must Earn Their Keep
An abstraction should reduce cognitive load, not add to it.
Guidelines:
- If understanding the abstraction requires more effort than the concrete code, don't abstract
- Good abstractions match mental models developers already have
- Three similar lines of code is often better than a premature abstraction
- Abstractions should hide complexity, not just move it
5. High-Fidelity Error Handling
Treat errors as a user interface (UI) for developers. Public-facing errors must provide actionable information.
Guidelines:
- Standardize on
miette: All custom error types (enums/structs) must derivemiette::Diagnosticin addition tothiserror::Error. - Actionable Metadata: Use
#[diagnostic(help(...))]to provide hints on how to resolve the error. - Searchable Codes: Use
#[diagnostic(code(...))]to provide unique identifiers for errors, facilitating documentation and search. - Preserve Context: Avoid "lossy" error conversions (like turning a rich
miette::Reportinto a plain string). Use transparent delegation or dedicated variants to preserve the full error chain.
6. Modern Rust Patterns: ADT Const Params
Use Enums with Const Generics (Algebraic Data Type Const Params) to control behavior without runtime overhead or boilerplate. This pattern is enabled by the adt_const_params feature flag.
When to Apply:
- Proactively apply this pattern when writing new code or refactoring existing code that requires choosing between a closed set of behaviors or strategies at compile-time.
Guidelines:
- Zero-Cost Behavior: Prefer
const POLICY: MyEnumover runtime fields. This allows the compiler to prune dead code and branches at compile-time (monomorphization). Example:ScopedMutex. - Reduce Boilerplate: Prefer
constEnums over the Trait-based Strategy pattern. This centralizes logic and eliminates the need for multiple marker structs and trait implementations. - Type-Level Identity: Use this pattern when you want different behaviors to result in different types, enabling compile-time enforcement of safety rules.
7. Strict Encapsulation & Testing Hygiene
Maintain strict encapsulation boundaries in production code and do not leak internal state merely for the convenience of tests.
Guidelines:
- No
pubfor tests: Never make a field or methodpuborpub(crate)if its only external caller is a test. - Test-Only Accessors: Keep production fields strictly scoped (private or
pub(in crate::...)). If tests need to inspect or manipulate internal state, provide explicit accessor methods annotated with#[cfg(test)](e.g.,pub(crate) fn internal_state_for_testing(&self)). This cleanly compiles the escape hatch out of the production binary.
Supporting Files
patterns.md- Detailed patterns with good/bad examples
Related Skills
check-bounds-safety- Type-safe Index/Length patterns (exemplar of principle #3)organize-modules- Module organization for encapsulation (supports principle #1)write_documentation- Inverted pyramid documentation (supports principle #2)concurrency-safety- Thread safety, Chain of Custody, and Loud Lock Releases
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

