Skip to content
Skills Library
Programming · Review & audit

stb-principles

/stb-principles

Applies Sean Barrett's stb library principles to any code or system, in any language - easy to use first, few dependencies, one idea per module, small public interface, small footprint, honest limits, explicit context, plain code. Use when writing, reviewing, refactoring or designing code, modules, APIs or services, or when the user says "stb", "stb-style" or "Barrett rules".

Repository
smit-skills ↗
Licence
MIT
Last repository change
13.11.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
6
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Applies Sean Barrett's stb library principles to any code or system, in any language - easy to use first, few dependencies, one idea per module, small public interface, small footprint, honest limits, explicit context, plain code. Use when writing, reviewing, refactoring or designing code, modules, APIs or services, or when the user says "stb", "stb-style" or "Barrett rules".

Triggers from the description

stbstb-styleBarrett rules
Original author description

Applies Sean Barrett's stb library principles to any code or system, in any language - easy to use first, few dependencies, one idea per module, small public interface, small footprint, honest limits, explicit context, plain code. Use when writing, reviewing, refactoring or designing code, modules, APIs or services, or when the user says "stb", "stb-style" or "Barrett rules".

How it works

  1. 1. Easy to use, then easy to maintain, then fast
  2. 2. Few dependencies
  3. 3. One idea, one self-contained module
  4. 4. Small public interface, private internals
  5. 5. Small footprint, narrow scope
  6. 6. Usage notes and honest limits up front
  7. 7. Pass context in, no hidden global state
  8. 8. Plain, direct code
  9. Checklist before you call a change done
Original SKILL.md headings · 91 lines, 834 words
SKILL.md preview
---
name: stb-principles
description: Applies Sean Barrett's stb library principles to any code or system, in any language - easy to use first, few dependencies, one idea per module, small public interface, small footprint, honest limits, explicit context, plain code. Use when writing, reviewing, refactoring or designing code, modules, APIs or services, or when the user says "stb", "stb-style" or "Barrett rules".
---

# STB principles

Eight rules from Sean T. Barrett's stb libraries, made general. Rule 1 decides ties between the others.

## 1. Easy to use, then easy to maintain, then fast

Barrett: "1. easy to use 2. easy to maintain 3. good performance." (`sources/stb_image.h`, lines 226 to 246)

- Pick the version a caller can use without mistakes from its signature alone.
- Pick readable over clever. Optimize only with a measurement in hand.
- When two options tie, take the one with fewer ways to misuse it.
- **Systems:** the default path through a service or tool is the correct one. No setup step the caller can forget.

## 2. Few dependencies

Barrett: "Don't rely on anything other than the C standard libraries." (`sources/docs/stb_howto.txt`, line 31)

- Reach for the language's standard library or platform first.
- Add no package for something a few lines can do.
- Need one anyway? Pin it, say why, and wrap it in one module so nothing else imports it.
- Use what the codebase already uses before you bring in a second tool for the same job.
- **Systems:** each outside service is one more thing that can go down. Put each behind one seam you can swap.

## 3. One idea, one self-contained module

Barrett: "the difference between 2 files and 1 file is a big deal." (`sources/README.md`, line 145)

- One idea lives in one module you can read top to bottom.
- Don't split a small idea across many tiny files. Don't pile unrelated ideas into one large file.
- Touch the fewest files the change needs.
- **Systems:** one job per service. Don't split one job across services that must deploy together.

## 4. Small public interface, private internals

Barrett puts public names under one prefix and private ones under another, so internals never leak. (`sources/docs/stb_howto.txt`, lines 94 to 104)

- Expose only what another module uses. Keep the rest private with the language's own tools.
- No exports kept for tests when the test can go through the public path.
- Before adding one, search for an existing one that does the job.
- **Systems:** few endpoints, few config options, few flags. Each one is a promise you keep forever.

## 5. Small footprint, narrow scope

Barrett stopped adding formats because each one "increases the amount of code we need to secure." (`sources/README.md`, lines 155 to 160)

- Change only what the task needs. No side refactors in the same change.
- Each new line is code someone secures and maintains. Delete before you add.
- Say no to options nobody asked for.
- **Systems:** each feature, port and permission adds attack surface. Ship the smallest set that does the job.

## 6. Usage notes and honest limits up front

Each stb header opens with how to use it, its options, and what it does not guarantee. (`sources/stb_image.h`, lines 1 to 60)

- Start any non-obvious module with one short note: what it does, how to call it, what it does not promise.
- State limits in plain words: "Safe against crashes. Not safe against power loss."
- Update a comment in the same change that makes it wrong. A false comment is worse than none.
- Match the comment density around you.
- **Systems:** the README or service doc says what fails, what isn't atomic, and which limits exist.

## 7. Pass context in, no hidden global state

Barrett: "consider letting the user pass in a context ... Otherwise, users may have to use global or thread-local variables." (`sources/docs/stb_howto.txt`, lines 44 to 47)

- Pass dependencies in as arguments.
- No module-level mutable state, global registries or singletons.
- No side effects that run because something got imported or loaded.
- **Systems:** no shared mutable config that changes behavior at runtime without the caller knowing. Pass it in the request or at startup.

## 8. Plain, direct code

Barrett: the library should be "easy to invoke (which requires good API design)." (`sources/docs/stb_howto.txt`, line 132)

- Plain functions over classes, factories, or interfaces with one implementation.
- Straight-line code a tired reader gets on the first pass.
- Name things for what they do.
- Fail with one clear error, close to the cause. Never swallow an error into an empty value.
- **Systems:** one clear error at the boundary beats silent retries and fallbacks that hide the cause.

## Checklist before you call a change done

1. Can a caller use it without mistakes from the signature or docs alone?
2. Zero new dependencies, or one that's pinned, justified and wrapped?
3. Fewest files or services, each holding one idea?
4. Is each new public name or endpoint used somewhere?
5. Does the diff touch only what the task needs?
6. Do non-obvious parts state what they don't guarantee, and is each comment you touched still true?
7. No new global state, singletons or load-time side effects?
8. No class or layer where one function works, and no swallowed errors?
Files in this package (6)
  • SKILL.md 5 KB
  • sources/LICENSE 3 KB
  • sources/ORIGIN.md 1 KB
  • sources/README.md 9 KB
  • sources/stb_image.h 271 KB
  • sources/docs/stb_howto.txt 7 KB

Versions

The database has no other skills named stb-principles.

Database snapshot: 13.11.2026 · package version be4da72a5464 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100writing-maintainable-code
    Principles for code that is easy to understand, change and trust. Use when writing, refactoring or reviewing code in any language, when a change touches business logic, external APIs, validation or error handling, or when preparing a commit or pull request.
  • 100backend-architecture-principles
    Language-agnostic backend architecture and code-quality rules. Use when designing services, structuring a backend codebase, writing business logic, handling errors, configuration, logging, background jobs, or reviewing backend code for maintainability.
  • 85engineering-principles
    Use when designing systems, structuring code, reviewing diffs, handling state, or adhering to core software engineering discipline principles.
  • 100codebase-design
    Shared vocabulary and principles for designing deep modules — small interfaces, clean seams, testable through the interface. Use when designing or improving a module's interface, deciding where a seam goes, hunting deepening opportunities, making code more testable, or when…
  • 100coding-principles
    Language-agnostic coding principles for maintainability, readability, and quality. Use when implementing features, refactoring code, or reviewing code quality.
  • 100code-quality-principles
    Applies KISS, YAGNI, and SOLID principles for clean code with reduced complexity. Use when refactoring or reviewing code for over-engineering.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.