extract-shared-types
Extract shared type definitions into a dedicated types directory without runtime behavior changes
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- extract-shared-types
- type
- execution
- version
- v0.1
- description
- Extract shared type definitions into a dedicated types directory without runtime behavior changes
- argument-hint
- [optional: package, app, directory, or domain to refactor]
- required_conventions
- [ "alignment-page" ]
02 资源文件 2
- 参考文档ALIGNMENT-PAGE.md51.3 KB
- 参考文档CHANGELOG.md311 B
03 SKILL.md 正文
Extract Shared Types
Use this skill for type hoisting, type barreling, shared types/ directories, import honesty, and circular-dependency prevention when the requested change is explicitly structural and behavior-preserving.
Process
-
Establish scope.
- Read
$ARGUMENTSfor a package, app, directory, or domain. - If no scope is provided, inspect the repo and choose the smallest coherent area with shared exported types.
- Read project instructions, package manifests, TypeScript config, path aliases, lint rules, package export maps, and existing
types/or barrel conventions.
- Read
-
Classify declarations before editing.
- Candidate moves: exported
typealiases,interfacedeclarations, ambient declarations, generic helper shapes, DTO/result shapes, props/state shapes, and domain data shapes. - Do not move runtime values: functions, constants, classes, runtime enums, schemas, validators, database/API clients, React components, business logic, or anything imported as a value.
- Treat TypeScript
enumas runtime unless the project already usesconst enumsafely and the compiler settings make the move clearly type-only.
- Candidate moves: exported
-
Design the target type layout.
- Create or reuse a dedicated
types/directory at the nearest appropriate boundary. - Organize files by domain, feature, or package convention rather than by source file name when a domain boundary is clear.
- Prefer direct imports from domain type files. Add
types/index.tsonly if the project already uses barrels or repeated type imports would otherwise become noisy.
- Create or reuse a dedicated
-
Move type declarations.
- Move only the approved type declarations.
- Preserve exported names, generic parameters, comments that explain shape semantics, and public visibility.
- Keep runtime implementation files focused on runtime logic, importing moved declarations with
import typewhere supported.
-
Update imports and compatibility.
- Update internal imports to the new type files.
- Use
import typefor type-only imports and avoid creating new value imports fromtypes/. - If old import paths are part of a public API or package boundary, leave type-only re-exports from the original module rather than forcing a breaking migration.
- Avoid widening public barrels unless the repo already exposes that type surface intentionally.
-
Verify behavior preservation.
- Run the narrowest relevant typecheck, tests, lint/import checks, and dependency-cycle checks available.
- Inspect the diff for runtime changes: implementation logic, emitted values, schema definitions, package exports, route behavior, and component behavior should not change.
- If verification fails, fix import/type issues without changing runtime behavior.
Output
When reporting completion, include:
- Scope refactored.
- Type files created or reused.
- Compatibility re-exports left in place, if any.
- Verification commands run and their results.
- Any skipped candidates with the reason they were runtime-coupled or public-API-sensitive.
Alignment Page
Follow the shared alignment-page convention via the packaged convention resolver; output path is alignment/extract-shared-types-{topic}.html.
Constraints
- Zero runtime behavior changes.
- Do not move declarations unless they are type-only.
- Do not introduce dependency upgrades, schema redesigns, or broad module restructuring.
- Do not remove public import paths unless the user explicitly requests a breaking change.
- Preserve unrelated user changes in the working tree.
Default Shipping Contract
Follow the shared shipping contract convention in CLAUDE.md.
04 同仓库更多 Skills
source-checkout-allowed
Valid source-checkout-only fixture.
deck-install-valid
Valid deck install fixture.
codex-pack-guard-valid
Valid Codex Pack Availability Guard fixture.
codex-missing-skill-valid
Valid Codex missing skill fallback fixture.
codex-base-skill-fallback-valid
Valid Codex base skill fallback fixture.
claude-pack-guard-valid
Valid Claude Pack Availability Guard fixture.