Skip to content

Instantly share code, notes, and snippets.

@jalehman
Created April 24, 2025 23:15
Show Gist options
  • Save jalehman/3d6b79bf52553b013f13e449fa8f7af9 to your computer and use it in GitHub Desktop.
Save jalehman/3d6b79bf52553b013f13e449fa8f7af9 to your computer and use it in GitHub Desktop.
Claude Code workflow commands

Overview

The following are the commands that I create on a per-project basis within the repo-env folder as referenced in the workflow described here.

A few notes:

  • Replace /path/to/repo-env/ with the appropriate absolute path to your repo-env
  • Anything wrapped with <> is a variable to be replaced
  • <prefix>/$ARGUMENTS is written that way because I tend to prefix my branches with my name

.claude/commands/start-task.md

I need to start implementing task "$ARGUMENTS". Please:

  1. Load and analyze the task file content from /path/to/repo-env/tasks/$ARGUMENTS.md
  2. Update the main branch with latest changes:
    cd /path/to/repo-env/<repository> && git checkout main && git pull origin main
  3. Check if a worktree already exists for this task:
    cd /path/to/repo-env/<repository> && git worktree list | grep $ARGUMENTS
  4. If the worktree does not exist, create it:
    cd /path/to/repo-env/<repository> && git worktree add "/path/to/repo-env/$ARGUMENTS" -b "<prefix>/$ARGUMENTS"
  5. After creating the worktree, set up the environment:
    cd /path/to/repo-env/$ARGUMENTS && <your specific setup commands, e.g. npm install>
  6. If the worktree exists, ensure it's up-to-date with main:
    cd /path/to/repo-env/$ARGUMENTS && git checkout <prefix>/$ARGUMENTS && git merge main
  7. Load the 5 most recent git commits with full messages to understand recent changes:
    cd /path/to/repo-env/<repository> && git log -n 5
  8. Analyze the task requirements/plan. If no implementation plan exists in the task, create one and confirm with me.
  9. Begin implementation by tackling the first step in the plan

Throughout the implementation:

  • Document design decisions and updates to the plan in the task file repo/tasks/$ARGUMENTS.md
  • Follow the code style guidelines from CLAUDE.md
  • Use the appropriate build and testing commands

.claude/commands/orient.md

I need to get oriented with the task "$ARGUMENTS" in its worktree. Please help me understand the task and code context by:

  1. First, check if the worktree exists and show its path:

    ls -la /path/to/repo-env/$ARGUMENTS
  2. If the worktree doesn't exist, explain how to set it up:

    cd /path/to/repo-env && echo "Worktree doesn't exist yet. You can create it with: /project:start-task $ARGUMENTS"
  3. If the worktree exists, read the task description:

    cd /path/to/repo-env && cat tasks/$ARGUMENTS.md || echo "Task file not found in repository"
  4. Check the git branch and status in the worktree:

    cd /path/to/repo-env/$ARGUMENTS && git branch --show-current && git status --short
  5. Show recent commits in the task branch:

    cd /path/to/repo-env/$ARGUMENTS && git log --oneline -n 5
  6. Check if there have been any changes in the main repository since the worktree was created:

    cd /path/to/repo-env/<repository> && git log --oneline -n 5 main
  7. Identify files modified in this task:

    cd /path/to/repo-env/$ARGUMENTS && git diff --name-only main...HEAD

Based on this information, provide a concise orientation summary:

  • Task description and current status
  • Current branch and any uncommitted changes
  • Key files that have been modified
  • Recent commit history
  • Next steps based on the task description

This will help me understand the current state of the task and the changes that have been made, so you can continue working on it effectively.

.claude/commands/complete-task.md

Task completion depends on your workflow. I use two primary variants:

  1. Merge the worktree back to a main branch, clean up the branch and worktree.
  2. Create a pull request and leave the worktree intact for addressing review.

I use the first variant when I'm working on small solo projects or sub-branches off of a bigger working branch. The second variant is better for bigger projects when teams are involved. It's common to have multiple variants of this task in the same project.

Variant 1: Merge & Cleanup

I need to complete the task "$ARGUMENTS" and prepare it for review. Please help me:

  1. Check if there are any uncommitted changes in the task worktree:

    cd /path/to/repo-env/$ARGUMENTS && git status --porcelain
  2. If there are uncommitted changes, show them and ask if I want to commit them:

    cd /path/to/repo-env/$ARGUMENTS && git status
  3. Verify that the current branch is correct:

    cd /path/to/repo-env/$ARGUMENTS && git branch --show-current
  4. Check if the task file has been marked as completed:

    cd /path/to/repo-env && grep -i "status:.*completed\|status:.*pending approval" tasks/$ARGUMENTS.md
  5. If the task isn't marked as completed, edit the task file to add the status:

    cd /path/to/repo-env && cat tasks/$ARGUMENTS.md
  6. Rename the task file to indicate completion:

    cd /path/to/repo-env && mv tasks/$ARGUMENTS.md tasks/COMPLETE-$ARGUMENTS.md
  7. Clean up the worktree: a. Switch to the main repository:

    cd /path/to/repo-env/<repository>

    b. Check if the feature branch needs to be merged to main:

    git log main..<prefix>/$ARGUMENTS --oneline

    c. If there are commits to merge, merge them:

    git checkout main && git merge <prefix>/$ARGUMENTS

    d. Remove the worktree:

    git worktree remove "/path/to/repo-env/$ARGUMENTS"

    e. Prune the worktree references:

    git worktree prune

    f. Delete the branch:

    git branch -d <prefix>/$ARGUMENTS
  8. Provide a summary of the completed task, PR creation, and cleanup process

Throughout this process, make sure to:

  • Verify each step before proceeding to the next
  • Provide clear explanations of what's happening
  • Alert me if there are any issues that need my attention
  • Follow the proper order: verify → commit changes → merge → cleanup

Variant 2: PR

I need to complete the task "$ARGUMENTS" and prepare it for review. Please help me:

  1. Check if there are any uncommitted changes in the task worktree:

    cd /path/to/repo-env/$ARGUMENTS && git status --porcelain
  2. If there are uncommitted changes, show them and ask if I want to commit them:

    cd /path/to/repo-env/$ARGUMENTS && git status
  3. Verify that the current branch is correct:

    cd /path/to/repo-env/$ARGUMENTS && git branch --show-current
  4. Check if the task file has been marked as completed:

    cd /path/to/repo-env && grep -i "status:.*completed\|status:.*pending approval" tasks/$ARGUMENTS.md
  5. If the task isn't marked as completed, edit the task file to add the status:

    cd /path/to/repo-env && cat tasks/$ARGUMENTS.md
  6. Push the branch to remote for review:

    cd /path/to/repo-env/$ARGUMENTS && git push -u origin <prefix>/$ARGUMENTS
  7. Prepare a draft pull request with a body inspired by the task document:

    cd /path/to/repo-env && cat tasks/$ARGUMENTS.md

    Then create a draft PR:

    cd /path/to/repo-env/$ARGUMENTS && gh pr create --draft --title "[$ARGUMENTS] Implement task" --body "$(cat ../tasks/$ARGUMENTS.md)"
  8. Rename the task file to indicate completion:

    cd /path/to/repo-env && mv tasks/$ARGUMENTS.md tasks/COMPLETE-$ARGUMENTS.md
  9. Provide a summary of the completed task and PR creation.

Throughout this process, make sure to:

  • Verify each step before proceeding to the next
  • Provide clear explanations of what's happening
  • Alert me if there are any issues that need my attention
  • Follow the proper order: verify → commit changes → push → create PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment