AI-Assisted Development Workflow Setup

How to set up git hooks and GitHub integrations so AI assistants automatically get the context they need.


The Core Insight

AI assistants need context to be useful, and that context should be injected automatically rather than manually provided each time.

This workflow uses git hooks, templates, and GitHub integrations to:

  1. Automatically provide relevant context during commits
  2. Keep the AI informed about recent changes and priorities
  3. Standardize issue tracking and PR workflows
  4. Create a rich commit history that serves as documentation

What You’ll Build

1. Commit Message Template (.gitmessage)

A structured template that prompts for:

Why it matters: Commit messages become a searchable log of what changed, why, and what might break. Future AI sessions can scan git log to understand recent risky areas.

2. Git Hooks (.githooks/)

Three hooks that inject context at key moments:

Hook Trigger What it does
prepare-commit-msg Before editing commit message Injects template + full staged diff
post-commit After commit completes Shows workplan priorities as reminder
post-checkout After switching branches Shows recent commits + workplan

The key insight: The prepare-commit-msg hook solves the “AI needs to see the diff” problem. By injecting the diff directly into the commit message file (as comments that get stripped), the AI automatically has full context when writing commit messages.

3. GitHub Issue Templates (.github/ISSUE_TEMPLATE/)

Three templates for different issue types:

4. PR Template (.github/PULL_REQUEST_TEMPLATE.md)

Standardized PR format with:

5. CLAUDE.md

AI context file with:


The Workflow

GitHub Issues
     |
     v
+--------------------------------------------------+
|  1. gh issue list --label showstopping           |
|  2. Pick issue, create branch:                   |
|     git checkout -b bugfix/123-desc develop      |
|     (post-checkout hook shows context)           |
+--------------------------------------------------+
     |
     v
+--------------------------------------------------+
|  3. Work on the fix                              |
|  4. Stage changes: git add <files>               |
|  5. Commit (no -m flag): git commit              |
|     (prepare-commit-msg injects diff)            |
|  6. AI reads .git/COMMIT_EDITMSG                 |
|  7. AI writes informed commit message            |
|     (post-commit shows workplan reminder)        |
+--------------------------------------------------+
     |
     v
+--------------------------------------------------+
|  8. Push: git push -u origin HEAD                |
|  9. Create PR: gh pr create --base develop       |
| 10. Merge: gh pr merge --merge --delete-branch   |
| 11. Close issue if not auto-closed               |
| 12. Sync: git checkout develop && git pull       |
+--------------------------------------------------+

Branch Strategy

Labels

Commit Message Convention

<type>: <subject under 50 chars>

<body explaining what and why>

Bug Risk: low/medium/high
Areas to watch: <specific concerns>

The Hook Files

prepare-commit-msg

#!/bin/bash
# Inject the staged diff into the commit message as comments
# AI can read this context when writing the commit message

COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2

# Only inject on regular commits (not merges, amends, etc.)
if [ -z "$COMMIT_SOURCE" ]; then
    # Get the staged diff
    DIFF=$(git diff --cached)

    # Append diff as comments (will be stripped from final message)
    echo "" >> "$COMMIT_MSG_FILE"
    echo "# Staged changes (for context, will be stripped):" >> "$COMMIT_MSG_FILE"
    echo "# " >> "$COMMIT_MSG_FILE"
    echo "$DIFF" | sed 's/^/# /' >> "$COMMIT_MSG_FILE"
fi

post-commit

#!/bin/bash
# Show workplan priorities after each commit

echo ""
echo "=== Current Priorities ==="
if [ -f "workplan.txt" ]; then
    head -20 workplan.txt
else
    echo "No workplan.txt found"
fi
echo ""

post-checkout

#!/bin/bash
# Show context when switching branches

PREV_HEAD=$1
NEW_HEAD=$2
BRANCH_CHECKOUT=$3

if [ "$BRANCH_CHECKOUT" = "1" ]; then
    echo ""
    echo "=== Recent commits on this branch ==="
    git log --oneline -10
    echo ""
    echo "=== Current priorities ==="
    if [ -f "workplan.txt" ]; then
        head -10 workplan.txt
    fi
    echo ""
fi

Enable the hooks

git config core.hooksPath .githooks

Gotchas


Files Checklist

File Purpose
.gitmessage Commit template
.githooks/prepare-commit-msg Injects diff into commit message
.githooks/post-commit Workplan reminder after commits
.githooks/post-checkout Context on branch switch
.githooks/README.md Instructions for enabling hooks
.github/ISSUE_TEMPLATE/bug_report.md Bug report template
.github/ISSUE_TEMPLATE/feature_request.md Feature request template
.github/ISSUE_TEMPLATE/performance.md Performance issue template
.github/PULL_REQUEST_TEMPLATE.md PR template
CLAUDE.md AI context file
workplan.txt Project priorities (tracked in git)

Summary

This transforms a repository from “just code” into a structured environment optimized for AI assistance. The key innovation is automatic context injection - rather than relying on the AI to remember to check things, the system surfaces relevant information at the right moments.

The workflow is lightweight (no complex tooling beyond git and gh CLI) but provides significant benefits:

Setup time: ~1 hour. Time saved: many hours in future sessions.