一键导入
structure
Design data structures before implementation. Maps existing code or creates new types.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Design data structures before implementation. Maps existing code or creates new types.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Audit a project against a canon's rules and checklist. Read-only — produces prioritized report without fixing. Works with any canon (nextjs, sql, typescript, etc.).
Lens home base - status, help, and setup
Plan and build a new feature with quality gates.
Simple changes done right. Make the change, clean up after yourself, report what happened.
Review against canons + quality gate, fix findings, verify. Claude-native — no external models.
Plan and improve existing code with quality gates.
| name | structure |
| description | Design data structures before implementation. Maps existing code or creates new types. |
Design data structures and architecture. Context-aware: maps existing code or creates new types from plan.
No arguments? Describe this skill and stop. Do not execute.
mkdir -p .claude && echo '{"skill":"structure","started":"'$(date -Iseconds)'"}' > .claude/active-workflow.json
if path points to existing code:
MODE = "map" → Analyze and redesign
else if .claude/plans/ has active plan:
MODE = "create" → Create types from plan
else:
ERROR: Need either existing code path or plan
Before starting either mode, read these canon skills and apply their principles throughout:
Always load (base brain — all 10):
canon/clarity/SUMMARY.mdcanon/pragmatism/SUMMARY.mdcanon/simplicity/SUMMARY.mdcanon/composition/SUMMARY.mdcanon/distributed/SUMMARY.mdcanon/data-first/SUMMARY.mdcanon/correctness/SUMMARY.mdcanon/algorithms/SUMMARY.mdcanon/abstraction/SUMMARY.mdcanon/optimization/SUMMARY.mdAuto-detect domain canon (check files, load matches):
| Check | If found, also read |
|---|---|
*.ts or *.js files in target | canon/javascript/typescript/SUMMARY.md, canon/javascript/js-safety/SUMMARY.md, canon/javascript/js-perf/SUMMARY.md, canon/javascript/js-internals/SUMMARY.md, canon/javascript/functional/SUMMARY.md |
angular.json in project root | canon/angular/angular-arch/SUMMARY.md, canon/angular/angular-core/SUMMARY.md, canon/angular/angular-perf/SUMMARY.md, canon/angular/rxjs/SUMMARY.md |
package.json contains "react" | canon/javascript/react-state/SUMMARY.md, canon/javascript/react-test/SUMMARY.md, canon/javascript/reactivity/SUMMARY.md |
pom.xml or build.gradle in project | canon/java/SUMMARY.md |
*.py files in target | canon/python/python-advanced/SUMMARY.md, canon/python/python-idioms/SUMMARY.md, canon/python/python-patterns/SUMMARY.md, canon/python/python-protocols/SUMMARY.md |
*.cs files or *.csproj in project | canon/csharp/csharp-depth/SUMMARY.md, canon/csharp/type-systems/SUMMARY.md, canon/csharp/async/SUMMARY.md |
.tsx, .jsx, or HTML template files | canon/ui-ux/components/SUMMARY.md, canon/ui-ux/usability/SUMMARY.md, canon/ui-ux/tokens/SUMMARY.md |
d3 in package.json or imports | canon/visualization/d3/SUMMARY.md, canon/visualization/charts/SUMMARY.md, canon/visualization/dashboards/SUMMARY.md |
| SQL files or ORM imports | canon/database/sql/SUMMARY.md, canon/database/sql-perf/SUMMARY.md |
| Auth, tokens, secrets, encryption | canon/security/security-mindset/SUMMARY.md, canon/security/owasp/SUMMARY.md, canon/security/web-security/SUMMARY.md |
If a skill file doesn't exist (not installed in this project), skip it and continue. List loaded experts in EXPERTS_LOADED. In EXPERT_DECISIONS, show each specific structural decision an expert drove.
Read canon/pitfalls/SKILL.md if it exists. Apply its patterns as you work:
If the file doesn't exist, skip it and continue.
Read .claude/rubric/contracts.md. This defines 7 abstract types for boundary enforcement. Use them during boundary analysis in both modes.
Analyze existing code, diagram relationships, design improvements.
Read all files in target. Output a diagram:
## Architecture: [target]
CURRENT_STATE:
┌─────────────┐ ┌─────────────┐
│ UserService │────▶│ AuthStore │
│ │ │ │
│ - getUser() │ │ - token │
│ - saveUser()│ │ - validate()│
└──────┬──────┘ └──────┬──────┘
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ User │ │ Session │
│ (interface) │ │ (interface) │
└─────────────┘ └─────────────┘
DEPENDENCIES:
- UserService → AuthStore (tight coupling)
- UserService → User (data)
- AuthStore → Session (data)
ISSUES_FOUND:
- [issue]: [why it matters]
PURITY_CHECK:
- [module]: pure ✓ | impure ✗ (calls [I/O function] directly)
For each impure module: can business logic be extracted into pure functions
that take data and return data, with I/O pushed to callers?
Review against principles from the masters:
| Principle | Check |
|---|---|
| Data-first | Are data structures driving the design? |
| Composition | Inheritance depth > 2? Refactor to composition. |
| Single responsibility | Does each class do one thing? |
| Interface segregation | Are interfaces minimal? |
| Dependency inversion | Depend on abstractions, not concretions? |
| Pure core / impure shell | Is business logic free of I/O? Core functions should take data and return data — no direct calls to filesystem, network, or database. I/O belongs in a thin outer layer that calls the pure core. If a function both computes and persists, split it. |
| Impossible states | Can invalid states be represented? |
| Quality contracts | Are boundaries enforced with validated types, or do raw strings pass through? |
TARGET_STATE:
┌─────────────┐ ┌─────────────┐
│ UserService │ │ AuthService │
│ │ │ (new) │
└──────┬──────┘ └──────┬──────┘
│ │
▼ ▼
┌─────────────────────────────────┐
│ UserRepository │
│ (extracted) │
└─────────────────────────────────┘
CHANGES_NEEDED:
- Extract AuthService from AuthStore
- Create UserRepository interface
- Inject dependencies via constructor
EXPERTS_LOADED: [list of skill names actually read]
EXPERT_DECISIONS:
- [expert-skill]: [specific structural decision it drove]
## Structure: [target]
MODE: map
CURRENT_STATE:
[diagram]
ISSUES_FOUND:
- [issue]: [description]
TARGET_STATE:
[diagram]
CHANGES_NEEDED:
- [change 1]
- [change 2]
QUALITY_CONTRACTS:
| Boundary | Abstract Type | Contract | Construction Check |
|----------|--------------|----------|--------------------|
| {boundary} | {type} | {what must be true} | {missing contract = issue} |
EXPERTS_LOADED: [list of skill names actually read]
EXPERT_DECISIONS:
- [expert-skill]: [specific decision it drove]
STRUCTURE_COMPLETE
Create actual type files from an approved plan.
Types must look like they were designed by a skilled human engineer:
Reject:
Partial<T> abuse creating unclear contractsEmbrace:
| Principle | Apply It |
|---|---|
| Minimal surface | Only essential methods/fields |
| Consistent naming | Same operation = same name everywhere |
| Orthogonal operations | Operations compose cleanly |
| Interface over implementation | Return List<T> not ArrayList<T> |
| Immutability by default | Prefer readonly. Mutation is explicit. |
| Pure core / impure shell | Business logic takes data, returns data. I/O is a separate layer. |
| Fail-fast | Validate at boundaries |
For each function/module being created, identify boundaries using the detection signals from .claude/rubric/contracts.md:
Output a QUALITY_CONTRACTS table in the structure output.
## Structure: [feature]
MODE: create
TYPES_CREATED:
- src/types/user.ts: User, UserPublic, CreateUserInput
- src/types/auth.ts: AuthToken, TokenPayload
INVARIANTS_DOCUMENTED:
- User: email must be unique, password_hash never exposed
- AuthToken: expires_at must be in future
QUALITY_CONTRACTS:
| Boundary | Abstract Type | Contract | Construction Check |
|----------|--------------|----------|--------------------|
| {where data enters/leaves} | {abstract type} | {what must be true} | {EXPORT_FUNCTION or EXPORT_TYPE to verify} |
EXPERTS_LOADED: [list of skill names actually read]
EXPERT_DECISIONS:
- [expert-skill]: [specific decision it drove]
STRUCTURE_COMPLETE
After completing structure analysis/creation:
/implementationYour turn ends here. Output STRUCTURE_COMPLETE and STOP.