/organize-project-structure
You are the orchestrator for repo-wide folder-structure redesign. Your
job is to infer the clearer mental model, adapt it to hard project
constraints, preserve source material, and arrive at a near-ideal target
topology plus an implementation approach. Use deterministic movement when
the move table and reference behavior are clear; otherwise separate what
can be automated from what needs human/LLM judgment.
Read _common/structural-design-principles.md before judging the target
tree. The floor is framework/tool correctness; above the floor, optimize
for skim, find, cluster, and stranger tests.
Core Contract
Separate design judgment from mechanical movement:
inventory -> folder value summaries -> repeated abstraction -> ideal topology
-> constraint overlay -> target topology -> implementation approach
-> optional move-path plan/dry-run -> decision -> apply/check if chosen
Do not hand-edit broad references when /move-path can resolve them.
Do not let an LLM do unstructured path rewrites. Do not apply a move plan
just because the skill can write one; applying is a decision after the
dry-run report and constraints are reviewed.
Classification Pass
Classify every top-level folder and major root file by lifecycle:
root-signpost — files a new reader should see first, usually
README.md, AGENT.md, or repo config.
doctrine-kb — source-grounded knowledge, summaries, claims,
process, schemas, synthesis.
idea-lifecycle — ideas before they become default routes, skills,
workbench features, or specs.
build-commitment — contracts, architecture decisions, product specs,
security decisions, acceptance criteria.
runtime — executable product/library code.
proof-machinery — fixtures, scorers, runners, experiments,
run-records, reports.
raw-source-material — datasets, imported source packages, logs,
extraction outputs, third-party or historical inputs.
tooling — scripts, tests, apps, CLIs, dashboards.
archive — preserved historical state that should not shape daily
navigation.
Top-level folders must earn their position by being a durable reader
navigation key. Historical names like inputs-1/, inputs-2/, and
outputs/ usually fail that test; preserve them under a source-material
or archive owner instead of deleting or flattening them.
For every confusing name, make the context decision explicit:
- Provenance label — keep the old name as a source identity, but move it
under a clearer owner such as
source-materials/input-bundles/.
- Operational label — rename it by default when the current name is
meaningless, chronology-based, or misleading. The move plan should prefer the
clearer name, not merely tuck the confusing name one level deeper.
- Compatibility label — keep it only when framework/tool contracts, public
paths, or explicit human preference require the old spelling.
Abstraction Ladder
Use summaries to climb from concrete contents to structural boundaries:
- Folder summaries. For each top-level folder and major subfolder,
summarize what work happens there, what value gets created, what
artifacts are produced or consumed, and what reader question the
folder answers. For code, sample entry points and public APIs; for
docs, sample headings and cross-links; for data, sample manifests or
READMEs before large payloads.
- Second-pass summary. Summarize the summaries. Look for repeated
ownership patterns, lifecycle phases, hidden parallel hierarchies,
source-vs-derived confusion, and names that describe history instead
of current purpose.
- Third-pass summary. Summarize the second pass into the smallest
useful set of navigation keys: e.g. doctrine, ideas, contracts,
runtime, proof machinery, raw source material, apps, tools, tests.
This is the ideal logical topology before constraints.
Use the discovered boundaries to decide folder-worth. A boundary is a
folder candidate when it has its own reader question, lifecycle,
artifact set, or change cadence. It is a strong folder candidate when
two or more of these are true:
- readers would naturally ask for it by name;
- edits inside it usually happen together and separately from neighbors;
- it owns a distinct value-producing workflow or artifact type;
- it has enough siblings/subparts that flat filenames would need a fake
prefix;
- its name is being used as a tag on multiple siblings instead of as a
container, e.g. several rename/move skills that naturally read as a
renaming/ cluster;
- it needs its own README/index to explain what belongs there and what
does not.
Pairs can stay flat when the boundary is weak. A small but distinct
boundary can still earn a folder when the navigation key is durable.
When possible, prefer colocating the cluster under a real folder over
sprinkling a shared tag through filenames or sibling names. Keep the tag
flat only when a framework, discovery mechanism, or strong reader
preference requires it.
Keep the intermediate summaries short enough to review. They are not
deliverables unless the user asks; they are the ladder that makes the
target topology explainable instead of vibes-based.
Constraint Overlay
After proposing the ideal logical topology, apply constraints before
solidifying the target topology:
- Framework/runtime conventions: Next.js
app/ or pages/, Python
package/import roots, Django app layout, build config discovery, test
runner discovery, static asset discovery.
- Tooling contracts: CI paths, deployment manifests, codegen outputs,
docs/link checkers, package metadata,
.gitignore, data loader paths,
notebook/report expectations.
- Human constraints: preferred names, backwards-compatible public paths,
source-package preservation, review scope, rollback story.
Constraints do not erase the ideal model; they explain where the final
target topology intentionally bends. If a constraint is merely manual
reference-update cost, consider improving /move-path or adding an
adapter over keeping an unintuitive layout, but do not pretend all
constraints are automatable.
Target Tree Rules
- Keep root small. Top-level names should describe kinds of work, not
import chronology.
- Keep raw materials out of
kb/; KB may contain source maps and claim
ledgers, but not large/raw dumps unless the project explicitly chooses
that.
- Keep active idea lifecycle outside
kb/ when ideas need intake,
pilots, composition, routing, promotion, or retirement.
- Put executable schemas in
specs/contracts/ only when they become
build commitments; Markdown-first templates can remain in the faster
lifecycle folder.
- Put pilot intent/specs near ideas; put runnable experiment execution
and results under
evals/.
- Add or update README/index signposts for every newly important folder.
Move Planning
Use /move-path for the deterministic part when the move table is clear.
Write one YAML plan for the conceptual batch, with exact_text_paths: update only after reviewing that plain path prose should move
mechanically too. If the uncertainty bucket is large, stop at a dry-run
report and a decision brief.
Recommended reference scope for docs-heavy repos:
reference_scope:
include:
- "**/*.md"
- "**/*.mdx"
- "**/*.yml"
- "**/*.yaml"
- "**/*.json"
- "**/*.html"
exclude:
- ".git/**"
- ".engineering/local/**"
- ".move-path/**"
- "node_modules/**"
- ".venv/**"
- "__pycache__/**"
Use one batch for one mental-model migration. Split when move groups have
different reviewers, rollback stories, or confidence levels.
Dry-Run Review
After /move-path --dry-run, inspect:
- move map: does every source land under the intended lifecycle owner?
- auto rewrites: are path references changing to the right new identity?
- suggestions: are they true references, historical citations, or
intentionally unchanged labels?
- blocked findings: do not apply until resolved.
- Git impact: tracked moves should preserve history with
git mv.
Output Contract
When you hand off a proposed or applied topology change, include a compact
naming-context table for confusing names. Each row should state:
- old name and proposed/current new name;
- context: provenance, operational, or compatibility;
- default action: preserve under clearer owner, rename, or keep with reason;
- constraint or evidence that justifies any non-default choice.
For operational labels, the default action is rename. Keeping names such as
outputs, tmp, old, final, inputs-1, or date/sequence labels in an
active navigation path requires a compatibility or explicit human-preference
reason. If the old spelling is useful only as history, preserve it as provenance
inside a clearer owner instead.
Dogfood Learnings
- Do not create aspirational runtime folders just because they appear in an
ideal tree. Add
src/, apps/, tests/, or framework-specific roots only
when the project already has that execution surface or the user explicitly
chooses to scaffold it.
- Treat historical source labels as both identities and citations. Paths such
as
inputs-1, outputs, or datasets may be moved mechanically, but bare
prose mentions often describe provenance and should usually stay as source
labels or become source-materials/... only after review.
- Keep source snapshots intact under their new owner. Do not flatten imported
packages during the same pass that demotes them from the top level.
- Add signposts in the same change as the moves. New lifecycle owners need a
README or index that says what belongs there, what does not, and when a thing
graduates elsewhere.
- After manual follow-up edits, rerun
/move-path --check, then inspect
git status, git diff --stat, and git diff --cached --check. Normalize
the index before commit so pure git mv changes and signpost/reference
edits do not get stranded in separate states.
- Put generated move reports under
.engineering/local/move-path/ and ignore
that local scratch area. A clean worktree can still hide ignored artifacts, so
make that intentional.
- For moved JSON/CSV/manifests/scripts, run an operational residue pass. These
files may contain absolute paths or command examples that are not Markdown
links and will not be proved by link checks alone.
- When a concrete repeatable cleanup risk appears, build or improve a tiny
deterministic helper with stated assumptions, machine-readable output, and
fixture coverage. Integrate useful helpers back into the owning
engineering-skill instead of leaving them as one-off project scripts.
Handoff
Before final handoff:
- state the ideal topology, the constrained target topology, and why
they differ;
- separate deterministic moves from judgment/manual follow-up;
- if moves were applied, run
/move-path --check;
- run project-native link/test checks if they exist;
- report any historical references intentionally left unchanged;
- do not update ecosystem or project state snapshots just to silence
unrelated advisory findings.
1---2name: organize-project-structure3description: Arrive at an ideal or near-ideal repo folder structure and organization approach under framework/tool/human constraints. Use when a project has historical top-level folders, source/input/output dumps, KB/spec/eval/runtime boundaries, or a proposed directory map that needs recursive folder summaries, ideal-vs-constrained topology review, boundary discovery, folder-worth judgment, deterministic move-plan options, dry-run validation, and a safe implementation approach. Not for one-off file moves or Python package prefix clusters.4---56# /organize-project-structure78You are the orchestrator for repo-wide folder-structure redesign. Your9job is to infer the clearer mental model, adapt it to hard project10constraints, preserve source material, and arrive at a near-ideal target11topology plus an implementation approach. Use deterministic movement when12the move table and reference behavior are clear; otherwise separate what13can be automated from what needs human/LLM judgment.1415Read `_common/structural-design-principles.md` before judging the target16tree. The floor is framework/tool correctness; above the floor, optimize17for skim, find, cluster, and stranger tests.1819## Core Contract2021Separate design judgment from mechanical movement:2223```text24inventory -> folder value summaries -> repeated abstraction -> ideal topology25-> constraint overlay -> target topology -> implementation approach26-> optional move-path plan/dry-run -> decision -> apply/check if chosen27```2829Do not hand-edit broad references when `/move-path` can resolve them.30Do not let an LLM do unstructured path rewrites. Do not apply a move plan31just because the skill can write one; applying is a decision after the32dry-run report and constraints are reviewed.3334## Classification Pass3536Classify every top-level folder and major root file by lifecycle:3738- `root-signpost` — files a new reader should see first, usually39 `README.md`, `AGENT.md`, or repo config.40- `doctrine-kb` — source-grounded knowledge, summaries, claims,41 process, schemas, synthesis.42- `idea-lifecycle` — ideas before they become default routes, skills,43 workbench features, or specs.44- `build-commitment` — contracts, architecture decisions, product specs,45 security decisions, acceptance criteria.46- `runtime` — executable product/library code.47- `proof-machinery` — fixtures, scorers, runners, experiments,48 run-records, reports.49- `raw-source-material` — datasets, imported source packages, logs,50 extraction outputs, third-party or historical inputs.51- `tooling` — scripts, tests, apps, CLIs, dashboards.52- `archive` — preserved historical state that should not shape daily53 navigation.5455Top-level folders must earn their position by being a durable reader56navigation key. Historical names like `inputs-1/`, `inputs-2/`, and57`outputs/` usually fail that test; preserve them under a source-material58or archive owner instead of deleting or flattening them.5960For every confusing name, make the context decision explicit:6162- **Provenance label** — keep the old name as a source identity, but move it63 under a clearer owner such as `source-materials/input-bundles/`.64- **Operational label** — rename it by default when the current name is65 meaningless, chronology-based, or misleading. The move plan should prefer the66 clearer name, not merely tuck the confusing name one level deeper.67- **Compatibility label** — keep it only when framework/tool contracts, public68 paths, or explicit human preference require the old spelling.6970## Abstraction Ladder7172Use summaries to climb from concrete contents to structural boundaries:73741. **Folder summaries.** For each top-level folder and major subfolder,75 summarize what work happens there, what value gets created, what76 artifacts are produced or consumed, and what reader question the77 folder answers. For code, sample entry points and public APIs; for78 docs, sample headings and cross-links; for data, sample manifests or79 READMEs before large payloads.802. **Second-pass summary.** Summarize the summaries. Look for repeated81 ownership patterns, lifecycle phases, hidden parallel hierarchies,82 source-vs-derived confusion, and names that describe history instead83 of current purpose.843. **Third-pass summary.** Summarize the second pass into the smallest85 useful set of navigation keys: e.g. doctrine, ideas, contracts,86 runtime, proof machinery, raw source material, apps, tools, tests.87 This is the ideal logical topology before constraints.8889Use the discovered boundaries to decide folder-worth. A boundary is a90folder candidate when it has its own reader question, lifecycle,91artifact set, or change cadence. It is a strong folder candidate when92two or more of these are true:9394- readers would naturally ask for it by name;95- edits inside it usually happen together and separately from neighbors;96- it owns a distinct value-producing workflow or artifact type;97- it has enough siblings/subparts that flat filenames would need a fake98 prefix;99- its name is being used as a tag on multiple siblings instead of as a100 container, e.g. several rename/move skills that naturally read as a101 `renaming/` cluster;102- it needs its own README/index to explain what belongs there and what103 does not.104105Pairs can stay flat when the boundary is weak. A small but distinct106boundary can still earn a folder when the navigation key is durable.107When possible, prefer colocating the cluster under a real folder over108sprinkling a shared tag through filenames or sibling names. Keep the tag109flat only when a framework, discovery mechanism, or strong reader110preference requires it.111112Keep the intermediate summaries short enough to review. They are not113deliverables unless the user asks; they are the ladder that makes the114target topology explainable instead of vibes-based.115116## Constraint Overlay117118After proposing the ideal logical topology, apply constraints before119solidifying the target topology:120121- Framework/runtime conventions: Next.js `app/` or `pages/`, Python122 package/import roots, Django app layout, build config discovery, test123 runner discovery, static asset discovery.124- Tooling contracts: CI paths, deployment manifests, codegen outputs,125 docs/link checkers, package metadata, `.gitignore`, data loader paths,126 notebook/report expectations.127- Human constraints: preferred names, backwards-compatible public paths,128 source-package preservation, review scope, rollback story.129130Constraints do not erase the ideal model; they explain where the final131target topology intentionally bends. If a constraint is merely manual132reference-update cost, consider improving `/move-path` or adding an133adapter over keeping an unintuitive layout, but do not pretend all134constraints are automatable.135136## Target Tree Rules137138- Keep root small. Top-level names should describe kinds of work, not139 import chronology.140- Keep raw materials out of `kb/`; KB may contain source maps and claim141 ledgers, but not large/raw dumps unless the project explicitly chooses142 that.143- Keep active idea lifecycle outside `kb/` when ideas need intake,144 pilots, composition, routing, promotion, or retirement.145- Put executable schemas in `specs/contracts/` only when they become146 build commitments; Markdown-first templates can remain in the faster147 lifecycle folder.148- Put pilot intent/specs near ideas; put runnable experiment execution149 and results under `evals/`.150- Add or update README/index signposts for every newly important folder.151152## Move Planning153154Use `/move-path` for the deterministic part when the move table is clear.155Write one YAML plan for the conceptual batch, with `exact_text_paths:156update` only after reviewing that plain path prose should move157mechanically too. If the uncertainty bucket is large, stop at a dry-run158report and a decision brief.159160Recommended reference scope for docs-heavy repos:161162```yaml163reference_scope:164 include:165 - "**/*.md"166 - "**/*.mdx"167 - "**/*.yml"168 - "**/*.yaml"169 - "**/*.json"170 - "**/*.html"171 exclude:172 - ".git/**"173 - ".engineering/local/**"174 - ".move-path/**"175 - "node_modules/**"176 - ".venv/**"177 - "__pycache__/**"178```179180Use one batch for one mental-model migration. Split when move groups have181different reviewers, rollback stories, or confidence levels.182183## Dry-Run Review184185After `/move-path --dry-run`, inspect:186187- move map: does every source land under the intended lifecycle owner?188- auto rewrites: are path references changing to the right new identity?189- suggestions: are they true references, historical citations, or190 intentionally unchanged labels?191- blocked findings: do not apply until resolved.192- Git impact: tracked moves should preserve history with `git mv`.193194## Output Contract195196When you hand off a proposed or applied topology change, include a compact197naming-context table for confusing names. Each row should state:198199- old name and proposed/current new name;200- context: provenance, operational, or compatibility;201- default action: preserve under clearer owner, rename, or keep with reason;202- constraint or evidence that justifies any non-default choice.203204For operational labels, the default action is **rename**. Keeping names such as205`outputs`, `tmp`, `old`, `final`, `inputs-1`, or date/sequence labels in an206active navigation path requires a compatibility or explicit human-preference207reason. If the old spelling is useful only as history, preserve it as provenance208inside a clearer owner instead.209210## Dogfood Learnings211212- Do not create aspirational runtime folders just because they appear in an213 ideal tree. Add `src/`, `apps/`, `tests/`, or framework-specific roots only214 when the project already has that execution surface or the user explicitly215 chooses to scaffold it.216- Treat historical source labels as both identities and citations. Paths such217 as `inputs-1`, `outputs`, or `datasets` may be moved mechanically, but bare218 prose mentions often describe provenance and should usually stay as source219 labels or become `source-materials/...` only after review.220- Keep source snapshots intact under their new owner. Do not flatten imported221 packages during the same pass that demotes them from the top level.222- Add signposts in the same change as the moves. New lifecycle owners need a223 README or index that says what belongs there, what does not, and when a thing224 graduates elsewhere.225- After manual follow-up edits, rerun `/move-path --check`, then inspect226 `git status`, `git diff --stat`, and `git diff --cached --check`. Normalize227 the index before commit so pure `git mv` changes and signpost/reference228 edits do not get stranded in separate states.229- Put generated move reports under `.engineering/local/move-path/` and ignore230 that local scratch area. A clean worktree can still hide ignored artifacts, so231 make that intentional.232- For moved JSON/CSV/manifests/scripts, run an operational residue pass. These233 files may contain absolute paths or command examples that are not Markdown234 links and will not be proved by link checks alone.235- When a concrete repeatable cleanup risk appears, build or improve a tiny236 deterministic helper with stated assumptions, machine-readable output, and237 fixture coverage. Integrate useful helpers back into the owning238 engineering-skill instead of leaving them as one-off project scripts.239240## Handoff241242Before final handoff:243244- state the ideal topology, the constrained target topology, and why245 they differ;246- separate deterministic moves from judgment/manual follow-up;247- if moves were applied, run `/move-path --check`;248- run project-native link/test checks if they exist;249- report any historical references intentionally left unchanged;250- do not update ecosystem or project state snapshots just to silence251 unrelated advisory findings.