Repository navigation
Description
Problem Description
devops openspec new <issue> prints "Created openspec/changes/ on branch ." The branch in this sentence is the branch name that the command computes from the issue title with branch_name. The command does not create, switch to or read that branch. When the checkout is on another branch, the output states a false fact.
Source: scaffold in src/devops_cli/openspec/scaffold.py computes branch = branch_name(issue, type_, slug) and returns it. new_next_steps in src/devops_cli/lang/en/messages.py formats it as "Created {folder} on branch {branch}." and again as "Branch: {branch}".
Reproduction Steps
git worktree add <path> -b fix/4498-same-name-test-path origin/main- In that worktree:
uv run devops openspec new 4498 git branch --show-current
Expected vs Actual Behavior
Expected: the output names the current branch, or states that the computed name is a suggestion and that the current branch has another name.
Actual: the output says "Created openspec/changes/4498-name-the-same-name-file-of on branch fix/4498-name-the-same-name-file-of." git branch --show-current gives fix/4498-same-name-test-path, and no branch fix/4498-name-the-same-name-file-of exists.
Environment Diagnostics
- DevOps CLI: main at 5f75d25
- Execution environment: devcontainer, git worktree
Logs, Traces, or Terminal Output
✓ Created openspec/changes/4498-name-the-same-name-file-of on branch fix/4498-name-the-same-name-file-of.
Branch: fix/4498-name-the-same-name-file-ofPre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Alternatives check of 2026-11-13: none.
Tool: none found.
Proposed design
Problem statement
devops openspec new <issue> prints that it created the change folder on a branch, and the branch name in that sentence is computed from the issue title. The command never creates, switches to or reads that branch, so a checkout on another branch reads a false fact, and the change folder can hold a slug that differs from the slug of the worktree branch. The command must name the branch of the checkout and take the change folder slug from that branch when the branch names the same issue.
Acceptance criteria
Requirement: The output names the branch of the checkout
devops openspec new SHALL name the branch that the checkout is on in its output.
Scenario: Checkout on the default branch
- WHEN The checkout is on
mainand the user runsdevops openspec new 4593 --title "fix(openspec): alpha". - THEN The output holds
Created openspec/changes/4593-alpha on branch main.andBranch: main.
Requirement: The change folder takes its slug from the branch of the issue
The command SHALL take the slug of the change folder from the branch of the checkout when that branch is <type>/<issue>-<slug> for the same issue.
Scenario: The branch slug differs from the title slug
- WHEN The worktree is on
fix/4593-alphaand the user runsdevops openspec new 4593 --title "fix(openspec): beta". - THEN The command creates
openspec/changes/4593-alpha/and creates no folderopenspec/changes/4593-beta/.
Requirement: The output marks the computed name as a suggestion
The command SHALL state that the computed branch name is a suggestion and that the checkout is not on it, when the branch of the checkout does not name the same issue.
Scenario: Checkout on a branch of another issue
- WHEN The checkout is on
docs/5225-adr-front-matter-and-rulesand the user runsdevops openspec new 4593 --title "fix(openspec): alpha". - THEN The output holds
Branch: docs/5225-adr-front-matter-and-rulesandThe branch fix/4593-alpha is a suggestion for this change. This checkout is not on it.
Requirement: A checkout with no branch names no branch
The command SHALL state that the checkout is on no branch when HEAD is detached.
Scenario: Detached HEAD
- WHEN The checkout has a detached HEAD and the user runs
devops openspec new 4593 --title "fix(openspec): alpha". - THEN The output holds
Branch: HEAD detachedand noon branch, and the command createsopenspec/changes/4593-alpha/.
Requirement: The dry run names the folder and the branch of a real run
The dry run SHALL name the folder and the branch that a real run creates in the same checkout.
Scenario: Dry run in a worktree on the branch of the issue
- WHEN The worktree is on
fix/4593-alphaand the user runsdevops openspec new 4593 --dry-run --title "fix(openspec): beta". - THEN The output holds
Would create openspec/changes/4593-alpha on branch fix/4593-alpha.andBranch: fix/4593-alpha, and the command creates no folder.
Existing Tool Considered
No open tool covers the need: the alternatives check of 2026-11-13 found none. GitPython (https://pypi.org/project/GitPython) can report the active branch, but it formats no message and reconciles no slug, and the project removed it for one git seam (docs/TESTING.md:80). The project builds the change itself, on helpers that already exist: current_branch reads the branch and parse_branch parses it. Written cost: about 5k tokens to build, keep and fix the code, and about 2 hours of elapsed time.
Key questions
- Which git command reports the branch of the checkout?:
git branch --show-currentreports it, and it prints nothing when HEAD is detached. The project already wraps it ascurrent_branch(repo_dir), which returns an empty string on a detached HEAD, andcommands/repos.pyrenders that asHEAD detached. [sources: src/devops_cli/git/operations.py:278, src/devops_cli/git/operations.py:280, src/devops_cli/commands/repos.py:92] - Which branch name does
devops openspec newreport?: The branch of the checkout, read withcurrent_branch. The folder is written into the working tree of that branch, so the sentence is true in every checkout. (best practice) [sources: src/devops_cli/openspec/scaffold.py:172, src/devops_cli/commands/openspec.py:126, src/devops_cli/git/operations.py:278]- Chosen: The branch of the checkout. The command writes the folder into the working tree of that branch, so the name is true.
- Rejected: The computed
<type>/<issue>-<slug>name. The command creates no branch and switches to none, so the output states a false fact, which is the defect. - Rejected: No branch name at all. The user then loses the name of the branch that the change belongs to, and the next steps name no branch.
- Where does the slug of the change folder come from?: From the branch of the checkout when
parse_branchreads that branch as<type>/<issue>-<slug>for the same issue; otherwise from the issue title, as today. CONTRIBUTING.md makes the branch slug the slug of the change folder, and the implement job makes the branch with the slug of the folder. (best practice) [sources: CONTRIBUTING.md:216, CONTEXT.md:122, src/devops_cli/git/branch_form.py:59]- Chosen: The slug of the branch of the checkout. The folder and the branch then hold the same slug, and the implement job derives the branch
<type>/<issue>-<slug>from the folder. - Rejected: The slug of the issue title always. The folder and the worktree branch hold different slugs, and the implement job derives a branch name that no worktree has.
- Chosen: The slug of the branch of the checkout. The folder and the branch then hold the same slug, and the implement job derives the branch
- What does the command print when the checkout is on another branch or on no branch?: It names the branch of the checkout, or
HEAD detachedwhen HEAD is detached, which is the wordingcommands/repos.pyalready uses. It then states that the computed<type>/<issue>-<slug>is a suggestion and that the checkout is not on it. (best practice) [sources: src/devops_cli/commands/openspec.py:126, src/devops_cli/commands/repos.py:92, src/devops_cli/git/branch_form.py:59]- Chosen: State the computed name as a suggestion. The user learns the branch name that the roadmap jobs use, and no sentence claims that the command made that branch.
- Rejected: Print the computed name with no note. It repeats the false fact of the defect.
- Rejected: Create the branch and switch to it. The command writes files only, and the roadmap jobs own the branch of an item; a switch would move the working tree of the user.
- How does
ScaffoldResultcarry the two names?: It keepsbranchas the computed<type>/<issue>-<slug>and addscurrent_branch, which isNoneon a detached HEAD (fromcurrent_branch(root) or None). The command reads both. (best practice) [sources: src/devops_cli/openspec/scaffold.py:25, tests/openspec/test_openspec_new.py:368]- Chosen: Add
current_branchand keepbranch. The callers and the tests that readbranchkeep their meaning. - Rejected: Change
branchto the branch of the checkout. It silently changes the meaning of the field for every caller and for the tests that read it.
- Chosen: Add
- Which code reads the branch of the checkout and which code parses it?: The helpers that already exist:
current_branchingit/operations.pyreads the branch through the one git seam, andparse_branchingit/branch_form.pyreturns its type, issue and slug.scaffold.pycalls both and starts no git command of its own. (best practice) [sources: src/devops_cli/git/operations.py:278, src/devops_cli/git/branch_form.py:59, docs/TESTING.md:80]- Chosen: Reuse
current_branchandparse_branch. Both exist, and the read goes through the one git seam that the invariant test enforces. - Rejected: A new subprocess call in
scaffold.py. It repeats the branch types and the slug rule in a second place and starts git outside the seam.
- Chosen: Reuse
- Where does the command build its output text?: Inline in
new_cmd, atcommands/openspec.py:120for the dry run and:126for the real run.MESSAGES.openspec.new_dry_run_outputandnew_next_stepshold the same text, and nothing reads them. [sources: src/devops_cli/commands/openspec.py:120, src/devops_cli/commands/openspec.py:126, src/devops_cli/lang/en/messages.py:553, src/devops_cli/lang/en/messages.py:554] - Where does the new wording live?: In
MESSAGES.openspec.new_dry_run_outputandnew_next_steps, formatted fromnew_cmd. The other openspec commands already print their text from that catalog, and the catalog already holds both messages. (best practice) [sources: src/devops_cli/commands/openspec.py:75, src/devops_cli/lang/en/messages.py:553, src/devops_cli/lang/en/messages.py:554]- Chosen: The message catalog. The other openspec commands print from
MESSAGES.openspec, and the two messages are already defined there, so the text has one home. - Rejected: The inline strings of
new_cmdonly. It leaves two copies of the same text, and the catalog entry that the issue names keeps the old wording.
- Chosen: The message catalog. The other openspec commands print from
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(openspec)scope of the title gives the scope.The output misleads users about the active branch but does not break the command or data.Users see a false branch name and may act on it, but the tool still functions correctly.The fix changes a message string or swaps the reported branch for the current one in one file.Both concern the openspec new scaffold command, but 3203 adds project-form content to the scaffold while this candidate fixes a misleading branch name in the output message.dan-petty commentedon Nov 12, 2026
Seen again on 2026-11-12. In a worktree on the branch
fix/4836-intake-comment-new-facts,devops openspec new 4836printedCreated openspec/changes/4836-the-intake-reason-comment-states-only on branch fix/4836-the-intake-reason-comment-states-only.The command made no branch with that name, and the worktree stayed on its branch.dan-petty commentedon Nov 12, 2026
Seen again on 2026-11-12 (devops-cli 0.115.0):
uv run devops openspec new 4845, run in a worktree on the branchfeat/4845-roadmap-job-result-line, printedCreated openspec/changes/4845-log-one-result-line-for-each on branch feat/4845-log-one-result-line-for-each. The checkout stayed on the first branch, and no branch with the printed name existed. I renamed the branch by hand to match the printed name.dan-petty commentedon Nov 12, 2026
Seen again on 2026-11-12 with #5185.
devops repos worktrees add 5185 --type feat --slug grafana-image-renderermade the worktree on branchfeat/5185-grafana-image-renderer. In that worktree,uv run devops openspec new 5185printed:git status --short --branchshowedfeat/5185-grafana-image-renderer, and no branchfeat/5185-enable-the-image-renderer-for-panelexists. The folder slug also differs from the slug of the worktree branch.dan-petty commentedon Nov 12, 2026
Occurrence on 2026-11-12, during #5163: in a worktree on the branch
docs/5163-cli-reference-index,uv run devops openspec new 5163 --title "docs(cli): turn CLI_REFERENCE into an index of the command group pages"printed "Created openspec/changes/5163-turn-cli-reference-into-an-index on branch docs/5163-turn-cli-reference-into-an-index." The checkout stayed ondocs/5163-cli-reference-index, and no branch of that name existed. I renamed my branch by hand to match the name.dan-petty commentedon Nov 12, 2026
The defect occurred again on 2026-11-12 (main at 0a14161, worktree
.data/agent/worktrees/w-5225).uv run devops repos worktrees add 5225 --type docs --slug adr-front-matter-and-rulesmade the branchdocs/5225-adr-front-matter-and-rules.uv run devops openspec new 5225printed "Created openspec/changes/5225-add-madr-front-matter-a-status on branch docs/5225-add-madr-front-matter-a-status."git branch --show-currentgavedocs/5225-adr-front-matter-and-rules. No branchdocs/5225-add-madr-front-matter-a-statusexists.One more effect: the folder slug also comes from the issue title, so it differs from the slug of the current branch. CONTRIBUTING.md section 5 says that the
<slug>of a branch is the slug of the change folder. I renamed the folder by hand to5225-adr-front-matter-and-rules. A fix can take the slug from the current branch when the branch is<type>/<issue>-<slug>for the same issue, and name that branch in the output.devops-cli-service commentedon Nov 13, 2026
Alternatives check: none
Reason: The searches found only general Git/Python references and GitPython, which can report the active branch but does not format or correct the CLI's message and does not reconcile the change slug. The issue needs a small in-repo change to
scaffold.pyandmessages.py, not an external tool.Tool: none found
Lacks:
openspec newoutput so that it names the branch that is actually checked out.<type>/<issue>-<slug>worktree branch.Tools considered:
Searches run:
Sources:
Checked on 2026-11-13. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 13, 2026
Seen again on 2026-11-13 at release 0.125.0.
devops repos worktrees add 5293 --type docs --slug k8s-product-docsmade the branchdocs/5293-k8s-product-docs. In that worktree,devops openspec new 5293printedCreated openspec/changes/5293-move-the-product-readme-sections-to on branch docs/5293-move-the-product-readme-sections-to.No branch of that name exists, and the worktree stayed ondocs/5293-k8s-product-docs.dan-petty commentedon Nov 13, 2026
The problem occurred again on 2026-11-13 for #5419. The worktree was on
docs/5419-bottom-line-first-line.uv run devops openspec new 5419printedCreated openspec/changes/5419-replies-give-the-bottom-line-in on branch docs/5419-replies-give-the-bottom-line-in. The command did not create that branch and did not switch to it. The folder was on the current branch. An agent that reads the output can think that the branch changed.dan-petty commentedon Nov 13, 2026
The defect occurred again on 2026-11-13 for #5421. In the worktree on branch
docs/5421-route-task-rules-out-of-agents-md,uv run devops openspec new 5421printed "on branch docs/5421-route-task-rules-out-of-agents". That name comes from the change slug, which is shorter than the branch slug. The command did not create or use that branch.devops-cli-service commentedon Nov 14, 2026
Status set to Ready at b15faab (see proposed design in issue body).
chore(main): release 0.138.0 (#5690)
devops-cli-service commentedon Nov 14, 2026
Released in v0.138.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.138.0
devops-cli-service commentedon Nov 14, 2026
Live since 2026-11-14 15:02 UTC