principle-subtract-before-you-add
WHEN about to add a mechanism, owner, queue, validator or abstraction; NOT deletion by appearance or a hard-to-trace path with no addition planned; removes proven redundancy first and judges the whole system.
- License 许可
- MIT
- 所属仓库
- mintuz/skills
- 最近更新
- 2026-11-13
- Stars
- ★ 35
- Forks
- 7
01 前言 Front Matter
- name
- principle-subtract-before-you-add
- description
- WHEN about to add a mechanism, owner, queue, validator or abstraction; NOT deletion by appearance or a hard-to-trace path with no addition planned; removes proven redundancy first and judges the whole system.
02 资源文件 36
- 参考文档AGENTS.md45.7 KB
- 参考文档metadata.json818 B
- 参考文档README.md3.2 KB
- 参考文档rules/_contributing.md4.0 KB
- 参考文档rules/_sections.md1.6 KB
- 参考文档rules/_template.md1.0 KB
- 参考文档rules/advanced-full-text-search.md1.4 KB
- 参考文档rules/advanced-jsonb-indexing.md1.4 KB
- 参考文档rules/conn-idle-timeout.md1.3 KB
- 参考文档rules/conn-limits.md1.4 KB
- 参考文档rules/conn-pooling.md1.3 KB
- 参考文档rules/conn-prepared-statements.md1.6 KB
- 参考文档rules/data-batch-inserts.md1.3 KB
- 参考文档rules/data-n-plus-one.md1.3 KB
- 参考文档rules/data-pagination.md1.4 KB
- 参考文档rules/data-upsert.md1.4 KB
- 参考文档rules/lock-advisory.md1.5 KB
- 参考文档rules/lock-deadlock-prevention.md1.9 KB
- 参考文档rules/lock-short-transactions.md1.4 KB
- 参考文档rules/lock-skip-locked.md1.3 KB
- 参考文档rules/monitor-explain-analyze.md1.5 KB
- 参考文档rules/monitor-pg-stat-statements.md1.4 KB
- 参考文档rules/monitor-vacuum-analyze.md1.5 KB
- 参考文档rules/query-composite-indexes.md1.4 KB
- 参考文档rules/query-covering-indexes.md1.3 KB
- 参考文档rules/query-index-types.md1.4 KB
- 参考文档rules/query-missing-indexes.md1.2 KB
- 参考文档rules/query-partial-indexes.md1.3 KB
- 参考文档rules/schema-data-types.md1.4 KB
- 参考文档rules/schema-foreign-key-indexes.md1.6 KB
- 参考文档rules/schema-lowercase-identifiers.md1.7 KB
- 参考文档rules/schema-partitioning.md1.5 KB
- 参考文档rules/schema-primary-keys.md1.8 KB
- 参考文档rules/security-privileges.md1.6 KB
- 参考文档rules/security-rls-basics.md1.8 KB
- 参考文档rules/security-rls-performance.md1.7 KB
03 SKILL.md 正文
Subtract Before You Add
Before adding a mechanism, owner or layer, remove proven redundancy and judge the whole system.
- Identify the behaviour and guarantees the change must preserve. Before adding another owner, queue, validator or abstraction, check whether deletion, a direct change or an existing mechanism meets the requirement (
principle-reuse-before-building). - Remove demonstrated dead paths, duplicated rules and content-free references within scope; repair their maintained callers and links. Sequence independent safe subtraction before construction. Keep removal coupled to replacement when separating them would break the contract. Avoid unrelated cleanup.
- Two similar guards may protect different boundaries or mutations. Prove redundancy before deleting either; preserve failure behaviour and its tests. Prefer observed requirements over speculative layers and scaffolding.
- Choose the smallest coherent change that meets the contract. More lines can be less work than a short patch that drops cancellation, errors or compatibility. Judge the complete system, including shifted complexity, rather than celebrating fewer local lines.
- Verify the affected public behaviour and references after each coherent change. Stop when the accepted outcome is met on the simpler base.
Distinct from: principle-reuse-before-building (about to write a helper, owner, script or component: search for an existing option), principle-minimize-reader-load (an existing path is hard to trace, with no addition planned), principle-foundational-thinking (adding infrastructure or abstraction "for later").
Done: the addition is still needed after removal, and no complexity has merely moved.
04 同仓库更多 Skills
xstate
WHEN React state changes in response to an external answer — async submit, in-flight or loading flags, retries, cancellation, polling, optimistic updates, stale responses — or to an interaction with an interruptible middle, such as a drag or a gesture; or WHEN building, reviewing, testing, or visualising XState 5 actors and @xstate/react integrations; NOT for a value one event sets completely, such as a text draft, a focus flag, or a plain open and closed toggle; models typed lifecycles and renders legal Mermaid stateDiagram-v2 charts.
web-design
WHEN refining UI layout, typography, color, or polish; NOT code implementation; provides concise principles for intentional, legible design.
tailwind
USE WHEN writing, fixing or reviewing styling in a project that uses Tailwind CSS, even a one-class change or a request that does not name Tailwind: colours, focus rings, spacing, class names chosen by a prop, map or CVA variants, theme tokens and dark mode in the Tailwind stylesheet or tailwind.config, setup or upgrades (if unsure whether the project uses Tailwind, check package.json or the main stylesheet first); NOT WHEN writing plain CSS or Sass in a project without Tailwind; produces class names Tailwind can find, syntax for the installed major version, visible focus indicators, and no unrequested dependency or invented brand value.
refactoring
WHEN you need a plan to refactor, restructure, or clean up working code and the test result is known, either green or a recorded failing set; NOT for new feature delivery or any behavior change; reversible-baseline safety with prioritized improvements.
react
USE WHEN changing the logic, data, props, state, Effects or rendered text of a React component, hook or page, even a one-line change; NOT WHEN the request is styling only (class names, Tailwind, CSS, dark mode, spacing, shadows) or tests only, or when it models submit, in-flight, loading, retry or failure states, even for a named React form (xstate covers that, including its React wiring); applies React 19 composition, state, Effect, structure, API and performance rules with only the project's installed libraries.
react-testing
USE WHEN writing, fixing or reviewing a React Testing Library test for a component, hook or context provider, even one small test, or when asked for an end-to-end journey inside a Vitest or React Testing Library suite; NOT WHEN changing the component itself (react), testing XState actors or @xstate/react (xstate), or writing a Playwright or Cypress test; covers renderHook, providers, async results, forms and false-pass anti-patterns, and declines end-to-end journeys with the testable slices.