Reorganize Spec Folders
When specs live under folders such as api/ and ui/, you have to know how a checkout behavior is tested before you know where to look for it. Grouping specs by what the system does puts related rules and examples in the same place, even when they exercise different interfaces.
Use restructure-spec-folders to organize existing specs and their tests in a Java project that uses JUnit 5 and Maven or Gradle. The default is to group by business capability. You can name another principle, such as grouping by the roles in the specs' user stories, or ask for repair only to tidy the current structure. Give a folder or package to limit the scope.
Example of grouping by capability
In this shop suite, the API and UI folders each hold specs for both the cart and checkout. These trees show the shop package under src/test/java/com/example.
shop/
├── api/
│ ├── CartDiscounts.specb
│ └── PayByCard.specb
└── ui/
├── ShoppingCart.specb
└── ChooseDelivery.specb
Ask the agent to reorganize the shop specs by capability. It proposes a tree based on what the specs describe. You can review and adjust it before the moves begin.
shop/
├── cart/
│ ├── CartDiscounts.specb
│ └── ShoppingCart.specb
└── checkout/
├── ChooseDelivery.specb
└── PayByCard.specb
Now someone changing checkout can find delivery and card payment together. When a capability grows, give it subfolders for the distinct parts of the behavior people need to find.
Keep the tests working through the move
The agent checks that the project compiles before planning the changes. After you approve the plan, it moves each spec with its test class and any helpers or data used only by that spec. It places shared test code with the capability that uses it, or in a shared package when several capabilities use it.
It updates packages, imports, marker paths or globs, and references such as JUnit suites and build filters. It then rebuilds the generated tests from the new locations and runs the affected tests. Checking that each moved scenario still runs exactly once catches missing marker coverage and overlapping globs.
The report tells you what moved and how the build and tests went. The scenarios and rules keep their original wording. If a spec spans several capabilities, the agent reports it as a candidate for splitting: a spec review or Move Under a New Spec divides it into several Features, and then the agent can give each one its own file. Separate Out Specs