Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Created March 3, 2026 08:20
Show Gist options
  • Select an option

  • Save thanakijwanavit/246f1b71932da52a6ae00d835d78a1a5 to your computer and use it in GitHub Desktop.

Select an option

Save thanakijwanavit/246f1b71932da52a6ae00d835d78a1a5 to your computer and use it in GitHub Desktop.
Setup Gasclaw Maintainer AI to maintain Villa Backend 4 project

PROMPT: Setup Gasclaw Maintainer for Villa Backend 4 Project

MISSION

Configure and run Gasclaw Maintainer AI agent to automatically maintain the Villa Backend 4 project. The maintainer should monitor, fix, and improve the codebase through automated PRs.

PROJECT OVERVIEW

Villa Backend 4 - E-commerce backend for Villa Market

  • Location: Find it with find ~ -type d -name "villa-backend-4" 2>/dev/null
  • Tech stack: Node.js/TypeScript, AWS Lambda, Serverless Framework
  • Database: DynamoDB, Dolt SQL (port 3307)
  • Current issues: Various bugs and maintenance needs

Gasclaw Maintainer - AI-powered maintenance agent

  • Location: Find it with find ~ -path "*/gasclaw/maintainer" -type d 2>/dev/null
  • Uses Claude Code + Kimi K2.5 for AI processing
  • OpenClaw gateway for Telegram notifications
  • Automated GitHub PR creation

STEP 1: DISCOVER ENVIRONMENT

# Find project directories
export VILLA_BACKEND=$(find ~ -type d -name "villa-backend-4" 2>/dev/null | head -1)
export GASCLAW_DIR=$(find ~ -path "*/gasclaw/maintainer" -type d 2>/dev/null | head -1)

echo "Villa Backend: $VILLA_BACKEND"
echo "Gasclaw: $GASCLAW_DIR"

# Check if found
if [ -z "$VILLA_BACKEND" ] || [ -z "$GASCLAW_DIR" ]; then
    echo "ERROR: Could not find directories. Search manually:"
    find ~ -maxdepth 3 -type d 2>/dev/null | grep -E "(villa|gasclaw)"
fi

STEP 2: VERIFY CURRENT STATE

Check Villa Backend 4

cd $VILLA_BACKEND
git status
git log --oneline -5
ls -la

Check Gasclaw Maintainer Container

cd $GASCLAW_DIR

# Is container running?
docker ps | grep gasclaw-maintainer

# Check logs for errors
docker logs gasclaw-maintainer-villa --tail 30

# Check if services are healthy
docker exec gasclaw-maintainer-villa ps aux | grep -E "(openclaw|dolt|gt)"

Check Environment Variables

cat $GASCLAW_DIR/.env
# Should contain:
# - GITHUB_TOKEN (with repo access)
# - TELEGRAM_BOT_TOKEN (for notifications)
# - TELEGRAM_CHAT_ID (group notifications)
# - KIMI_API_KEY (AI backend)

STEP 3: FIX ANY BLOCKING ISSUES

Issue: Permission Denied on /workspace/gt

If you see "Permission denied" errors:

# Fix from HOST machine (not container)
cd $GASCLAW_DIR
sudo chown -R 1000:1000 data/gt/
docker restart gasclaw-maintainer-villa

Issue: Container Not Running

cd $GASCLAW_DIR
docker-compose down
docker-compose up -d
sleep 10
docker logs gasclaw-maintainer-villa --tail 50

Issue: Bot Not Responding to Messages

# Check if Telegram polling is working
docker exec gasclaw-maintainer-villa \
  cat /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log 2>/dev/null | \
  grep -E "(lane enqueue|telegram.*starting)" | tail -5

# Should see: lane enqueue: lane=session:agent:main:telegram:group:-1003776910127

STEP 4: CONFIGURE GASCLAW FOR VILLA BACKEND 4

Verify gasclaw.yaml Config

cat $GASCLAW_DIR/data/config/gasclaw.yaml

Should have:

maintenance:
  loop_interval: 300        # 5 minutes between cycles
  max_pr_size: 200          # Max lines changed per PR
  auto_merge: false         # Manual review recommended
  repo: "gastown-publish/gasclaw"  # Or your fork
  working_dir: "/workspace/gasclaw"
  
# Important: Villa Backend should be mounted at /workspace/villa-backend-4

Verify Docker Compose Mounts

cat $GASCLAW_DIR/docker-compose.yml | grep -A5 "volumes:"

Should see:

volumes:
  - ./data:/workspace
  - /path/to/villa-backend-4:/workspace/villa-backend-4:ro  # Or :rw for fixes

STEP 5: VERIFY INTEGRATION

Test 1: Container Can See Villa Backend

docker exec gasclaw-maintainer-villa ls -la /workspace/villa-backend-4/
docker exec gasclaw-maintainer-villa cat /workspace/villa-backend-4/package.json | head -10

Test 2: GitHub Authentication Works

docker exec gasclaw-maintainer-villa gh auth status

Test 3: Dolt SQL is Running

docker exec gasclaw-maintainer-villa dolt sql -q "SELECT 1;"

Test 4: Telegram Notifications Work

Send test message to group:

