feat: add deep-work automation system#1644
Conversation
Implements full workflow automation for GitHub issues using worktrees and AI agents. Features: - Complete 12-step workflow automation from issue selection to PR - Worktree-based parallel development - AI agent orchestration (architectobot, codecrusher, memory-keeper, pr-reviewer) - Smart issue selection with filtering - Resume capability with state detection - Quality gates and automated checks Commands: - pnpm deep-work start <issue> - Full workflow for specific issue - pnpm deep-work pick - AI-powered issue selection + start - pnpm deep-work continue - Resume from current state - pnpm deep-work status - Progress dashboard - pnpm deep-work cleanup <issue> - Clean up completed work 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR introduces a comprehensive Bash CLI system for managing AI-assisted GitHub issue resolution workflows. It includes CLI dispatch, shared worktree/repository utilities, smart issue picking with scoring, full end-to-end workflow automation (planning, implementation, quality checks, PR creation), session resumption logic, and worktree lifecycle management. ChangesDeep Work Issue Automation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Comment |
Scripts should be in scripts/deep-work/ not directly in scripts/
graycyrus
left a comment
There was a problem hiding this comment.
Walkthrough
This PR adds a pnpm deep-work command suite — eight shell scripts under scripts/deep-work/ — that automates the full GitHub issue workflow: syncing upstream, creating a git worktree, calling AI agents for planning and implementation, running quality checks, committing, pushing, creating a PR, and running an automated review. The modular layout (shared lib.sh, individual verb scripts, cli.sh dispatcher) is consistent with the existing scripts/work/ and scripts/review/ structure.
However, the PR has several correctness and security problems that need to be addressed before merging.
Change Summary
| File | Summary |
|---|---|
package.json |
Registers deep-work as bash scripts/deep-work/cli.sh |
scripts/deep-work/cli.sh |
Dispatcher: routes start, pick, continue, status, list, cleanup |
scripts/deep-work/lib.sh |
Shared helpers: worktree management, repo resolution, quality checks |
scripts/deep-work/start.sh |
Full 12-step workflow: sync → worktree → plan → implement → QC → commit → push → PR → review |
scripts/deep-work/continue.sh |
Resume from current state with interactive branch detection |
scripts/deep-work/pick.sh |
Smart issue selection via jq scoring, then delegates to start.sh |
scripts/deep-work/status.sh |
Progress dashboard over all active worktrees |
scripts/deep-work/list.sh |
Simple worktree listing |
scripts/deep-work/cleanup.sh |
Guided worktree teardown with PR status awareness |
Verified / Looks Good
cli.shdispatch pattern is correct;exechand-off means no dangling shell processeslib.shsourcing ofscripts/review/lib.shand layered env-var resolution is sensiblepick.shjq scoring logic is soundcleanup.shdouble-confirmation flow is good UXstatus.shuses process substitution correctlyworktree_branch_for_issueslug generation matches existing patterns
Nitpicks
- Every file is missing a trailing newline (POSIX requires text files to end with newline)
list.shsetsworktrees_found=truein a subshell (pipe) so it's never visible — then works around it by callinglist_deep_work_worktreesa second timelib.shsync_upstreamusesgit merge --ff-only || git mergefallback which may produce unexpected merges on non-ff failuresstart.shusescontext_info+="...\n"but\nin double-quotes produces literal backslash-n, not a newline
Questions
- The
read -rpauses after planning and implementation suggest the user must supervise each step. Is this intended as semi-automated (with checkpoints) rather than fully automated? worktree_existsonly checks[ -d ]— if the dir was manually deleted withoutgit worktree remove, stale git refs could cause issues. Should this checkgit worktree listinstead?
|
|
||
| # Call architectobot agent directly via claude with task flag | ||
| echo "$planning_prompt" | claude --task architectobot | ||
|
|
There was a problem hiding this comment.
[critical] claude --task architectobot is not a valid Claude Code CLI invocation. Claude Code doesn't have a --task flag. This means steps 2, 3, 6, and 10 of the workflow will error out immediately.
The same issue affects lines 181, 216, and in continue.sh at lines 111 and 236.
| claude "$planning_prompt" |
|
|
||
| echo "[deep-work] staging changes for commit..." | ||
| git add . | ||
|
|
There was a problem hiding this comment.
[critical] git add . blindly stages everything — could commit .env files, build artifacts, or editor swap files that happen to be in the worktree. CLAUDE.md explicitly says: "prefer adding specific files by name rather than git add -A or git add .".
| # Stage tracked modifications only; let the user explicitly add new files | |
| git add -u | |
| echo "[deep-work] staged tracked changes. Untracked files (if any):" | |
| git ls-files --others --exclude-standard |
| commit_message="fix(#${issue}): ${title} | ||
|
|
||
| ${body} | ||
|
|
There was a problem hiding this comment.
[critical] The full issue body ($body) is interpolated into the commit message. This is both a security risk (crafted issue bodies could contain shell metacharacters that expand during assignment) and a usability problem (issue bodies can be many KB). The existing scripts/work/start.sh avoids this — use only the title + issue reference.
| git commit -m "fix(#${issue}): ${title} | |
| Closes #${issue} | |
| 🤖 Generated with [Claude Code](https://claude.ai/code) | |
| Co-Authored-By: Claude <noreply@anthropic.com>" |
| worktree_dir_for_issue() { | ||
| local issue="$1" | ||
| echo "../oh-$issue" | ||
| } |
There was a problem hiding this comment.
[major] This returns a relative path (../oh-<n>). Once start.sh does cd "$worktree_dir", any subsequent call to worktree_dir_for_issue resolves incorrectly (it would be ../../oh-<n> relative to the new CWD). Use the already-available $repo_root:
| } | |
| echo "${repo_root}/../oh-${issue}" |
| --body "$pr_body" \ | ||
| --draft \ | ||
| --head "$(gh auth status 2>&1 | grep 'Logged in.*as' | sed 's/.*as //' | cut -d' ' -f1):$branch" \ | ||
| --base main \ |
There was a problem hiding this comment.
[major] gh auth status output format is not stable across gh versions and is not meant for programmatic use. If the format changes or there are multiple accounts, this silently produces a broken --head value.
Use the API instead:
| --base main \ | |
| --head "$(gh api /user --jq '.login'):$branch" \ |
|
|
||
| # Fetch main from main worktree location | ||
| cd "$repo_root" | ||
| sync_upstream |
There was a problem hiding this comment.
[major] This cd $repo_root && sync_upstream && cd $worktree_dir block switches the main worktree to the main branch and runs a full fetch+submodule update — which may disturb the developer's main checkout (could be on a different branch). Step 0 already synced before creating the worktree.
Just fetch and merge from within the worktree:
git fetch origin main
if ! git merge origin/main; then| if ! pnpm format:check; then | ||
| echo "[deep-work] running formatter..." | ||
| pnpm format | ||
| fi |
There was a problem hiding this comment.
[minor] If pnpm format itself fails, the function continues and reports success. Also, no indication that the formatter modified files (working tree is now dirty).
| fi | |
| if ! pnpm format; then | |
| echo "[deep-work] ❌ formatter failed" | |
| return 1 | |
| fi | |
| echo "[deep-work] ⚠️ formatter made changes — files are now modified" |
Summary
Implements full workflow automation for GitHub issues using worktrees and AI agents, following the workflow patterns documented in
workflow/directory.Features
Core Automation
Commands Added
pnpm deep-work start <issue>- Full workflow for specific issuepnpm deep-work pick- AI-powered issue selection + start workflowpnpm deep-work continue- Resume from current state with intelligent detectionpnpm deep-work status- Progress dashboard for all active workpnpm deep-work list- Simple worktree listingpnpm deep-work cleanup <issue>- Clean up completed workWorkflow Steps Automated
../oh-<issue>worktree with new branchImplementation
scripts/deep-work/with modular designlib.shfor worktree managementTesting
pnpmscript ecosystemBreaking Changes
None - purely additive feature.
Next Steps
🤖 Generated with Claude Code
Summary by CodeRabbit
pnpm deep-workCLI command for managing GitHub issue workflows with subcommands:start(begin new issues),pick(smart issue selection),continue(resume sessions),status(view progress),list(show active issues), andcleanup(remove sessions)