Coding Agent (Bash-First)
Use the exec command—always with background: true, pty: true, and timeout: 86400—to launch a Claude Code Agent for all coding work, as well as most general-purpose technical tasks. Simple and effective.
Important Notes:
- •Always use
pty: true— Claude Code agents require a terminal environment to function properly. - •The
execcommand has a default timeout of 1800 seconds (30 minutes). However, Claude Code is designed to handle much longer runs. Set the timeout to a large value such as 86400 (24 hours). Be patient—do not terminate sessions merely because they appear "slow." - •Since
execmay occasionally fail to correctly parse extremely long command strings, the best practice is to first write your full task instructions into a file (e.g.,~/.openclaw/workspace/claude_tasks/task_YYMMDD_hhmmss.txt), then give Claude Code a concise instruction like:
'Read /absolute/path/to/task_xxx.txt for work details.'(See example below.) - •Use the
processtool to query task status. Monitor progress viaprocess:log.
Claude Code CLI Best Practices
Workflow Guidelines
- •
Write a comprehensive task description to a timestamped file using the
writetool. Use a descriptive filename such as:/absolute/path/to/task_20260101_140721_some_job.txtImportant Note: You MUST include all of the following elements in your task description (see the next section for an example):
- •Length: Do not exceed 2000 words.
- •Content: Include necessary background, the overall objective, a brief idea or approach, important notes and requirements, and a clear list of deliverables.
- •Focus on the "What": Define what needs to be done, but never provide a sample solution or pre-written code. Let Claude Code handle all implementation details.
- •Notification: Explicitly require the agent to notify you upon task completion; otherwise, tasks may end silently.
- •Logging: Require that any experiments or scripts log their intermediate results and outputs to files, allowing you to review the agent's progress.
- •Reporting: Require the generation of a final summary report.
- •
Launch the agent using the
exectool with the required flags (background: true,pty: true,timeout: 86400):bashcd /path/to/project && claude 'Read /absolute/path/to/task_xxx.txt for work details.' --allowedTools 'Bash,Read,Edit,Write,WebFetch'
- •
Monitor progress regularly using the
process:logtool. Also check the code repo to see code modification and result file generated by Claude Code. Add a follow-up item toHEARTBEAT.mdfor later verification, and provide periodic updates to the user. Be patient—Claude Code tasks can take a long time (it's normal for complex tasks to take over an hour, especially when many comparative experiments are involved). Check result in repo, Claude may not inform you directly - •
Following Actions If you need to provide additional instructions or clarifications to a running Claude Code session (e.g., adding a brief requirement or asking it to re-read the task file), use the
process:submittool (notprocess:write, which only writes to the session input buffer without triggering submission).
Key Instructions to Include in Your Task Description
1. Final Notification Instruction: Include the following at the end of your task description to ensure Claude Code notifies you upon completion:
When completely finished, run this command to inform me: openclaw gateway wake --text "(Claude Code's return message or next step suggestions)" --mode now
2. Logging Instruction for Experiments/Scripts: If your task involves running experiments or scripts, include the following to ensure progress is visible:
When running any scripts (e.g., Python), ensure they log key steps, output intermediate results, and print final data to a well-named file (e.g., by running `python3 your_script.py > experiment_log_YYYYMMDD_HHMMSS.txt`).
3. Instruction for Long-Running Experiments: If your task involves experiments that are expected to run for an extended duration, include the following to instruct Claude Code to report intermediate results promptly:
For long-running experiments, execute them in incremental stages. After each stage, save and report intermediate results (e.g., metrics, checkpoints, or logs) before proceeding to the next stage. Do not wait until the entire experiment finishes to provide updates.
What Can Claude Code Do?
You can delegate virtually any technical or analytical task to Claude Code—from professional software engineering to orchestrating multi-hour experiments. Its capabilities include:
🧑💻 Professional Coding & Development
- •Build full applications from scratch or extend existing codebases
- •Refactor and optimize code for performance, readability, or maintainability
- •Debug issues by analyzing logs and tracing root causes
- •Write comprehensive tests (unit, integration, E2E) and documentation
- •Implement APIs, data pipelines, and automation scripts
🔬 Experimentation & Analysis
- •Run multi-step experiments with automated data collection and validation
- •Clean, transform, and analyze datasets (including statistical analysis)
- •Generate visualizations and reports to communicate insights
- •Simulate scenarios or model complex systems
- •Monitor long-running processes and handle intermediate outputs
🛠️ System & DevOps Tasks
- •Configure development environments and CI/CD pipelines
- •Manage infrastructure using Infrastructure-as-Code (IaC) templates
- •Automate repetitive workflows across platforms
- •Perform large-scale file operations (batch renaming, format conversion, etc.)
- •Interact programmatically with databases, APIs, and external services
📚 Learning & Exploration
- •Research technical topics by exploring documentation and real-world examples
- •Create tutorials, demos, or interactive learning materials
- •Rapidly prototype new ideas to validate feasibility
- •Compare technologies through benchmark implementations