Skip to content

owenob1/prompt-improver / skills/prompt-improver

prompt-improver

Verified

Transform vague prompts into precise, verifiable structured XML prompts that coding agents execute reliably. Modes: execute (default — generate then run) and plan (generate XML for review first). Use when the user says improve prompt, make this work better, prompt engineer, structure a request, plan a complex change before coding, or when a rough request needs verification criteria before execution. Do not use when the input is already a well-structured XML prompt or detailed implementation spec — skip generation and execute directly.

FileKindSize
SKILL.mdskill md10.8 KB
assets/generation-agent-prompt.mdmarkdown8.7 KB
config/runtime-defaults.jsonconfig13.5 KB
config/settings.default.jsonconfig4.6 KB
config/settings.example.jsonconfig4.8 KB
examples/before-after.mdmarkdown23.5 KB
examples/fixtures/invalid-prompt.xmlconfig176 B
examples/fixtures/valid-prompt.xmlconfig1.7 KB
references/models-supported.mdmarkdown10.1 KB
references/prompt-chaining.mdmarkdown7.2 KB
references/prompting-principles.mdmarkdown21.6 KB
references/xml-template.mdmarkdown12.0 KB
scripts/assemble-generation-prompt.shexecutablescript4.2 KB
scripts/backends/agy.shexecutablescript815 B
scripts/backends/amp.shexecutablescript708 B
scripts/backends/claude.shexecutablescript1.2 KB
scripts/backends/cline.shexecutablescript1.0 KB
scripts/backends/codex.shexecutablescript2.0 KB
scripts/backends/copilot.shexecutablescript860 B
scripts/backends/cursor.shexecutablescript785 B
scripts/backends/droid.shexecutablescript693 B
scripts/backends/gemini.shexecutablescript1.3 KB
scripts/backends/grok.shexecutablescript1.4 KB
scripts/backends/kimi.shexecutablescript879 B
scripts/backends/kiro.shexecutablescript750 B
scripts/backends/opencode.shexecutablescript694 B
scripts/backends/qwen.shexecutablescript936 B
scripts/gather-context.shexecutablescript10.8 KB
scripts/generate-prompt.shexecutablescript20.0 KB
scripts/lib/backend-common.shscript4.8 KB
scripts/lib/settings.shexecutablescript36.0 KB
scripts/smoke-test.shexecutablescript40.1 KB
scripts/standalone-improve.shexecutablescript995 B
scripts/validate-prompt.shexecutablescript11.7 KB

scripts/gather-context.sh

View on GitHub
#!/usr/bin/env bash
# gather-context.sh
# Deterministic project context for prompt enrichment.
# Shell-only: fixed path probes, package manifests, git metadata.
# Does NOT run AI, grep the tree recursively, or glob-search for source.
# Usage: bash gather-context.sh [project-root]

set -euo pipefail

ROOT="${1:-.}"
cd "$ROOT"

# Bound external tools so a slow package manager can't stall prompt generation.
_bounded() {
  if command -v timeout >/dev/null 2>&1; then
    timeout 15 "$@"
  elif command -v gtimeout >/dev/null 2>&1; then
    gtimeout 15 "$@"
  else
    "$@"
  fi
}

# python3 that actually runs (macOS ships a /usr/bin/python3 stub without CLT).
_have_python() {
  command -v python3 >/dev/null 2>&1 && python3 -c 'pass' >/dev/null 2>&1
}

echo "=== PROJECT CONTEXT (deterministic) ==="

# Tech stack detection
echo ""
echo "--- TECH STACK ---"

# Detect monorepo
echo ""
echo "--- MONOREPO ---"
if [ -f "turbo.json" ]; then
  echo "Monorepo: Turborepo"
elif [ -f "pnpm-workspace.yaml" ]; then
  echo "Monorepo: pnpm workspaces"
elif [ -f "nx.json" ]; then
  echo "Monorepo: Nx"
elif [ -f "lerna.json" ]; then
  echo "Monorepo: Lerna"
else
  echo "Monorepo: no"
fi

# List workspaces if monorepo
if [ -f "pnpm-workspace.yaml" ] && command -v pnpm &>/dev/null && _have_python; then
  echo "Workspaces:"
  _bounded pnpm ls --depth -1 --json 2>/dev/null | python3 -c "
import sys, json
try:
    data = json.load(sys.stdin)
    for pkg in data:
        print(f'  - {pkg.get(\"name\", \"unknown\")}')
except: pass
" 2>/dev/null || echo "  (could not list workspaces)"
elif [ -f "package.json" ] && _have_python; then
  # Check for yarn/npm workspaces in package.json
  python3 -c "
import sys, json
try:
    pkg = json.load(open('package.json'))
    workspaces = pkg.get('workspaces', [])
    if isinstance(workspaces, dict):
        workspaces = workspaces.get('packages', [])
    if workspaces:
        print('Workspaces:')
        for w in workspaces:
            print(f'  - {w}')
except: pass
" 2>/dev/null || true
fi

if [ -f "package.json" ]; then
  echo "Platform: Node.js"
  echo "Dependencies:"
  if command -v jq &>/dev/null; then
    jq -r '
      (.dependencies // {}) + (.devDependencies // {}) |
      to_entries[] |
      select(.key | test("^(next|react|vue|svelte|angular|astro|express|fastify|hono|remix|nuxt|typescript|tailwindcss|prisma|drizzle-orm|supabase|vitest|jest|playwright|cypress)$")) |
      "  \(.key): \(.value)"
    ' package.json 2>/dev/null || echo "  (could not parse with jq)"
  elif _have_python; then
    cat package.json | python3 -c "
import sys, json
try:
    pkg = json.load(sys.stdin)
    deps = {**pkg.get('dependencies', {}), **pkg.get('devDependencies', {})}
    key_frameworks = ['next', 'react', 'vue', 'svelte', 'angular', 'astro', 'express', 'fastify', 'hono', 'remix', 'nuxt']
    key_tools = ['typescript', 'tailwindcss', 'prisma', 'drizzle-orm', 'supabase', 'vitest', 'jest', 'playwright', 'cypress']
    found = [k for k in deps if k in key_frameworks + key_tools]
    for f in found:
        print(f'  {f}: {deps[f]}')
    if not found:
        for k, v in list(deps.items())[:15]:
            print(f'  {k}: {v}')
except:
    print('  (could not parse package.json)')
" 2>/dev/null
  else
    echo "  (neither jq nor python3 available)"
  fi
fi

if [ -f "tsconfig.json" ]; then
  echo "TypeScript config:"
  if command -v jq &>/dev/null; then
    jq -r '.compilerOptions | "  target: \(.target // "not set"), module: \(.module // "not set"), strict: \(.strict // "not set")"' tsconfig.json 2>/dev/null || echo "  (could not parse tsconfig.json)"
  else
    echo "  (tsconfig.json present, install jq for details)"
  fi
fi

if [ -f "pyproject.toml" ]; then
  echo "Platform: Python"
  head -20 pyproject.toml
fi

if [ -f "Cargo.toml" ]; then
  echo "Platform: Rust"
  head -20 Cargo.toml
fi

if [ -f "go.mod" ]; then
  echo "Platform: Go"
  head -10 go.mod
fi

if [ -f "bun.lockb" ] || [ -f "bunfig.toml" ]; then
  echo "Runtime: Bun"
fi

if [ -f "deno.json" ] || [ -f "deno.lock" ]; then
  echo "Runtime: Deno"
fi

# .NET: only probe a few common fixed filenames (no shell globs over the tree)
_dotnet=false
for _f in App.csproj Project.csproj src/App.csproj; do
  if [ -f "$_f" ]; then _dotnet=true; break; fi
done
if [ "$_dotnet" = false ] && [ -f "global.json" ]; then
  _dotnet=true
fi
if [ "$_dotnet" = true ]; then
  echo "Platform: .NET (manifest markers present)"
fi
unset _dotnet _f

if [ -f "pom.xml" ]; then
  echo "Platform: Java (Maven)"
elif [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then
  echo "Platform: Java (Gradle)"
fi

# Agent instruction files (multi-CLI)
echo ""
echo "--- AGENT INSTRUCTIONS ---"
FOUND_AGENT_MD=false
# Parent-level files are read only from the enclosing git repo root, never
# from arbitrary directories above the project.
GIT_TOP=$(git rev-parse --show-toplevel 2>/dev/null || true)
[ "$GIT_TOP" = "$(pwd -P)" ] && GIT_TOP=""
for f in CLAUDE.md AGENTS.md .cursorrules; do
  if [ -f "$f" ]; then
    echo "Found: $f"
    head -40 "$f"
    FOUND_AGENT_MD=true
  elif [ -n "$GIT_TOP" ] && [ -f "$GIT_TOP/$f" ]; then
    echo "Found: (repo root) $f"
    head -40 "$GIT_TOP/$f"
    FOUND_AGENT_MD=true
  fi
done
if [ "$FOUND_AGENT_MD" = false ]; then
  echo "(none found)"
fi

# Configuration files
echo ""
echo "--- CONFIGURATION ---"
[ -f ".claude/CLAUDE.md" ] && echo "Claude Code: project CLAUDE.md found"
[ -f "AGENTS.md" ] && echo "Agents: AGENTS.md found"
{ [ -f ".env.example" ] || [ -f ".env.template" ]; } && echo "Environment: .env template found"
{ [ -f ".eslintrc.js" ] || [ -f ".eslintrc.json" ] || [ -f "eslint.config.js" ] || [ -f "eslint.config.mjs" ]; } && echo "Linter: ESLint"
{ [ -f "biome.json" ] || [ -f "biome.jsonc" ]; } && echo "Linter: Biome"
{ [ -f ".prettierrc" ] || [ -f ".prettierrc.json" ] || [ -f "prettier.config.js" ]; } && echo "Formatter: Prettier"
{ [ -f "Dockerfile" ] || [ -f "docker-compose.yml" ] || [ -f "docker-compose.yaml" ]; } && echo "Container: Docker"
[ -d ".github/workflows" ] && echo "CI/CD: GitHub Actions"
{ [ -f "wrangler.toml" ] || [ -f "wrangler.jsonc" ]; } && echo "Deploy: Cloudflare Workers"
[ -f "vercel.json" ] && echo "Deploy: Vercel"
[ -f "netlify.toml" ] && echo "Deploy: Netlify"

# Claude Code project detection
echo ""
echo "--- CLAUDE CODE ---"
if [ -d ".claude/skills" ]; then
  echo "Project skills:"
  for skill in .claude/skills/*/SKILL.md; do
    [ -f "$skill" ] && echo "  - $(dirname "$skill" | xargs basename)"
  done
fi

if [ -d ".claude/agents" ]; then
  echo "Custom agents:"
  for agent in .claude/agents/*.md; do
    [ -f "$agent" ] && echo "  - $(basename "$agent" .md)"
  done
fi

if [ -d ".claude/commands" ]; then
  echo "Custom commands:"
  for cmd in .claude/commands/*.md; do
    [ -f "$cmd" ] && echo "  - /$(basename "$cmd" .md)"
  done
fi

# Top-level names only (no recursive find/glob search)
echo ""
echo "--- STRUCTURE (top-level only) ---"
if [ -d . ]; then
  # shellcheck disable=SC2012
  # Capture first, then walk: `ls | head` SIGPIPEs ls in big dirs under pipefail.
  _names=$(ls -1A 2>/dev/null || true)
  _shown=0
  while IFS= read -r name; do
    [ -z "$name" ] && continue
    [ "$_shown" -ge 60 ] && break
    _shown=$((_shown + 1))
    case "$name" in
      .|..|node_modules|.git|dist|build|.next|__pycache__|.venv|target) continue ;;
    esac
    if [ -d "$name" ]; then
      echo "  dir  $name/"
    else
      echo "  file $name"
    fi
  done <<<"$_names"
fi

# Recent git activity (deterministic metadata only)
echo ""
echo "--- RECENT CHANGES ---"
if git rev-parse --is-inside-work-tree &>/dev/null 2>&1; then
  git log --oneline -5 2>/dev/null || echo "(no git history)"
  echo ""
  echo "Recently modified files (git):"
  if _changed=$(git diff --name-only HEAD~5 HEAD 2>/dev/null); then
    sed -n '1,15p' <<<"$_changed"
  else
    echo "(insufficient history)"
  fi
else
  echo "(not a git repository)"
fi

# Test runner config files only (no recursive test-file search)
echo ""
echo "--- TEST PATTERNS ---"
if [ -f "vitest.config.ts" ] || [ -f "vitest.config.js" ]; then
  echo "Test runner: Vitest"
elif [ -f "jest.config.ts" ] || [ -f "jest.config.js" ]; then
  echo "Test runner: Jest"
elif [ -f "pytest.ini" ] || [ -f "pyproject.toml" ]; then
  echo "Test runner: pytest (likely)"
else
  echo "Test runner: (not detected from config files)"
fi

# Typecheck command detection
echo ""
echo "--- TYPECHECK COMMAND ---"
if [ -f "tsconfig.json" ]; then
  echo "npx tsc --noEmit"
elif [ -f "pyproject.toml" ]; then
  if grep -q 'mypy' pyproject.toml 2>/dev/null; then
    echo "mypy ."
  elif grep -q 'pyright' pyproject.toml 2>/dev/null; then
    echo "pyright"
  else
    echo "(no typecheck detected)"
  fi
elif [ -f "go.mod" ]; then
  echo "go vet ./..."
elif [ -f "Cargo.toml" ]; then
  echo "cargo check"
else
  echo "(no typecheck detected)"
fi

# Test command detection
echo ""
echo "--- TEST COMMAND ---"
TEST_CMD_FOUND=false
if [ -f "vitest.config.ts" ] || [ -f "vitest.config.js" ]; then
  echo "npx vitest run"
  TEST_CMD_FOUND=true
elif [ -f "jest.config.ts" ] || [ -f "jest.config.js" ]; then
  echo "npx jest"
  TEST_CMD_FOUND=true
elif [ -f "pytest.ini" ]; then
  echo "pytest"
  TEST_CMD_FOUND=true
elif [ -f "pyproject.toml" ] && grep -q 'pytest' pyproject.toml 2>/dev/null; then
  echo "pytest"
  TEST_CMD_FOUND=true
elif [ -f "Cargo.toml" ]; then
  echo "cargo test"
  TEST_CMD_FOUND=true
elif [ -f "go.mod" ]; then
  echo "go test ./..."
  TEST_CMD_FOUND=true
fi
if [ "$TEST_CMD_FOUND" = false ] && [ -f "package.json" ]; then
  TEST_SCRIPT=""
  if command -v jq &>/dev/null; then
    TEST_SCRIPT=$(jq -r '.scripts.test // ""' package.json 2>/dev/null)
  elif _have_python; then
    TEST_SCRIPT=$(python3 -c "import json; pkg=json.load(open('package.json')); print(pkg.get('scripts',{}).get('test',''))" 2>/dev/null || true)
  fi
  if [ -n "$TEST_SCRIPT" ] && ! grep -q 'echo.*Error' <<<"$TEST_SCRIPT"; then
    echo "$TEST_SCRIPT"
    TEST_CMD_FOUND=true
  fi
fi
if [ "$TEST_CMD_FOUND" = false ]; then
  echo "(no test command detected)"
fi

# Build command detection
echo ""
echo "--- BUILD COMMAND ---"
BUILD_CMD_FOUND=false
if [ -f "package.json" ]; then
  BUILD_SCRIPT=""
  if command -v jq &>/dev/null; then
    BUILD_SCRIPT=$(jq -r '.scripts.build // ""' package.json 2>/dev/null)
  elif _have_python; then
    BUILD_SCRIPT=$(python3 -c "import json; pkg=json.load(open('package.json')); print(pkg.get('scripts',{}).get('build',''))" 2>/dev/null || true)
  fi
  if [ -n "$BUILD_SCRIPT" ]; then
    echo "$BUILD_SCRIPT"
    BUILD_CMD_FOUND=true
  fi
fi
if [ "$BUILD_CMD_FOUND" = false ] && [ -f "Cargo.toml" ]; then
  echo "cargo build"
  BUILD_CMD_FOUND=true
elif [ "$BUILD_CMD_FOUND" = false ] && [ -f "go.mod" ]; then
  echo "go build ./..."
  BUILD_CMD_FOUND=true
fi
if [ "$BUILD_CMD_FOUND" = false ]; then
  echo "(no build command detected)"
fi

# Intentionally no recursive find/grep/glob and no AI/index explorers.
# Context stays reproducible across runs for the same tree metadata.

echo ""
echo "=== END CONTEXT ==="
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall