Generalize From Instance
Use this skill to extract a reusable contract from a working private case without
preserving the private case as the owner of the behavior. The goal is a general
implementation that still passes the original case as one regression example.
Core Rule
Treat the private case as evidence, not as the model.
The accepted output must name the general entity types, their input contracts,
their ownership boundary, and the verification gate. It must not depend on
fixture names, file paths, coordinates, result magnitudes, mesh ids, material ids,
or UI labels that only make sense for one sample.
Workflow
Capture the private anchors.
List the concrete names, paths, coordinates, ids, labels, result values, or
visual features that currently make the work specific. Quote file and line
references when code or docs already contain the private 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.
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.
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, 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 an added body, port, terminal, material, mode,
field, column, or result convention without another branch?
- Are hidden defaults safe when the private case omits a field, or should the
code fail with a concrete diagnostic?
If any answer exposes a private assumption, fix the contract rather than adding
a compatibility 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 original fixture behavior only through the general path.
- Fail fast on unknown roles or malformed general inputs; do not silently map an
unknown value 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, fixture-specific ids, hardcoded coordinates, or
path-based dispatch as a generalization substitute.
Output Artifact
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 when several anchors or mappings are involved.
Gate
The work passes only when:
- the original private case still works through the general path;
- no production logic depends on fixture paths, names, ids, coordinates, or
screenshot-only layout assumptions;
- 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.4---56# Generalize From Instance78Use this skill to extract a reusable contract from a working private case without9preserving the private case as the owner of the behavior. The goal is a general10implementation that still passes the original case as one regression example.1112## Core Rule1314Treat the private case as evidence, not as the model.1516The accepted output must name the general entity types, their input contracts,17their ownership boundary, and the verification gate. It must not depend on18fixture names, file paths, coordinates, result magnitudes, mesh ids, material ids,19or UI labels that only make sense for one sample.2021## Workflow22231. Capture the private anchors.24 List the concrete names, paths, coordinates, ids, labels, result values, or25 visual features that currently make the work specific. Quote file and line26 references when code or docs already contain the private assumption.27282. Classify each anchor.29 Mark every anchor as one of:30 - `contract`: a real input/output rule that must remain.31 - `example`: a valid sample that belongs in docs, tests, or fixtures only.32 - `accident`: a leaked assumption that must be removed.33 - `unknown`: a claim that needs inspection before editing.34353. Derive the general entities.36 Replace private nouns with owner-owned categories. Prefer categories that come37 from parsed input schemas, runtime metadata, typed records, cell arrays,38 boundary tags, roles, or explicit config.39404. Move behavior to the owner.41 Implement the general rule in the module that owns the data contract. Do not42 add consumer-side patches that special-case the original fixture.43445. Preserve the private case as a regression.45 Keep the original case in examples or tests only. If possible, add one46 synthetic or alternate case that proves the code is not tied to the original47 names, ids, coordinate axis, count, or ordering.48496. Document the general contract.50 Say what input fields drive the behavior, what output is produced, what is51 intentionally example-only, and how the verification proves generality.5253## Generality Checks5455Before editing, ask:5657- Does the rule depend on a fixture path, file basename, geometry name, or case58 nickname?59- Does it infer semantics from coordinates, ordering, counts, colors, result60 magnitudes, or current screenshot layout when an explicit input field exists?61- Does a function, type, option, test, or heading use a private noun where a62 typed entity name would be clearer?63- Would the same code handle an added body, port, terminal, material, mode,64 field, column, or result convention without another branch?65- Are hidden defaults safe when the private case omits a field, or should the66 code fail with a concrete diagnostic?6768If any answer exposes a private assumption, fix the contract rather than adding69a compatibility branch.7071## Implementation Rules7273- Prefer schema-driven parsing, typed records, metadata arrays, and declared74 roles over string matching against private names.75- Keep examples and validation fixtures named after their physical case, but keep76 production functions and UI groups named after general entities.77- Preserve original fixture behavior only through the general path.78- Fail fast on unknown roles or malformed general inputs; do not silently map an79 unknown value to the private case's default.80- Keep the diff at the owning boundary. If generalization requires a broader81 interface, state the verified reason before expanding scope.82- Do not use empirical scaling, fixture-specific ids, hardcoded coordinates, or83 path-based dispatch as a generalization substitute.8485## Output Artifact8687Return one compact implementation note with:8889- private anchors found;90- classification table for `contract`, `example`, `accident`, and `unknown`;91- general entity contract;92- files changed and ownership boundary;93- verification commands and evidence;94- residual assumptions, each labelled `ASSUMPTION (UNVERIFIED)` if not checked.9596Use a Markdown table when several anchors or mappings are involved.9798## Gate99100The work passes only when:101102- the original private case still works through the general path;103- no production logic depends on fixture paths, names, ids, coordinates, or104 screenshot-only layout assumptions;105- docs separate general rules from examples;106- tests or smoke checks exercise the original case and at least one107 non-private variation when practical;108- completion claims cite fresh verification evidence.109110## Terms and Abbreviations111112- `contract`: the stable input/output rule owned by a module or interface.113- `fixture`: a concrete sample case used for tests, examples, or validation.114- `general path`: implementation driven by typed input or metadata rather than a115 private case.116- `owner`: the module or boundary responsible for the behavior and its117 invariants.118- `private anchor`: a name, coordinate, id, path, label, or result value that119 ties behavior to one specific case.