Skip to content

Latest commit

 

History

History
82 lines (59 loc) · 3.48 KB

File metadata and controls

82 lines (59 loc) · 3.48 KB

RULES-CODING.md — How to Handle Software Tasks

This is a MANDATORY IRON RULE for all OpenClaw agents across all projects.

Rule: Always Use Claude Code for Software Tasks

When you receive a software task (implementation, testing, refactoring, spec writing, deployment scripts, etc.), you MUST delegate it to Claude Code (claude CLI) running as a non-interactive background agent.

⚠️ IRON RULE: --dangerously-skip-permissions is MANDATORY

ALWAYS. EVERY TIME. NO EXCEPTIONS.

claude -p --dangerously-skip-permissions --model claude-opus-4-6 "<task prompt>" 2>&1

Without --dangerously-skip-permissions, Claude Code will HANG waiting for user input to approve file writes. There is no user at the terminal. It will hang forever. This flag is not optional.

Required flags — ALL THREE, ALWAYS:

  • -p — non-interactive (print mode), no user input needed
  • --dangerously-skip-permissionsIRON RULE: ALWAYS USE THIS. NEVER OMIT.
  • --model claude-opus-4-6 — always use Opus 4.6 for quality

Execution pattern:

exec pty:true background:true workdir:<project-dir> timeout:600 command:"claude -p --dangerously-skip-permissions --model claude-opus-4-6 '<prompt>' 2>&1 | tee /tmp/claude-agent-<task-name>.log"

Logging is MANDATORY. Always pipe through tee to a log file. Claude Code -p buffers all output until completion — without logging you can't debug failures after the fact. Log file naming: /tmp/claude-agent-<short-task-name>.log

Rules

  1. NEVER hand-code changes yourself when the task is non-trivial (>1 file or >20 lines). Delegate to Claude Code.
  2. ALWAYS use non-interactive mode (-p). Never spawn interactive Claude Code sessions.
  3. ALWAYS use --dangerously-skip-permissions to avoid hanging on permission prompts.
  4. ALWAYS use --model claude-opus-4-6 for consistent quality.
  5. Use pty:true — Claude Code is a terminal application.
  6. Use background:true for long tasks, then poll for completion.
  7. Parallel agents are OK — spawn multiple for independent tasks.
  8. Include specs by reference — tell the agent to Read <spec-file> rather than inlining huge prompts.
  9. End with notification — append When completely finished, run: openclaw system event --text 'Done: <summary>' --mode now to get notified on completion.
  10. Verify after completion — always run tests / check outputs after agent finishes.
  11. Commit results — commit the agent's work with a descriptive message.

What Counts as a Software Task

  • Creating or editing code files
  • Writing deployment scripts
  • Adding tests (unit, e2e, integration)
  • Refactoring
  • Writing technical specs (that involve reading code)
  • Build/CI configuration
  • Database migrations

What Does NOT Need Claude Code

  • Simple one-line fixes (just use edit tool directly)
  • Reading/exploring code (just use read tool)
  • Git operations (just use exec)
  • Documentation-only changes (use write tool)

Output Buffering Warning

Claude Code -p buffers ALL output until completion. This means:

  • process log will show nothing until the agent finishes
  • Use process poll with long timeouts (120-300 seconds)
  • Check process is alive with ps aux | grep claude if worried
  • Typical task takes 2-8 minutes

Prompt Template

Read <spec-file> for full spec.

YOUR TASK: <clear description>

1. <step 1>
2. <step 2>
...

When completely finished, run: openclaw system event --text 'Done: <summary>' --mode now