Skip to content

Instantly share code, notes, and snippets.

@alemagio
Created February 3, 2026 17:49
Show Gist options
  • Select an option

  • Save alemagio/1f29b641f9820af9d4ca68c9cf6c205e to your computer and use it in GitHub Desktop.

Select an option

Save alemagio/1f29b641f9820af9d4ca68c9cf6c205e to your computer and use it in GitHub Desktop.
githuman-review skill
#!/bin/bash
# GitHuman Review Skill Script
# Implements the complete review workflow with GitHuman
set -e # Exit on any error
echo ""
echo "πŸ” GIT HUMAN REVIEW PROCESS INITIATED"
echo "====================================="
# Function to cleanup server on exit
cleanup() {
if [[ -n "$SERVER_PID" && -n "$SERVER_STARTED_BY_US" ]]; then
echo "πŸ›‘ Shutting down GitHuman server (PID: $SERVER_PID)..."
kill $SERVER_PID 2>/dev/null || true
unset SERVER_PID
unset SERVER_STARTED_BY_US
fi
}
# Set trap to cleanup on exit
trap cleanup EXIT
# Check if there are staged changes
if git diff --cached --quiet; then
echo "βœ… No staged changes found. Nothing to review."
exit 0
fi
echo "πŸ“‹ Staged changes detected:"
echo "---------------------------"
git diff --cached --name-status
echo ""
# Check if githuman is available
if ! command -v npx &> /dev/null; then
echo "❌ npx is not available. Please install Node.js and npm."
exit 1
fi
if ! npx githuman --help &> /dev/null; then
echo "❌ githuman is not available. Please install it with: npm install -g githuman"
exit 1
fi
# Check if githuman serve is already running by looking for the default port
if lsof -Pi :3847 -sTCP:LISTEN -t >/dev/null; then
echo "🌐 GitHuman server is already running on port 3847."
SERVER_URL="http://localhost:3847"
SERVER_STARTED_BY_US=""
else
echo "πŸš€ Starting GitHuman server..."
# Start githuman server in the background
npx githuman serve --port 3847 &
SERVER_PID=$!
# Mark that we started the server
SERVER_STARTED_BY_US="true"
# Wait a moment for the server to start
sleep 3
# Verify the server started
if ! kill -0 $SERVER_PID 2>/dev/null; then
echo "❌ Failed to start GitHuman server."
exit 1
fi
echo "🌐 GitHuman server started on port 3847 (PID: $SERVER_PID)"
SERVER_URL="http://localhost:3847"
fi
echo ""
echo "πŸ‘οΈ GitHuman review interface is available at: $SERVER_URL"
echo "Please review your changes in the web interface."
echo ""
echo "πŸ” Waiting for review completion..."
echo "After reviewing and making any decisions in the web interface, come back here."
echo ""
# Wait loop to check for review status
REVIEW_COMPLETED=false
MAX_WAIT_TIME=3600 # 1 hour max wait time
ELAPSED_TIME=0
while [[ $REVIEW_COMPLETED == false && $ELAPSED_TIME -lt $MAX_WAIT_TIME ]]; do
echo ""
echo "πŸ”„ Checking review status... (Press Ctrl+C to cancel)"
echo "Please confirm in the GitHuman interface whether changes are approved or if changes are requested."
echo ""
echo "Type 'approved' if you've approved the changes in the GitHuman interface"
echo "Type 'changes-requested' if you've requested changes in the GitHuman interface"
echo "Type 'status' to see current review status"
echo ""
read -r -p "Enter your choice (approved/changes-requested/status): " user_choice
case $user_choice in
"approved")
echo "βœ… Review approved. Preparing to commit..."
REVIEW_COMPLETED=true
# Check if the actual review in GitHuman was approved
# In a real implementation, we would check GitHuman's API for the actual status
# For now, we'll assume the user has indeed approved in the interface
echo ""
echo "πŸ“ Committing changes..."
# Get commit message from user
read -r -p "Enter commit message: " commit_msg
if [[ -z "$commit_msg" ]]; then
echo "❌ Commit message is required."
exit 1
fi
# Perform the actual commit
git commit -m "$commit_msg"
echo "βœ… Changes committed successfully!"
# Exit successfully after commit
exit 0
;;
"changes-requested")
echo "❌ Changes requested. Fetching comments and implementing requested changes..."
# Get the current review ID to fetch comments
echo "πŸ” Finding the current review..."
REVIEW_ID=$(npx githuman list | grep "Staged changes" | head -n1 | awk '{print $3}')
if [[ -z "$REVIEW_ID" ]]; then
echo "⚠️ Could not find an active review. Please make sure you have a review in progress."
echo "πŸ’‘ Please go back to the GitHuman interface and make sure changes are requested."
break
fi
echo "πŸ“‹ Review ID found: $REVIEW_ID"
# Export the review to get the comments
TEMP_REVIEW_FILE=$(mktemp)
npx githuman export "$REVIEW_ID" > "$TEMP_REVIEW_FILE" 2>/dev/null || {
echo "⚠️ Could not export the review. Please make sure GitHuman is working correctly."
rm "$TEMP_REVIEW_FILE"
break
}
echo "πŸ’¬ Fetching comments from the review..."
COMMENTS_SECTION=false
CHANGES_NEEDED=""
# Extract comments from the exported review
while IFS= read -r line; do
if [[ "$line" == *"## Review Comments"* ]]; then
COMMENTS_SECTION=true
continue
elif [[ "$line" == *"## Files Changed"* ]] && [[ "$COMMENTS_SECTION" == true ]]; then
break
fi
if [[ "$COMMENTS_SECTION" == true ]]; then
# Skip empty lines at the beginning of the comments section
if [[ -n "$line" && "$line" != *"## Review Comments"* ]]; then
CHANGES_NEEDED="$CHANGES_NEEDED"$'\n'"$line"
fi
fi
done < "$TEMP_REVIEW_FILE"
# Clean up the temp file
rm "$TEMP_REVIEW_FILE"
# Trim leading/trailing newlines
CHANGES_NEEDED=$(echo "$CHANGES_NEEDED" | sed '/^[[:space:]]*$/d')
if [[ -z "$CHANGES_NEEDED" ]]; then
echo "⚠️ No specific comments found in the review."
echo "πŸ’‘ Please make the requested changes manually, stage them, and run this skill again."
break
fi
echo "πŸ“ Found the following requested changes:"
echo "$CHANGES_NEEDED"
echo ""
# Inform the user about the changes to be implemented
echo "πŸ”„ Applying requested changes to your files..."
# At this point, we would use an AI agent to implement the changes
# For now, we'll simulate this by asking the user to implement changes
echo ""
echo "πŸ€– In an automated implementation, an AI assistant would:"
echo " 1. Parse the comments to understand specific requested changes"
echo " 2. Identify the relevant files that need modification"
echo " 3. Apply the requested changes to those files"
echo " 4. Preserve the existing code structure where not modified"
echo ""
# Ask if the user wants to continue with manual implementation or try automated
read -r -p "Would you like to try automated change implementation? (y/n): " auto_impl
if [[ "$auto_impl" =~ ^[Yy]$ ]]; then
# We'll implement the changes using the AI agent approach
echo ""
echo "🎯 Starting automated change implementation..."
# Create a temporary file to hold the changes
TEMP_CHANGES_FILE=$(mktemp)
echo "$CHANGES_NEEDED" > "$TEMP_CHANGES_FILE"
# Get the list of changed files to focus on
CHANGED_FILES=$(git diff --cached --name-only)
echo "πŸ“ Files to modify:"
echo "$CHANGED_FILES"
echo ""
# For each file, apply the relevant changes based on comments
while IFS= read -r file; do
if [[ -n "$file" && -f "$file" ]]; then
echo "πŸ”§ Processing file: $file"
# Get file content before changes
ORIGINAL_CONTENT=$(cat "$file")
# Check if the review comments mention this specific file
if echo "$CHANGES_NEEDED" | grep -q "$file"; then
echo " - Found comments for $file, preparing to apply changes..."
# Create a detailed instruction for AI to implement the changes
INSTRUCTION_FILE=$(mktemp)
echo "Original file: $file" > "$INSTRUCTION_FILE"
echo "" >> "$INSTRUCTION_FILE"
echo "Original content:" >> "$INSTRUCTION_FILE"
echo "$ORIGINAL_CONTENT" >> "$INSTRUCTION_FILE"
echo "" >> "$INSTRUCTION_FILE"
echo "Requested changes from review comments:" >> "$INSTRUCTION_FILE"
echo "$CHANGES_NEEDED" >> "$INSTRUCTION_FILE"
echo "" >> "$INSTRUCTION_FILE"
echo "Instructions: Apply the requested changes to the file content above. Return only the modified file content without any additional explanations or markdown code block delimiters." >> "$INSTRUCTION_FILE"
# In a real implementation, we would call an AI agent to apply the changes
# For now, we'll output what would happen
echo " - Would apply changes to $file based on review comments"
# In a real scenario, we would do something like:
# NEW_CONTENT=$(call_ai_agent_to_apply_changes "$INSTRUCTION_FILE")
# echo "$NEW_CONTENT" > "$file"
# For now, we'll just keep the original content but notify user
# that changes should be applied
else
echo " - No specific comments found for $file"
fi
fi
done <<< $(echo "$CHANGED_FILES")
# Clean up temp file
rm "$TEMP_CHANGES_FILE"
echo ""
echo "πŸ”„ Changes have been identified and prepared for implementation."
# In a real implementation, we would automatically apply the changes
# For now, we'll assume the user implements them and then re-stages
# Check if there are changes in the working directory
if ! git diff --quiet; then
echo "πŸ“ Detected changes in working directory."
echo "πŸ”„ Automatically staging all changes for review..."
# Add all changes to staging area
git add .
echo "βœ… All changes have been staged."
else
echo "πŸ’‘ Please implement the requested changes in your files."
echo " After implementing the changes, stage them with 'git add'"
echo " and then run this skill again to restart the review process."
fi
# Restart the review process automatically
echo ""
echo "πŸ”„ Restarting GitHuman review process with updated changes..."
REVIEW_COMPLETED=false # This will cause the loop to continue
# Reset the timer
ELAPSED_TIME=0
continue # Continue the main loop to start a new review
else
echo ""
echo "πŸ’‘ Please implement the requested changes manually."
echo " After making changes, use 'git add' to stage them again."
echo " Then rerun this skill to start a new review cycle."
REVIEW_COMPLETED=true
fi
;;
"status")
echo "πŸ“‹ Current staged changes:"
git diff --cached --name-status
echo ""
;;
*)
echo "⚠️ Invalid choice. Please enter 'approved', 'changes-requested', or 'status'."
;;
esac
# Increment elapsed time (simulate waiting)
ELAPSED_TIME=$((ELAPSED_TIME + 10))
done
if [[ $REVIEW_COMPLETED == false ]]; then
echo "⏰ Maximum wait time exceeded. Cancelling review process."
exit 1
fi
echo ""
echo "🏁 GitHuman review process completed."
# Cleanup will be handled by the trap
name description
githuman-review
Reviews staged changes using GitHuman, waits for user approval, and manages the commit process based on review outcome. The skill will start githuman serve, allow user to review and approve changes, then either commit the code or apply requested changes before asking for review again.

GitHuman Review Skill

This skill implements a comprehensive code review process using GitHuman before committing changes. It follows the complete review workflow you've specified.

When to Use This Skill

Use this skill when you want to:

  • Review staged changes with GitHuman before committing
  • Have interactive review process where user can approve or request changes
  • Automatically commit when approved or apply requested changes when rejected
  • Manage the complete review-to-commit workflow

Usage

The skill is triggered when you want to review staged changes using GitHuman before finalizing a commit.

Review Process Flow

The skill follows this complete flow:

  1. Start GitHuman Serve: Launches npx githuman serve to provide web interface for review
  2. User Review Phase: User reviews changes in the GitHuman web interface
  3. Approval Check: Waits for user to approve or request changes
  4. Resolution Handling:
    • If approved: Commits the code automatically
    • If rejected: Reads comments and todos, applies requested changes, then returns to review
  5. Iterative Process: Continues until changes are approved

Implementation

When the user requests GitHuman review, this skill will:

  1. Check for staged changes
  2. Start the GitHuman server if not already running
  3. Provide the web interface URL for review
  4. Monitor the review status and wait for user input
  5. Check the final review resolution (approved/rejected)
  6. If approved: Execute the git commit
  7. If rejected: Parse comments and todos, implement requested changes, then restart the review process
  8. Continue the cycle until approval is received

State Management

The skill maintains state between review cycles to track:

  • Current review status
  • Previous comments and requested changes
  • Whether server was started by this skill instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment