diff --git a/bin/claude-code b/bin/claude-code index 59788a1..7246f63 100755 --- a/bin/claude-code +++ b/bin/claude-code @@ -1,19 +1,10 @@ -#!/bin/bash -# Wrapper that sets ANTHROPIC_API_KEY from OpenClaw's auth config -export ANTHROPIC_API_KEY=$(python3 -c " -import json -with open('/home/openclaw/.openclaw/agents/main/agent/auth-profiles.json') as f: - data = json.load(f) -for key, profile in data.get('profiles', {}).items(): - if 'anthropic' in key: - print(profile.get('token', '')) - break -" 2>/dev/null) +#!/usr/bin/env bash +# Claude Code CLI wrapper +# Usage: claude-code "task description" [working-dir] +set -euo pipefail -if [ -z "$ANTHROPIC_API_KEY" ]; then - echo "Error: Could not extract Anthropic API key from auth-profiles.json" - exit 1 -fi +TASK="${1:?Usage: claude-code [working-dir]}" +WORKDIR="${2:-$(pwd)}" -export PATH=$PATH:/usr/local/go/bin -exec claude "$@" +cd "$WORKDIR" +exec claude -p "$TASK" --allowedTools "Edit,Write,Bash" diff --git a/debug_health_orb.png b/debug_health_orb.png new file mode 100644 index 0000000..93eea36 Binary files /dev/null and b/debug_health_orb.png differ diff --git a/debug_mana_orb.png b/debug_mana_orb.png new file mode 100644 index 0000000..1f0077c Binary files /dev/null and b/debug_mana_orb.png differ diff --git a/projects/iso-bot b/projects/iso-bot index 67f2e55..0716aeb 160000 --- a/projects/iso-bot +++ b/projects/iso-bot @@ -1 +1 @@ -Subproject commit 67f2e5536aba342d3108cecdac29d3839cbd6dac +Subproject commit 0716aeb5e13a100a632eff255e33f840240f0715 diff --git a/skills/coding-agent/NOTES.md b/skills/coding-agent/NOTES.md new file mode 100644 index 0000000..5f7eb05 --- /dev/null +++ b/skills/coding-agent/NOTES.md @@ -0,0 +1,50 @@ +# Claude Code Usage Notes + +## Golden Rule +**User gives task → spawn sub-agent → sub-agent runs Claude Code → sub-agent verifies → user gets ONE summary message. No play-by-play.** + +## How to Use Claude Code + +### Via Sub-Agent (preferred for complex tasks) +``` +sessions_spawn with task like: +"Run Claude Code to [task]. Working dir: /path/to/project. +After Claude Code finishes, verify the changes compile and make sense. +If not, run Claude Code again with fixes. Commit and push when done." +``` + +### Direct (simple tasks only) +```bash +cd /path/to/project +claude -p "task description" --allowedTools "Edit,Write,Bash" +``` + +## Key Facts +- **Default model**: Opus 4.6 (no override needed) +- **Auth**: OAuth login already completed, no API key needed +- **Allowed tools**: Always pass `--allowedTools "Edit,Write,Bash"` +- **Timeout**: Claude Code can take 5-20 minutes for complex tasks. Don't micromanage. +- **Hanging**: Sometimes streams hang after ~10-15 min. Sub-agent can detect this and retry. +- **PTY mode**: Use `pty=true` when running via exec + +## Sub-Agent Task Template +``` +Run Claude Code CLI in /path/to/project to do the following: + +[TASK DESCRIPTION] + +Steps: +1. Run: cd /path/to/project && claude -p "[task]" --allowedTools "Edit,Write,Bash" +2. Wait for completion (up to 20 min, check if process is still alive periodically) +3. If it hangs (no file changes for 10+ min), kill and retry once +4. After completion, verify: go build / npm build / etc +5. If build fails, run Claude Code again with the error +6. Commit and push when everything works +7. Report summary of all changes made +``` + +## Anti-Patterns +- ❌ Polling every 30 seconds and reporting progress +- ❌ Sending WhatsApp messages during the process +- ❌ Reading every file before/after to narrate changes +- ✅ Fire and forget, verify at end, report once