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 current-path submission;--path stackrequires a linear stack (one child per parent).undoremains single-level.- 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.
IMPORTANT: This project uses bd (beads) for ALL issue tracking. Do NOT use markdown TODOs, task lists, or other tracking methods.
- Dependency-aware: Track blockers and relationships between issues
- Git-friendly: Dolt-powered version control with native sync
- Agent-optimized: JSON output, ready work detection, discovered-from links
- Prevents duplicate tracking systems and confusion
Check for ready work:
bd ready --jsonCreate new issues:
bd create "Issue title" --description="Detailed context" -t bug|feature|task -p 0-4 --json
bd create "Issue title" --description="What this issue is about" -p 1 --deps discovered-from:bd-123 --jsonClaim and update:
bd update <id> --claim --json
bd update bd-42 --priority 1 --jsonComplete work:
bd close bd-42 --reason "Completed" --jsonbug- Something brokenfeature- New functionalitytask- Work item (tests, docs, refactoring)epic- Large feature with subtaskschore- Maintenance (dependencies, tooling)
0- Critical (security, data loss, broken builds)1- High (major features, important bugs)2- Medium (default, nice-to-have)3- Low (polish, optimization)4- Backlog (future ideas)
- Check ready work:
bd readyshows unblocked issues - Claim your task atomically:
bd update <id> --claim - Work on it: Implement, test, document
- Discover new work? Create linked issue:
bd create "Found bug" --description="Details about what was found" -p 1 --deps discovered-from:<parent-id>
- Complete:
bd close <id> --reason "Done"
bd automatically syncs via Dolt:
- Each write auto-commits to Dolt history
- Use
bd dolt push/bd dolt pullfor remote sync - No manual export/import needed!
- ✅ Use bd for ALL task tracking
- ✅ Always use
--jsonflag for programmatic use - ✅ Link discovered work with
discovered-fromdependencies - ✅ Check
bd readybefore asking "what should I work on?" - ❌ Do NOT create markdown TODO lists
- ❌ Do NOT use external issue trackers
- ❌ Do NOT duplicate tracking systems
For more details, see README.md and docs/QUICKSTART.md.
When ending a work session, you MUST complete ALL steps below. Work is NOT complete until git push succeeds.
MANDATORY WORKFLOW:
- File issues for remaining work - Create issues for anything that needs follow-up
- Run quality gates (if code changed) - Tests, linters, builds
- Update issue status - Close finished work, update in-progress items
- PUSH TO REMOTE - This is MANDATORY:
git pull --rebase bd sync git push git status # MUST show "up to date with origin" - Clean up - Clear stashes, prune remote branches
- Verify - All changes committed AND pushed
- Hand off - Provide context for next session
CRITICAL RULES:
- Work is NOT complete until
git pushsucceeds - NEVER stop before pushing - that leaves work stranded locally
- NEVER say "ready to push when you are" - YOU must push
- If push fails, resolve and retry until it succeeds