Guidance for AI coding agents working in this repository.
- Project:
dubstack - Type: Turborepo monorepo — TypeScript CLI (ESM) for stacked git branch workflows + docs app
- Main entrypoint:
packages/cli/src/index.ts - Core commands:
create,restack,submit/ss,merge-next/land,post-merge,undo,co,modify,skills - State storage:
.git/dubstack/*inside the target git repository
- Node:
>=22(required) - Package manager:
pnpm(pnpm@10.29.1inpackage.json) - Monorepo orchestrator:
turbo(root scripts delegate via turbo) - Test runner:
vitest - Lint/format:
biome(runs repo-wide from root viapnpm checks) - Build tool:
tsup(CLI package)
Use these commands from the repo root:
pnpm installpnpm testpnpm typecheckpnpm checkspnpm checks:fixpnpm check:allpnpm evalspnpm evals:watchpnpm evals:exportpnpm build
- Root configs:
turbo.json,tsconfig.json(base),biome.json,pnpm-workspace.yaml - CLI package (
packages/cli/):- CLI wiring:
packages/cli/src/index.ts - Command implementations:
packages/cli/src/commands/*.ts - Shared logic:
packages/cli/src/lib/*.ts - Unit tests:
packages/cli/src/**/*.test.tsandpackages/cli/test/**/*.test.ts
- CLI wiring:
- Docs app:
apps/docs/(Next.js App Router with Fumadocs) - Agent contributor docs:
.agents/README.md,.agents/styleguide.md,.agents/patterns/*.md - Agent skills shipped by this repo:
skills/dubstackskills/dub-flow
- Project-only agent skills:
.agents/skills/dub-flow-evals
- Follow existing TypeScript style in this repo:
- spaces for indentation (2 spaces)
- single quotes
- kebab-case file names
- ESM imports
- Read
.agents/styleguide.mdand relevant.agents/patterns/*.mdbefore making structural changes. - Keep command behavior user-facing and explicit via
DubErrormessages. - Prefer small pure helpers in
packages/cli/src/lib/*over large command files. - Avoid adding new dependencies unless necessary.
- Keep all changes source-first in
packages/cli/src/; do not hand-edit generated output.
createauto-initializes state viaensureState(...).restackandsubmitrequire valid tracked stack state and should fail clearly when context is invalid.submitdefaults to downstack (current branch + ancestors); use--upstack,--stack, or--branch <name>for other scopes. Scope flags are mutually exclusive. Legacy--path current|stackstill works in v1.x with a deprecation warning.undois multi-level via a 20-entry ring buffer at.git/dubstack/undo-log.json;dub redoreplays the most recently undone entry. Mutating commands save an entry before mutation; saves are best-effort (filesystem failures are swallowed).- Error text is part of UX and often asserted in tests; change carefully.
ALWAYS run these before considering any task complete — no exceptions:
pnpm checks— lint + format (auto-fix withpnpm checks:fix)pnpm typecheck— type checkingpnpm test— unit tests
All three must pass. Do not skip any. Do not consider work done until all pass.
If AI metadata generation or prompts changed, also run pnpm evals.
When you want the full local gate in one command, run pnpm check:all.
If behavior/output changed, add or update tests near the changed code:
- command logic:
packages/cli/src/commands/*.test.ts - library logic:
packages/cli/src/lib/*.test.ts - cross-command scenarios:
packages/cli/test/**/*.test.ts
- Use conventional commit style where possible (
feat:,fix:,docs:, etc.). - Keep commits scoped and readable.
- Preserve clean history expectations on
main: linear history, squash-style landing, and required checks passing before merge. - If command UX changes, update docs (
README.md,QUICKSTART.md) in the same PR. - If skill workflows change, update corresponding files under
skills/.
- Do not use git worktrees for this repository, even if a prompt or skill (including
using-git-worktrees) recommends it. - Perform all work in the current repository checkout unless the user explicitly asks otherwise.
When implementing a task:
- Read relevant command + lib files in
packages/cli/src/first. - Make minimal focused edits.
- Add/update tests for changed behavior.
- Run verification commands.
- Summarize changes with file paths and any follow-up risks.
When reviewing code:
- Prioritize regressions in stack state handling, git command safety, submit flow, and conflict/recovery paths.