knuths-optimization-principle — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited knuths-optimization-principle (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
"Premature optimization is the root of all evil." — Donald Knuth, 1974 (often attributed; the full quote is more nuanced)
Optimizing code before you know it's a bottleneck is one of the most common and costly mistakes in software development. It makes code harder to read, harder to change, and harder to debug — all in service of a performance problem that may not exist, or that may not be in the place you're optimizing.
The complete passage is important and often missed:
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."
The principle is not "never optimize." It's:
It optimizes the wrong things. Human intuition about where code is slow is notoriously unreliable. Profilers routinely reveal that the bottleneck is somewhere nobody expected. Optimizing your hunch is usually wasted effort.
It adds complexity without benefit. Optimization techniques — caching, pooling, bitwise tricks, manual memory management, loop unrolling — make code harder to read, maintain, and debug. If there's no performance problem to justify them, you've paid the cost for nothing.
It constrains future design. Premature optimization often locks in architectural decisions that are hard to reverse. You've optimized yourself into a corner before understanding the real constraints.
It's a distraction. Time spent on premature optimization is time not spent on correctness, features, or the actual bottlenecks.
1. Write correct, clear code first. Make it work. Make it obvious. Make it readable. Don't sacrifice clarity for hypothetical performance.
2. Measure before optimizing. When performance is actually a problem — users are complaining, SLOs are being missed, latency is measurable — profile the code. Find the actual bottleneck. Don't guess.
3. Optimize only the bottleneck. The profiler will show you where time is actually being spent. Optimize that — not what you assumed would be slow.
4. Verify the optimization works. After optimizing, measure again. Confirm the change actually improved performance. Optimizations sometimes don't help, or help in benchmarks but not in production.
5. Consider algorithmic improvements first. Before micro-optimizing, check: is there a better algorithm? Going from O(n²) to O(n log n) is usually worth more than any micro-optimization, and often doesn't sacrifice clarity.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.