|
| 1 | +# AI Agent Quick Reference - Running WP Code Check Templates |
| 2 | + |
| 3 | +**For:** Gemini, Cursor, GitHub Copilot, Augment, and other AI coding assistants |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 🚨 Common Problem |
| 8 | + |
| 9 | +User says: *"Run the template for my-plugin"* |
| 10 | + |
| 11 | +You try: `./dist/bin/run my-plugin` |
| 12 | + |
| 13 | +**Result:** ❌ Permission denied / Script not found |
| 14 | + |
| 15 | +**Why?** The template points to a path **outside** the WP Code Check directory, and you're using relative paths. |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## ✅ The Solution (3 Steps) |
| 20 | + |
| 21 | +### Step 1: Ask for WP Code Check Location |
| 22 | + |
| 23 | +``` |
| 24 | +"Where is WP Code Check installed? (e.g., /Users/noelsaw/Sites/wp-code-check)" |
| 25 | +``` |
| 26 | + |
| 27 | +### Step 2: Make Scripts Executable |
| 28 | + |
| 29 | +```bash |
| 30 | +chmod +x /path/to/wp-code-check/dist/bin/run |
| 31 | +chmod +x /path/to/wp-code-check/dist/bin/check-performance.sh |
| 32 | +``` |
| 33 | + |
| 34 | +### Step 3: Use Absolute Path |
| 35 | + |
| 36 | +```bash |
| 37 | +/path/to/wp-code-check/dist/bin/run my-plugin |
| 38 | +``` |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## 📋 Complete Example |
| 43 | + |
| 44 | +```bash |
| 45 | +# User wants to scan a plugin at: /Users/noelsaw/Sites/my-plugin |
| 46 | +# WP Code Check is at: /Users/noelsaw/Tools/wp-code-check |
| 47 | +# Template file: /Users/noelsaw/Tools/wp-code-check/dist/TEMPLATES/my-plugin.txt |
| 48 | + |
| 49 | +# Step 1: Set WP Code Check path |
| 50 | +WP_CODE_CHECK="/Users/noelsaw/Tools/wp-code-check" |
| 51 | + |
| 52 | +# Step 2: Make executable |
| 53 | +chmod +x "$WP_CODE_CHECK/dist/bin/run" |
| 54 | + |
| 55 | +# Step 3: Run template |
| 56 | +"$WP_CODE_CHECK/dist/bin/run" my-plugin |
| 57 | +``` |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## 🔧 Troubleshooting Checklist |
| 62 | + |
| 63 | +Before running any template: |
| 64 | + |
| 65 | +- [ ] Do you know where WP Code Check is installed? |
| 66 | +- [ ] Does the template file exist? (`ls $WP_CODE_CHECK/dist/TEMPLATES/my-plugin.txt`) |
| 67 | +- [ ] Is the `run` script executable? (`ls -lh $WP_CODE_CHECK/dist/bin/run`) |
| 68 | +- [ ] Are you using an absolute path to the script? |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## 🎯 Quick Commands |
| 73 | + |
| 74 | +### Find WP Code Check installation: |
| 75 | +```bash |
| 76 | +find ~ -name "check-performance.sh" -path "*/wp-code-check/dist/bin/*" 2>/dev/null | head -1 |
| 77 | +``` |
| 78 | + |
| 79 | +### List available templates: |
| 80 | +```bash |
| 81 | +ls -1 /path/to/wp-code-check/dist/TEMPLATES/*.txt | xargs -n1 basename |
| 82 | +``` |
| 83 | + |
| 84 | +### Make all scripts executable: |
| 85 | +```bash |
| 86 | +chmod +x /path/to/wp-code-check/dist/bin/* |
| 87 | +``` |
| 88 | + |
| 89 | +### Test if script works: |
| 90 | +```bash |
| 91 | +/path/to/wp-code-check/dist/bin/check-performance.sh --help |
| 92 | +``` |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +## ❌ Common Mistakes |
| 97 | + |
| 98 | +### Mistake 1: Using Relative Paths |
| 99 | +```bash |
| 100 | +# ❌ DON'T |
| 101 | +./dist/bin/run my-plugin |
| 102 | + |
| 103 | +# ✅ DO |
| 104 | +/full/path/to/wp-code-check/dist/bin/run my-plugin |
| 105 | +``` |
| 106 | + |
| 107 | +### Mistake 2: Assuming Current Directory |
| 108 | +```bash |
| 109 | +# ❌ DON'T assume WP Code Check is in current directory |
| 110 | +cd /Users/noelsaw/Sites/my-plugin |
| 111 | +./dist/bin/run my-plugin # This won't work! |
| 112 | + |
| 113 | +# ✅ DO use absolute path |
| 114 | +/Users/noelsaw/Tools/wp-code-check/dist/bin/run my-plugin |
| 115 | +``` |
| 116 | + |
| 117 | +### Mistake 3: Ignoring Permissions |
| 118 | +```bash |
| 119 | +# ❌ DON'T just run without checking |
| 120 | +/path/to/run my-plugin |
| 121 | + |
| 122 | +# ✅ DO check and fix permissions first |
| 123 | +chmod +x /path/to/run |
| 124 | +/path/to/run my-plugin |
| 125 | +``` |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +## 🤖 AI Agent Template |
| 130 | + |
| 131 | +Copy this workflow for running templates: |
| 132 | + |
| 133 | +```bash |
| 134 | +#!/bin/bash |
| 135 | +# AI Agent Workflow for Running WP Code Check Templates |
| 136 | + |
| 137 | +# Configuration |
| 138 | +TEMPLATE_NAME="$1" # e.g., "my-plugin" |
| 139 | +WP_CODE_CHECK="${WP_CODE_CHECK:-/path/to/wp-code-check}" # Ask user if not set |
| 140 | + |
| 141 | +# Validation |
| 142 | +if [ -z "$TEMPLATE_NAME" ]; then |
| 143 | + echo "❌ Error: Please specify a template name" |
| 144 | + echo "Usage: run-template <template-name>" |
| 145 | + exit 1 |
| 146 | +fi |
| 147 | + |
| 148 | +if [ ! -d "$WP_CODE_CHECK" ]; then |
| 149 | + echo "❌ Error: WP Code Check not found at: $WP_CODE_CHECK" |
| 150 | + echo "Please set WP_CODE_CHECK environment variable or provide the path" |
| 151 | + exit 1 |
| 152 | +fi |
| 153 | + |
| 154 | +# Check template exists |
| 155 | +TEMPLATE_FILE="$WP_CODE_CHECK/dist/TEMPLATES/${TEMPLATE_NAME}.txt" |
| 156 | +if [ ! -f "$TEMPLATE_FILE" ]; then |
| 157 | + echo "❌ Error: Template not found: $TEMPLATE_FILE" |
| 158 | + echo "" |
| 159 | + echo "Available templates:" |
| 160 | + ls -1 "$WP_CODE_CHECK/dist/TEMPLATES/"*.txt 2>/dev/null | xargs -n1 basename | sed 's/\.txt$//' |
| 161 | + exit 1 |
| 162 | +fi |
| 163 | + |
| 164 | +# Make executable |
| 165 | +chmod +x "$WP_CODE_CHECK/dist/bin/run" 2>/dev/null |
| 166 | +chmod +x "$WP_CODE_CHECK/dist/bin/check-performance.sh" 2>/dev/null |
| 167 | + |
| 168 | +# Run |
| 169 | +echo "🚀 Running WP Code Check template: $TEMPLATE_NAME" |
| 170 | +"$WP_CODE_CHECK/dist/bin/run" "$TEMPLATE_NAME" |
| 171 | +``` |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +## 📚 Full Documentation |
| 176 | + |
| 177 | +For complete details, see: |
| 178 | +- **[_AI_INSTRUCTIONS.md](_AI_INSTRUCTIONS.md)** - Complete AI agent guide |
| 179 | +- **[README.md](README.md)** - User documentation |
| 180 | + |
| 181 | +--- |
| 182 | + |
| 183 | +## 💡 Pro Tips |
| 184 | + |
| 185 | +1. **Always ask the user** where WP Code Check is installed |
| 186 | +2. **Verify paths exist** before running commands |
| 187 | +3. **Check permissions** before executing scripts |
| 188 | +4. **Use absolute paths** for everything |
| 189 | +5. **Provide helpful error messages** when things fail |
| 190 | + |
| 191 | +--- |
| 192 | + |
| 193 | +**Remember:** WP Code Check can be installed anywhere, and templates can point to paths anywhere. Never assume relative paths will work! |
| 194 | + |
0 commit comments