docker exec gasclaw-maintainer-villa python3 -c "
import os, json, urllib.request
token = os.environ['TELEGRAM_BOT_TOKEN']
chat_id = '-1003776910127'
msg = 'πŸ€– Gasclaw Maintainer is now monitoring Villa Backend 4'
data = json.dumps({'chat_id': chat_id, 'text': msg}).encode()
req = urllib.request.Request(f'https://api.telegram.org/bot{token}/sendMessage', 
                              data=data, headers={'Content-Type': 'application/json'})
urllib.request.urlopen(req, timeout=10)
print('Notification sent!')
"

STEP 6: START MAINTENANCE MODE

Option A: Run Maintenance Loop (Continuous)

The entrypoint.sh should already be running this. Check:

docker logs gasclaw-maintainer-villa | grep -i "maintenance\|cycle"

You should see "=== Maintenance cycle #N ===" every 5 minutes.

Option B: Manual Single Run

docker exec gasclaw-maintainer-villa bash -c "
export GT_HOME=/workspace/gt
export GITHUB_TOKEN=\$GITHUB_TOKEN
export ANTHROPIC_API_KEY=\$KIMI_API_KEY
cd /workspace/villa-backend-4
claude -p 'Analyze this codebase for bugs and issues. Look for:
1. Common anti-patterns
2. Error handling problems
3. Security issues
4. Performance bottlenecks
5. Test coverage gaps
Report findings in structured format.' 2>&1 | tee /tmp/analysis.log
"

Option C: Claude Code Interactive Session

docker exec -it gasclaw-maintainer-villa bash
# Then inside container:
cd /workspace/villa-backend-4
claude
# Now interact with Claude Code to fix issues

STEP 7: VERIFY MAINTENANCE IS WORKING

Check 1: Maintenance Cycles Running

docker logs gasclaw-maintainer-villa 2>&1 | grep -E "Maintenance cycle|=== " | tail -10

Check 2: PRs Being Created

docker exec gasclaw-maintainer-villa gh pr list --repo YOUR_REPO 2>/dev/null | head -10

Or check GitHub web UI for new PRs from "Gasclaw Maintainer" bot.

Check 3: Status Reports in Telegram

Look for messages like:

  • "πŸ“Š Sasha's GT Status Report"
  • "πŸ”„ Maintenance cycle complete"
  • "βœ… PR created: fix/..."

Check 4: Logs Show Activity

# Check OpenClaw logs
docker exec gasclaw-maintainer-villa \
  cat /tmp/openclaw/openclaw-$(date +%Y-%m-%d).log 2>/dev/null | \
  grep -E "(agent|session|embedded run)" | tail -20

MAINTENANCE TASKS GASCLAW SHOULD PERFORM

Immediate Tasks

  1. Security Audit

    • Check for hardcoded secrets
    • Review dependency vulnerabilities
    • Check IAM permissions
  2. Code Quality

    • Run linter (ESLint/Prettier)
    • Check TypeScript types
    • Identify dead code
  3. Bug Fixes

    • Check error handling
    • Review async/await patterns
    • Validate input sanitization
  4. Documentation

    • Check README accuracy
    • Update API docs
    • Add inline comments

Ongoing Tasks (Every Cycle)

  1. Monitor test suite health
  2. Check for dependency updates
  3. Review open issues
  4. Validate deployment configs

TROUBLESHOOTING

Problem: Maintenance cycles not starting

# Check if entrypoint is stuck
docker logs gasclaw-maintainer-villa --tail 100 | grep -i "error\|fail\|permission"

# Restart container
docker restart gasclaw-maintainer-villa
sleep 30
docker logs gasclaw-maintainer-villa --tail 50

Problem: Claude Code not responding

# Check Kimi API key
docker exec gasclaw-maintainer-villa env | grep KIMI

# Test API connectivity
docker exec gasclaw-maintainer-villa curl -s https://api.kimi.com/coding/models

Problem: Cannot write to Villa Backend

If maintainer needs to create PRs but code is mounted read-only:

# In docker-compose.yml, change:
# - /path/to/villa-backend-4:/workspace/villa-backend-4:ro
# To:
# - /path/to/villa-backend-4:/workspace/villa-backend-4:rw

# Then restart
cd $GASCLAW_DIR
docker-compose down
docker-compose up -d

Problem: Git auth failing

docker exec gasclaw-maintainer-villa gh auth login --with-token
# Paste GITHUB_TOKEN when prompted

SUCCESS CRITERIA

Verify all are true:

  • Container running: docker ps | grep gasclaw-maintainer
  • No permission errors in logs: docker logs gasclaw-maintainer-villa 2>&1 | grep -i permission (should be empty)
  • Maintenance cycles active: docker logs gasclaw-maintainer-villa | grep "Maintenance cycle"
  • Villa Backend visible: docker exec gasclaw-maintainer-villa ls /workspace/villa-backend-4/package.json
  • Telegram bot responding: Send "status" in group, get reply
  • GitHub auth working: docker exec gasclaw-maintainer-villa gh auth status
  • Status reports arriving in Telegram every 5 minutes

REPORT BACK

Tell me:

  1. Where you found the directories ($VILLA_BACKEND and $GASCLAW_DIR)
  2. Current container status (running/stopped/errors)
  3. Any blocking issues you encountered
  4. Current state of maintenance cycles (active/not started)
  5. Whether Telegram bot is responding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment