Move Under a New Spec
A Feature that started as the shopping cart can end up covering discount codes too. Its user story then has to name both subjects, and a reader looking for the discount rules scrolls past everything about adding products.
Use move-under-new-spec to give part of a spec a Feature of its own in the same file. The agent writes the new Feature's title and user story, narrows the original's where they no longer fit, and links the two with out-of-scope lines. To give the new Feature a file of its own as well, add --own-file, or use Separate Out Specs afterwards.
Ask the agent to move rules and scenarios
Give the agent the spec path and name the rules and scenarios to move by title, or give their lines with --only-lines. A line on a rule's title, description or background picks the whole rule with its scenarios. A line in a scenario, from the tags above it to its last step, picks just that scenario. The parts can come from several Features in the file, and they all go under the one new Feature.
For example, ask the agent to move the discount code rule of ShoppingCart.specb under a new spec.
Feature: Shopping cart
As a shopper
I want to collect products in a cart and take discount codes off its total
So that I know what I'll pay before checking out
Scenario: add a product to the cart
Given the cart is empty
When I add a "Coffee mug" at "€12.00"
Then the cart total is "€12.00"
Rule: only a valid discount code takes its percentage off the cart total
Scenario: apply a valid discount code
Given the cart total is "€40.00"
When I apply the discount code "SAVE10"
Then the cart total is "€36.00"
Scenario: apply an expired discount code
Given the cart total is "€40.00"
When I apply the expired discount code "SPRING5"
Then the cart total is "€40.00"
The new Feature goes right after the original, with a user story written for the moved rule. The original's I want no longer names discount codes, and its So that still fits, so it stays. Each Feature points at the other with an out-of-scope line that names it by title.
Feature: Shopping cart
As a shopper
I want to collect products in a cart
So that I know what I'll pay before checking out
Out of scope: discounts — see Cart discounts
Scenario: add a product to the cart
Given the cart is empty
When I add a "Coffee mug" at "€12.00"
Then the cart total is "€12.00"
Feature: Cart discounts
As a shopper
I want to take a discount code off my cart's total
So that I pay less for the same products
Out of scope: adding products to the cart — see Shopping cart
Rule: only a valid discount code takes its percentage off the cart total
Scenario: apply a valid discount code
Given the cart total is "€40.00"
When I apply the discount code "SAVE10"
Then the cart total is "€36.00"
Scenario: apply an expired discount code
Given the cart total is "€40.00"
When I apply the expired discount code "SPRING5"
Then the cart total is "€40.00"
What each Feature keeps
Each moved rule and scenario keeps its tags, the comments above it and its steps. The new Feature takes the original's tags, and copies the description lines its parts need, such as a term they use. The original loses a description line only when nothing left in it needs that line.
Scenarios picked without their rule go under a rule in the new Feature that states what they show. If you pick every scenario of a rule but not the rule itself, the agent judges whether the rule moves with them. When they show a different criterion from the rule's, the rule stays behind with no scenarios, and the report names it as needing one.
Each background keeps only the steps its own scenarios rely on, at Feature and at rule level. The new Feature gets a copy of the original's background when its scenarios need it. The agent keeps any step it is unsure about and lists every step it removes.
If the move would leave a Feature with no rules or scenarios, the agent stops and changes nothing. Moving everything under a new header would just reword that Feature.
When the original's title changes and the file was named after it, the agent suggests a new file name. Give it with the IDE's Rename, which renames the spec's test classes as well.
Check the move, or review it first
Both Features stay in one file, which generates one test class, so the step implementations stay where they are. The generated tests are named by position, so the move renumbers them.
A removed background step is how the move can break a test. Add --verify in a Java project with JUnit 5, and the agent runs the spec's tests before and after the move and puts back any step a scenario turns out to need. Without it, check the report's list of removed steps.
Add --as-review-finding to see the change before it is made. The agent publishes it as one split finding in the spec's AI Review tab in IntelliJ IDEA, where you inspect it and select Apply or Dismiss. The agent needs the same connection to the IDE as a spec review. A finding can only change one Feature, so this works when the parts come from one Feature.
From the spec editor
In IntelliJ IDEA, right-click in the spec editor and choose SpecBinder → Move Under a New Spec. The entry saves the spec and sends the lines selected, or the caret's line with nothing selected, to the agent in the spec's own session, starting one if none is open. Agent sessions
The entry is greyed out where it has nothing to move, such as on a Feature's user story, and where the move would leave a Feature with nothing in it. The status bar says why. It works with Claude Code for now.