factor-of-safety
Use this skill whenever the design will encounter conditions that can't be fully predicted at design time — load spikes, edge-case content, real-world variability, hardware variation, third-party flakiness, or any "what if" scenario. Trigger when scoping performance budgets, designing for content extremes, picking infrastructure capacity, designing error-handling, or planning for the long tail of users with unusual setups. Factor of Safety is one of the foundational principles in 'Universal Principles of Design' (Lidwell, Holden, Butler 2003) — also called "factor of ignorance" because the size of the safety factor is proportional to how much you *don't* know.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-13
- Stars
- ★ 1.6k
- Forks
- 483
01 前言 Front Matter
- name
- factor-of-safety
- description
- Use this skill whenever the design will encounter conditions that can't be fully predicted at design time — load spikes, edge-case content, real-world variability, hardware variation, third-party flakiness, or any "what if" scenario. Trigger when scoping performance budgets, designing for content extremes, picking infrastructure capacity, designing error-handling, or planning for the long tail of users with unusual setups. Factor of Safety is one of the foundational principles in 'Universal Principles of Design' (Lidwell, Holden, Butler 2003) — also called "factor of ignorance" because the size of the safety factor is proportional to how much you *don't* know.
02 资源文件 1
03 SKILL.md 正文
Factor of Safety
Factor of Safety is the engineering practice of designing systems with capacity exceeding what's strictly required, to absorb unknown variations and prevent failure. A bridge rated for 5,000 lbs is built to hold 25,000 — a safety factor of 5. The "extra" capacity isn't waste; it's insurance against the things you didn't predict: corrosion, fatigue, unusual load combinations, materials that didn't quite meet spec.
For software design, the same logic applies: design with margin in performance, capacity, content handling, error tolerance, and edge cases. The unpredicted always shows up; the question is whether the system absorbs it gracefully or fails loudly.
Definition (in our own words)
A factor of safety is the ratio of a system's actual capacity to the capacity it was designed to handle under normal use. The size of the factor depends on how much you don't know about the conditions the system will face — the more uncertainty, the larger the factor needs to be. The book's alternative name, "factor of ignorance," is illuminating: a well-understood, well-tested system can have a small safety factor; a novel system facing unknown conditions needs a large one.
Origins and research lineage
- Engineering safety practice going back centuries. The Pyramids of Giza, by some analyses, were over-engineered with safety factors of 20+ — the builders couldn't predict load conditions over millennia, so they built radically conservatively.
- Henry Petroski, To Engineer Is Human: The Role of Failure in Successful Design (St. Martin's Press, 1985) and Design Paradigms: Case Histories of Error and Judgment in Engineering (Cambridge University Press, 1994). Petroski's central thesis: engineering progresses by understanding past failures, and safety factors are the explicit acknowledgment that the next failure will look like something not yet seen.
- Lidwell, Holden & Butler (2003) compactly stated the principle and noted the inverse relationship between safety-factor size and design knowledge. The book's central case: the Challenger O-rings, designed for a safety factor of 3 in past launches but well below 3 at low temperatures.
- Modern reliability engineering (Jens Rasmussen, Charles Perrow's Normal Accidents, James Reason's work on system failure) extends the idea to complex systems where multiple small margins compound into total system safety.
- Software practice — capacity planning, redundancy, error budgets (Google SRE), graceful degradation — all are factor-of-safety in software vocabulary.
Why factor of safety matters
Every system designed at exactly its expected load will fail when it encounters more. Real systems always encounter more — through use you didn't predict, through growth, through abuse, through the long tail of edge cases. A system without margin fails loudly when conditions change; a system with margin absorbs the change gracefully and continues operating.
The cost of insufficient margin is well-documented:
- Performance: a system sized for 1,000 users that hits 1,500 users degrades or crashes.
- Content: a layout sized for 50-character names breaks when a user has a 90-character name.
- Network: an API designed assuming 99.9% uptime fails when its dependency drops to 98%.
- Hardware: a UI designed for 1080p screens looks broken on 4K and on small mobile.
- Cognitive: a tool designed for the typical user fails for the user with motor impairment, low vision, or unfamiliarity.
The cost of too much margin is real too — over-engineering wastes resources, slows development, and can make systems harder to maintain. The discipline is calibrating margin to the actual uncertainty.
When to apply
- Performance and capacity planning. Systems should run at meaningful headroom over typical load.
- Content handling. Layouts must survive content that exceeds typical bounds — long names, big numbers, multi-line addresses, no images.
- Error tolerance. Systems should fail gracefully on unexpected input rather than crashing.
- Network and dependency reliability. Systems should degrade gracefully when dependencies are slow or down.
- Hardware variation. UIs should work across device sizes, pixel densities, and input modalities.
- Accessibility. Designs should accommodate users at the edges of typical capability ranges.
- Anywhere "we've never seen that before" is plausible.
When NOT to over-apply
- Premature optimization. Building 100x capacity when current load is 1x ties up resources better spent on other priorities.
- Speculative redundancy. Multiple redundant systems for failure modes that have never occurred and aren't credible.
- Defensive code obscuring intent. Wrapping every operation in try/catch with no error-handling strategy. Doesn't help; obscures.
The right margin is enough to handle the credible unknown — not infinite.
How to size the safety factor
The book's insight: the safety factor should track the level of ignorance about the design parameters.
- Well-understood, well-tested system: safety factor of 1.5–2x typical load.
- Moderately understood, some unknowns: 2–4x.
- Novel system, significant unknowns: 4–10x or more.
- Catastrophic-failure systems with severe consequence: even higher.
Typical safety factors in different engineering domains:
- Steel structures: 2–3x.
- Wood structures: 4–6x (more variable material).
- Aircraft: 1.5x (highly engineered, weight-constrained — but with extensive other safety mechanisms).
- Software capacity: highly variable, often 2–5x of expected peak load.
- UI content: typically design for 1.5–2x the typical content length.
Worked examples
Example 1: layout that survives content extremes
A user-card layout designed only for short names breaks for the user named "María-José Esperanza Sánchez de Bermúdez."
/* Without margin */
.user-name {
width: 200px;
white-space: nowrap;
overflow: hidden;
}
/* Long names disappear into ellipsis silently */
/* With margin */
.user-name {
max-width: 100%;
overflow-wrap: break-word;
hyphens: auto;
}
.user-card {
min-height: 80px; /* accommodates 1-3 lines */
}
The "with margin" version handles names from 5 to 90 characters; the layout grows gracefully.
Example 2: API capacity planning
An API expected to handle 100 requests/second is designed with capacity for 500 rps. Reasoning:
- Marketing campaigns, viral growth, or app launches can spike traffic 5–10x.
- Slow database queries can multiply effective load.
- One client misbehaving can saturate the API for everyone.
The 5x margin handles common spikes; auto-scaling handles sustained growth beyond.
Example 3: graceful degradation when a dependency fails
async function fetchUserData(userId) {
try {
return await api.fetchUser(userId, { timeout: 2000 });
} catch (error) {
// Graceful degradation: return cached data if available
const cached = await cache.get(`user:${userId}`);
if (cached) {
logger.warn('Using cached user data due to API failure', { userId, error });
return { ...cached, _stale: true };
}
// Last resort: return minimal data so UI can render something
return { id: userId, name: 'Unknown', _placeholder: true };
}
}
Three levels of margin: try the API; fall back to cache; fall back to placeholder. The UI never gets a hard crash from a transient failure.
Example 4: form input that handles edge cases
<input
type="email"
name="email"
maxlength="254" <!-- RFC 5321 maximum email length -->
autocomplete="email"
spellcheck="false"
inputmode="email"
/>
// Validate beyond max-length
function isValidEmail(value) {
if (!value || value.length > 254) return false;
if (!value.includes('@')) return false;
// ... more validation
return true;
}
The maxlength="254" is a margin: most emails are < 30 characters, but the RFC allows up to 254. Designing for 254 absorbs the long tail without breaking.
Example 5: error budgets (Google SRE)
Google's Site Reliability Engineering practice formalizes safety factors as "error budgets":
- Service-level objective (SLO): 99.9% availability.
- Error budget: 0.1% — about 43 minutes of downtime per month.
- Engineering teams can spend the budget on risk: faster releases, infrastructure changes, experimental features.
The error budget is an explicit margin against perfection — and explicit guidance about when to slow down (budget consumed) and when to take risks (budget remaining).
Cross-domain examples
Bridges and structures
Civil engineering's canonical safety-factor application. Bridges are designed for loads multiple times what they're rated to carry. Materials, weather, seismic events, and unanticipated use (heavy trucks, large crowds) are absorbed by the margin.
Aircraft
Aircraft use lower safety factors than buildings (1.5x rather than 5x) because weight matters and materials are highly engineered. The trade-off: extensive testing, redundant systems, and rigorous maintenance compensate for the slimmer margin.
Medical devices
Pharmaceutical dosing has built-in safety margins: the lethal dose of a drug is typically 10x or more of the therapeutic dose. The "ignorance" factor here is patient variation, drug interactions, and unusual conditions.
Disaster preparedness
FEMA recommends households maintain 3 days of supplies (food, water, medicine). The 3-day window is a safety factor against typical disaster duration; communities maintain larger margins for less-typical disasters.
The Challenger disaster (the book's case)
The space shuttle Challenger O-rings were designed with a safety factor of 3 — meaning they could handle 3x the expected stress. In past launches, the actual safety factor (under varying temperatures) had eroded toward 1. On the cold morning of January 28, 1986, the O-rings failed at a temperature where the safety factor was estimated below 1. The decision to launch despite engineering objections cost seven lives.
The case illustrates a common pattern: when systems perform reliably over time, confidence rises and pressure to reduce safety factors (cost, schedule) accumulates. Lowering safety factors based on past success ignores that the past success was partly because of the safety factors.
Anti-patterns
- Optimizing without margin. A system tuned to exactly its current load capacity. Any growth or spike crashes.
- Removing redundancy as "waste." Until the redundancy was needed, it looked unused. Then a single failure cascades.
- Designing for the typical case only. Edge cases are encountered routinely; designing only for typical means routinely failing.
- Confidence eroding safety factors over time. Systems that worked reliably get optimized for cost; the safety factor erodes; an unusual event causes failure.
- No graceful degradation. Systems that crash hard on dependency failure, instead of degrading to limited functionality.
- Content limits that match typical content. A name field allowing 30 characters works for most users; the user with a 35-character name has a broken account.
Heuristics
- The "what's the worst case?" audit. For each design decision, name the worst plausible case (longest content, highest load, lowest device capability). Does the design handle it?
- The "if this dependency fails" check. For each external dependency, ask: how does the system behave if this dependency fails? If the answer is "the user sees a broken page," add margin.
- The capacity headroom check. What's the system's actual capacity vs. current peak load? Less than 2x is fragile; 5x+ is comfortable.
- The "we've never seen that before" history. Look at past incidents. Each one was probably "unprecedented" before it happened. New unprecedented things will happen.
Related principles
weakest-link— safety factors strengthen the chain; finding the weakest link is the first step.scaling-fallacy— what works at small scale needs more margin at large scale.structural-forms— the engineering analog: load-bearing patterns that distribute stress.forgiveness— the user-side complement: designs that absorb user errors, not just system failures.iteration— iterative testing helps identify where margin is needed.uncertainty-principle— measurement itself introduces variability that the safety factor must absorb.
Sub-aspect skills
factor-of-safety-content-stress— designing UI to survive content extremes.factor-of-safety-failure-margin— capacity planning, graceful degradation, redundancy.
Closing
Factor of Safety is the engineering discipline that acknowledges what designers and builders try to forget: the unknown will arrive. Designs without margin fail loudly when it does; designs with margin absorb it. The cost of the margin is paid up front; the benefit pays out across the system's lifetime, especially in the moments no one anticipated.
04 同仓库更多 Skills
migrate-to-e2e
Moves an existing Playwright, Cypress, Selenium, Appium, Detox, Maestro, or TesterArmy suite to e2e one slice at a time, with the old suite running beside the new one until each ported test is proven. Keeps a MIGRATION.md progress file so any later session resumes where the last stopped. Optionally plants a defect to show both suites catch it. Use for /migrate-to-e2e, "migrate our tests to e2e", "port these Maestro flows", "move our TesterArmy tests", or when a project has an e2e config and an older suite still running.
e2e
Writes, runs, and debugs end-to-end tests for web and mobile apps with e2e, the agentic test runner, which mixes agent.act goals with exact locator assertions on a Playwright browser or an iOS or Android device. Also drives a project's running app live over the e2e MCP server to look at a screen, check a UI change, take a screenshot or record a video, and try a locator; and runs bug bashes, parallel e2e explore runs with each bug proven by a repro test. Use when a project depends on e2e or has an e2e.config.ts, when asked for end-to-end, browser, mobile, or agentic UI tests, to check a change in the running app, to QA or bug bash an app or branch, or when an e2e run fails.
create-verification-skill
Generate a project-local verify-<app> skill on top of e2e, so any coding agent can launch the app, check it is worth driving, exercise a feature the way a user does, keep evidence, and bug bash it. Writes the skill, a feature map with one explore charter per feature, and proves it once. Use for /create-verification-skill, "make a verification skill for this repo", or when a project has no scripted way to prove UI behavior.
deja-search
deja-vu memory — search the user's past AI coding sessions with the deja CLI. Holds what they already settled and never wrote into the repo (naming rules, banned or already-tried tools, required checks before merge, preferred values, who owns what). Use before your first edit in a task, before you call a change done or ready to merge, before you recommend a tool, library, design or reviewer, before re-debugging an error that may already be solved, when they say 'didn't we fix this before', 'what did we decide about X' or 'I already have that', and before telling them something on this machine does not exist.
deja-reflect
End-of-session reflection and memory curation with deja-vu. Review what was decided, what commands broke and what repaired them, and record durable project rules or decisions with deja remember so the next session starts with them.
revid
Make, edit, export and post AI videos with Revid (revid.ai) through the Revid MCP server. Use whenever the user wants a short-form or long-form video made (from an idea, a script, a URL, an article, a PDF, a tweet, a product page, their own clips, or a song), wants to find what is going viral on TikTok, YouTube, Instagram or X before making something, wants to edit or re-export an existing Revid project, generate a standalone AI image or clip, make a series episode, or publish and schedule a finished video to connected social accounts. Covers setup (hosted MCP with OAuth, or an API key), the 36 tools, credits, polling and the rules for publishing. Routes to the more specific revid-* skills when one fits.