Generalize From Instance
Use this skill to extract a reusable contract from a working private case without
preserving that case as the owner of the behavior. A general implementation
handles valid instances and accepted variation through the correct owner; it does
not erase legitimate concrete contracts or predict hypothetical variants.
Core Rule
Treat the private case as evidence, not as the model.
Generality, extensibility, low coupling, cohesion, simplicity, and efficiency are
one architecture tradeoff. Keep each needed change local to the correct owner;
use the smallest stable seam justified by an accepted requirement, an accepted
declared future direction, or evidenced domain variability. A current second
consumer is useful evidence, not a prerequisite. Do not add speculative
frameworks, duplicate decisions, or cascade edits across unrelated modules.
Preserve correctness, required performance, user constraints, and external
contracts.
Concrete does not mean private. Schema-defined identifiers, protocol paths,
coordinate systems, domain constants, user-selected labels, and supported API
shapes may be legitimate contracts. Classify them before changing them.
Workflow
Apply the workflow proportionally. A single-anchor documentation or test-name
correction needs only a concise classification, owner, and check; multiple
anchors or behavior and contract changes need the fuller mapping below.
Capture the private anchors.
List the concrete names, paths, coordinates, ids, labels, result values, or
visual features suspected of making the work specific. Quote file and line
references when code or docs contain the assumption.
Classify each anchor.
Mark every anchor as one of:
contract: a real input/output rule that must remain.
example: a valid sample that belongs in docs, tests, or fixtures only.
accident: a leaked assumption that must be removed.
unknown: a claim that needs inspection before editing.
Derive the general entities.
Replace private nouns with owner-owned categories. Prefer categories that come
from parsed input schemas, runtime metadata, typed records, cell arrays,
boundary tags, roles, or explicit config. Generalize over valid instances,
accepted future directions, and evidenced domain variability, not imagined
semantic variants.
Move behavior to the owner.
Implement the general rule in the module that owns the data contract. Do not
add consumer-side patches that special-case the original fixture or repeat the
same decision across callers.
Preserve the private case as a regression.
Keep the original case in examples or tests only. If possible, add one
synthetic or alternate case that proves the code is not tied to the original
names, ids, coordinate axis, count, or ordering.
Document the general contract.
Say what input fields drive the behavior, what output is produced, what is
intentionally example-only, which compatibility behavior remains, and how the
verification proves generality.
Generality Checks
Before editing, ask:
- Does the rule depend on a fixture path, file basename, geometry name, or case
nickname?
- Does it infer semantics from coordinates, ordering, counts, colors, result
magnitudes, or current screenshot layout when an explicit input field exists?
- Does a function, type, option, test, or heading use a private noun where a
typed entity name would be clearer?
- Would the same code handle other valid instances and accepted or evidenced
variation within its declared contract without a fixture-specific branch? A
genuinely new semantic behavior may require new owner-level dispatch and does
not prove that the prior implementation was instance-specific.
- Are hidden defaults safe when the private case omits a field, or should the
code fail with a concrete diagnostic?
- Did the change add an abstraction, plugin system, duplicated decision, or
multi-module cascade without evidence that the owning contract needs it?
If an answer exposes a private assumption, correct it at the owning boundary.
Preserve authorized external contracts; when compatibility is required, keep it
in one owner-owned adapter or migration path rather than a fixture-specific
consumer branch.
Implementation Rules
- Prefer schema-driven parsing, typed records, metadata arrays, and declared
roles over string matching against private names.
- Keep examples and validation fixtures named after their physical case, but keep
production functions and UI groups named after general entities.
- Preserve supported behavior through the general path or its owner-owned
compatibility boundary.
- Follow the owning contract's unknown-value policy. Reject an unknown value only
when required semantic interpretation cannot be performed under that contract;
otherwise explicitly preserve, ignore, or round-trip it as the contract allows.
Never map an unknown value silently to the private case's default.
- Keep the diff at the owning boundary. If generalization requires a broader
interface, state the verified reason before expanding scope.
- Do not use empirical scaling or example-only ids, coordinates, or path dispatch
to imitate the original result. A concrete value remains valid when the owning
schema, protocol, domain model, or user contract defines it.
Output Artifact
Return only the detail the change needs. For a single-anchor documentation, test,
or naming correction, a short result naming its classification, owner, and check
is sufficient. For multiple anchors or behavior and contract changes, return one
compact implementation note with:
- private anchors found;
- classification table for
contract, example, accident, and unknown;
- general entity contract;
- files changed and ownership boundary;
- verification commands and evidence;
- residual assumptions, each labelled
ASSUMPTION (UNVERIFIED) if not checked.
Use a Markdown table only when several anchors or mappings are involved. Do not
create a new artifact, abstraction, or gate unless the task contract requires it.
Gate
The work passes only when:
- the original private case still works through the general path or a required
owner-owned compatibility boundary;
- no production logic depends on example-only or accidental anchors; each
remaining concrete path, name, id, coordinate, label, or layout rule is a
verified contract owned at the correct boundary;
- accepted future directions or evidenced domain variation stay local to the
owning implementation or stable seam without speculative mechanisms;
- required correctness, performance, user constraints, and external contracts
remain preserved, or an authorized migration is explicit;
- docs separate general rules from examples;
- tests or smoke checks exercise the original case and at least one
non-private variation when practical;
- completion claims cite fresh verification evidence.
Terms and Abbreviations
contract: the stable input/output rule owned by a module or interface.
fixture: a concrete sample case used for tests, examples, or validation.
general path: implementation driven by typed input or metadata rather than a
private case.
owner: the module or boundary responsible for the behavior and its
invariants.
private anchor: a name, coordinate, id, path, label, or result value that
ties behavior to one specific case.
1---2name: generalize-from-instance3description: Use when Codex must turn fixture-specific, geometry-specific, dataset-specific, user-case-specific, or one-off code/docs/tests/UI logic into a general implementation contract. Trigger on requests such as "make it general", "not for this geometry", "remove hardcoding", "general logic", "do not map to this case", or when a private validation case is leaking into production behavior, documentation, naming, tests, or UI.4metadata:5 source: https://skillmd.com/skills/applicate2628/generalize-from-instance6---78# Generalize From Instance910Use this skill to extract a reusable contract from a working private case without11preserving that case as the owner of the behavior. A general implementation12handles valid instances and accepted variation through the correct owner; it does13not erase legitimate concrete contracts or predict hypothetical variants.1415## Core Rule1617Treat the private case as evidence, not as the model.1819Generality, extensibility, low coupling, cohesion, simplicity, and efficiency are20one architecture tradeoff. Keep each needed change local to the correct owner;21use the smallest stable seam justified by an accepted requirement, an accepted22declared future direction, or evidenced domain variability. A current second23consumer is useful evidence, not a prerequisite. Do not add speculative24frameworks, duplicate decisions, or cascade edits across unrelated modules.25Preserve correctness, required performance, user constraints, and external26contracts.2728Concrete does not mean private. Schema-defined identifiers, protocol paths,29coordinate systems, domain constants, user-selected labels, and supported API30shapes may be legitimate contracts. Classify them before changing them.3132## Workflow3334Apply the workflow proportionally. A single-anchor documentation or test-name35correction needs only a concise classification, owner, and check; multiple36anchors or behavior and contract changes need the fuller mapping below.37381. Capture the private anchors.39 List the concrete names, paths, coordinates, ids, labels, result values, or40 visual features suspected of making the work specific. Quote file and line41 references when code or docs contain the assumption.42432. Classify each anchor.44 Mark every anchor as one of:45 - `contract`: a real input/output rule that must remain.46 - `example`: a valid sample that belongs in docs, tests, or fixtures only.47 - `accident`: a leaked assumption that must be removed.48 - `unknown`: a claim that needs inspection before editing.49503. Derive the general entities.51 Replace private nouns with owner-owned categories. Prefer categories that come52 from parsed input schemas, runtime metadata, typed records, cell arrays,53 boundary tags, roles, or explicit config. Generalize over valid instances,54 accepted future directions, and evidenced domain variability, not imagined55 semantic variants.56574. Move behavior to the owner.58 Implement the general rule in the module that owns the data contract. Do not59 add consumer-side patches that special-case the original fixture or repeat the60 same decision across callers.61625. Preserve the private case as a regression.63 Keep the original case in examples or tests only. If possible, add one64 synthetic or alternate case that proves the code is not tied to the original65 names, ids, coordinate axis, count, or ordering.66676. Document the general contract.68 Say what input fields drive the behavior, what output is produced, what is69 intentionally example-only, which compatibility behavior remains, and how the70 verification proves generality.7172## Generality Checks7374Before editing, ask:7576- Does the rule depend on a fixture path, file basename, geometry name, or case77 nickname?78- Does it infer semantics from coordinates, ordering, counts, colors, result79 magnitudes, or current screenshot layout when an explicit input field exists?80- Does a function, type, option, test, or heading use a private noun where a81 typed entity name would be clearer?82- Would the same code handle other valid instances and accepted or evidenced83 variation within its declared contract without a fixture-specific branch? A84 genuinely new semantic behavior may require new owner-level dispatch and does85 not prove that the prior implementation was instance-specific.86- Are hidden defaults safe when the private case omits a field, or should the87 code fail with a concrete diagnostic?88- Did the change add an abstraction, plugin system, duplicated decision, or89 multi-module cascade without evidence that the owning contract needs it?9091If an answer exposes a private assumption, correct it at the owning boundary.92Preserve authorized external contracts; when compatibility is required, keep it93in one owner-owned adapter or migration path rather than a fixture-specific94consumer branch.9596## Implementation Rules9798- Prefer schema-driven parsing, typed records, metadata arrays, and declared99 roles over string matching against private names.100- Keep examples and validation fixtures named after their physical case, but keep101 production functions and UI groups named after general entities.102- Preserve supported behavior through the general path or its owner-owned103 compatibility boundary.104- Follow the owning contract's unknown-value policy. Reject an unknown value only105 when required semantic interpretation cannot be performed under that contract;106 otherwise explicitly preserve, ignore, or round-trip it as the contract allows.107 Never map an unknown value silently to the private case's default.108- Keep the diff at the owning boundary. If generalization requires a broader109 interface, state the verified reason before expanding scope.110- Do not use empirical scaling or example-only ids, coordinates, or path dispatch111 to imitate the original result. A concrete value remains valid when the owning112 schema, protocol, domain model, or user contract defines it.113114## Output Artifact115116Return only the detail the change needs. For a single-anchor documentation, test,117or naming correction, a short result naming its classification, owner, and check118is sufficient. For multiple anchors or behavior and contract changes, return one119compact implementation note with:120121- private anchors found;122- classification table for `contract`, `example`, `accident`, and `unknown`;123- general entity contract;124- files changed and ownership boundary;125- verification commands and evidence;126- residual assumptions, each labelled `ASSUMPTION (UNVERIFIED)` if not checked.127128Use a Markdown table only when several anchors or mappings are involved. Do not129create a new artifact, abstraction, or gate unless the task contract requires it.130131## Gate132133The work passes only when:134135- the original private case still works through the general path or a required136 owner-owned compatibility boundary;137- no production logic depends on example-only or accidental anchors; each138 remaining concrete path, name, id, coordinate, label, or layout rule is a139 verified contract owned at the correct boundary;140- accepted future directions or evidenced domain variation stay local to the141 owning implementation or stable seam without speculative mechanisms;142- required correctness, performance, user constraints, and external contracts143 remain preserved, or an authorized migration is explicit;144- docs separate general rules from examples;145- tests or smoke checks exercise the original case and at least one146 non-private variation when practical;147- completion claims cite fresh verification evidence.148149## Terms and Abbreviations150151- `contract`: the stable input/output rule owned by a module or interface.152- `fixture`: a concrete sample case used for tests, examples, or validation.153- `general path`: implementation driven by typed input or metadata rather than a154 private case.155- `owner`: the module or boundary responsible for the behavior and its156 invariants.157- `private anchor`: a name, coordinate, id, path, label, or result value that158 ties behavior to one specific case.