add: offer to initialize a stack automatically - #486
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an interactive fallback that initializes a stack when gh stack add runs outside one.
Changes:
- Reuses
runInitfromadd, preserving branch and commit options. - Restores missing local trunk branches from remotes.
- Updates documentation and regression tests.
Show a summary per file
| File | Description |
|---|---|
README.md |
Documents automatic initialization flow. |
docs/src/content/docs/reference/cli.md |
Updates CLI reference. |
cmd/utils.go |
Adds optional stack lookup. |
cmd/init.go |
Restores missing local trunks. |
cmd/init_test.go |
Tests trunk restoration. |
cmd/add.go |
Adds initialization prompt and flow. |
cmd/add_test.go |
Tests initialization scenarios. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Balanced
ktravers
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gh stack addto initialize a stack when current branch is not part of a stack #275When
gh stack addruns from a branch that is not part of a stack, it now offers to initialize a new stack instead of failing. Explicit and auto-generated branch names become the first layer; without a name, the existinginitflow handles branch selection and prompting.The shortcut reuses
runInit, preserves commit flags, and leaves declined confirmations and non-interactive behavior unchanged.initnow also restores a missing local trunk from the selected remote before branch creation, covering repositories where the default branch was renamed locally.README and CLI reference documentation are updated along with regression coverage for both flows.