1
0
Fork 0

feat: initial companion repo for OpenClaw vs Claude Code article

40 files demonstrating every major OpenClaw capability using Claude Code:
- 3 agents (researcher, writer, reviewer)
- 3 skills (daily-briefing, slack-message, web-research)
- 2 security hooks (pre-tool-use blocker, post-tool-use logger)
- 10 self-contained examples with copy-paste prompts
- Complete feature map (20 capabilities, 11 full match, 7 different, 2 gap)
- Security docs including NemoClaw comparison
- Automation, messaging, browser, memory documentation

Zero dependencies. Clone and run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-03-26 09:47:29 +01:00
commit 2491f5c732
40 changed files with 2037 additions and 0 deletions

View file

@ -0,0 +1,49 @@
# Example 01: Agent Runtime
**Capability:** Claude Code executes tools autonomously, streams output as it works,
and loops until the task is complete. No user input needed between steps.
**OpenClaw equivalent:** Long-running daemon with tool execution and streaming output.
---
## The Prompt
```
Research the top 3 AI frameworks released this month, compare their GitHub stars,
and write a summary to research-output.md
For each framework include:
- Name and release date
- GitHub URL and current star count
- One sentence on what problem it solves
- Your verdict on whether it's worth watching
End the file with a "Verdict" section that ranks all three.
```
---
## What Happens
Claude Code will:
1. Use WebSearch to find AI framework releases from the current month
2. Use WebFetch to retrieve GitHub pages and extract star counts
3. Loop through each framework, gathering data tool call by tool call
4. Use Write to create `research-output.md` with the structured summary
5. Report completion with a summary of what was written
You will see each tool call streamed as it happens. Claude does not ask for
confirmation between steps unless it hits something ambiguous.
---
## Why This Matters
This is the agent loop in action: plan, execute, observe, repeat. The same
loop that runs a 300-step pipeline also runs this 5-step research task.
The difference is only scale.
Claude Code v2.1.84 added adaptive thinking, which adjusts reasoning depth
automatically. Complex sub-tasks get more thought; simple ones proceed fast.

View file

@ -0,0 +1,50 @@
# Example 02: Shell Execution and File I/O
**Capability:** Claude Code runs shell commands and reads/writes files as part of the
same task. Shell output becomes input to the next step automatically.
**OpenClaw equivalent:** `exec` tool with PTY support + read/write/edit file tools.
---
## The Prompt
```
Create a directory called 'project-scaffold', add these files inside it:
1. package.json with name "my-project", version "0.1.0", and description
"A scaffolded project created by Claude Code"
2. README.md with a project overview section and a "Getting Started" section
with placeholder install instructions
3. .gitignore for Node.js (node_modules, .env, dist, .DS_Store)
Then run 'find project-scaffold -type f' to verify all three files exist
and show me the contents of package.json.
```
---
## What Happens
Claude Code will:
1. Use Bash to run `mkdir project-scaffold`
2. Use Write to create each of the three files
3. Use Bash to run `find project-scaffold -type f` and capture the output
4. Use Read to show the contents of `package.json`
5. Report back with the directory tree and file verification
---
## Why This Matters
Shell execution and file I/O are the foundation of every automation. Claude Code
handles both in the same task context, so shell output can feed directly into
file content decisions.
The permission system controls what shell commands are allowed. In the
`settings.json` in this repo, `rm -rf` and a handful of other destructive
patterns are blocked by the `pre-tool-use.sh` hook before execution reaches
the shell. See `examples/09-security-hooks/` for details.

View file

@ -0,0 +1,54 @@
# Example 03: Web Search and Fetch
**Capability:** Claude Code can search the web and fetch full page content as part of
any task. Both tools are built-in; no MCP server required.
**OpenClaw equivalent:** Brave Search API + web_fetch with Firecrawl fallback.
---
## The Prompt
```
Search for the latest Claude Code release notes, summarize the 5 most impactful
features added in recent versions, and write the summary to changelog-summary.md
For each feature include:
- Feature name and the version it shipped in
- One sentence on what it does
- One sentence on why it matters for agent workflows
At the top of the file add a "Researched on" line with today's date and the
source URLs you used.
```
---
## What Happens
Claude Code will:
1. Use WebSearch to find Claude Code release notes and changelog pages
2. Use WebFetch to retrieve the full changelog content from Anthropic's docs
3. Parse and rank features by impact on agent workflows
4. Use Write to create `changelog-summary.md` with source attribution
5. Confirm the file was written
---
## Why This Matters
Web search makes Claude Code's knowledge current. The training cutoff becomes
less relevant when Claude can verify facts before writing them down.
The combination of WebSearch (for discovery) and WebFetch (for depth) mirrors
what a human researcher does: scan headlines, then read the full article.
This is the same pattern used in the PREP phase of the article production
pipeline that drives the `fromaitochitta.com` content workflow.
---
## Note on Sources
Claude Code cites sources when writing research outputs. If you need full
traceability, add "include the exact URL next to each claim" to the prompt.

View file

@ -0,0 +1,63 @@
# Example 04: Browser Automation
**Capability:** Claude Code can control a real browser via Playwright MCP, take
screenshots, and extract structured data from live pages.
**OpenClaw equivalent:** CDP/Playwright browser automation with screenshot and act commands.
---
## Prerequisites
Playwright MCP must be enabled. Add this to `.mcp.json`:
```json
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
```
This repo's `.mcp.json` already includes it. If Claude Code does not show
Playwright tools at startup, run `npm install` to ensure the package is
available, then restart.
---
## The Prompt
```
Navigate to https://news.ycombinator.com, take a screenshot of the current
front page, and list the top 5 stories with their point counts and submitter
names.
Save the list to hacker-news-top5.md with the format:
1. [title] - [points] points by [submitter]
Include a note at the bottom with the timestamp of when you fetched this.
```
---
## What Happens
Claude Code will:
1. Use the Playwright MCP `browser_navigate` tool to load the page
2. Use `browser_screenshot` to capture the current state
3. Use `browser_snapshot` or `browser_get_text` to extract story data
4. Use Write to save the structured list to `hacker-news-top5.md`
---
## Why This Matters
Browser automation handles pages that cannot be reached with WebFetch alone:
JavaScript-rendered content, login-protected pages, and interactive workflows.
OpenClaw bundles Playwright natively. Claude Code uses the same underlying
engine via MCP. The setup takes two minutes; the capability is identical.

View file

@ -0,0 +1,58 @@
# Example 05: Memory System
**Capability:** Claude Code maintains persistent memory across sessions through a
hierarchy of markdown files. What is written in one session is available in the next.
**OpenClaw equivalent:** Daily markdown logs + MEMORY.md + vector search (SQLite-vec).
---
## How the Hierarchy Works
Claude Code loads context in this order, from broadest to narrowest:
1. `~/.claude/CLAUDE.md` - global preferences, always loaded
2. `CLAUDE.md` in the project root - project-specific config, always loaded
3. `memory/MEMORY.md` - session state, loaded if referenced in CLAUDE.md
4. `.claude/` managed memory - auto-updated by Claude when `--memory` is active
The file loaded earlier provides the frame. Later files narrow it.
---
## The Prompt
```
Read this project's CLAUDE.md and summarize what you learn about the project
in three bullet points.
Then create a file at memory/project-notes.md with:
- Today's date as a header
- The three-bullet summary
- A note that says "Memory system demonstrated successfully"
Finally, explain in one paragraph how this file will be available in the
next Claude Code session without re-reading CLAUDE.md.
```
---
## What Happens
Claude Code will:
1. Use Read to load `CLAUDE.md` from the project root
2. Synthesize the project context into three bullets
3. Use Write to create `memory/project-notes.md`
4. Explain how CLAUDE.md references cause files to be auto-loaded
---
## Why This Matters
OpenClaw uses SQLite-vec for semantic memory search across sessions. Claude Code
uses structured markdown with explicit file references. Both achieve persistence.
The markdown approach is more inspectable: you can read, edit, and version control
every piece of memory Claude has about your project.
The `memory/MEMORY.md` file in this repo shows the pattern at scale.

View file

@ -0,0 +1,57 @@
# Example 06: Multi-Agent Orchestration
**Capability:** Claude Code can spawn sub-agents with distinct roles, run them in
parallel or in sequence, and combine their outputs into a final result.
**OpenClaw equivalent:** Sub-agents, agent-to-agent messaging, mesh workflows.
---
## Prerequisites
This example uses the agents defined in `.claude/agents/`:
- `researcher.md` - web research and source gathering
- `writer.md` - structured content drafting
- `reviewer.md` - accuracy and quality review
These agents load automatically when Claude Code opens this project.
---
## The Prompt
```
Use the researcher agent to find information about how Claude Code handles
agent isolation and worktree sandboxing (introduced in v2.1.49 and v2.1.50).
Then use the writer agent to draft a 300-word technical summary of the findings,
written for a developer audience. No jargon without explanation.
Finally, use the reviewer agent to check the draft for technical accuracy.
If the reviewer finds any issues, have the writer fix them before showing
me the final version.
```
---
## What Happens
Claude Code will:
1. Invoke the researcher agent via the Agent tool with the research task
2. Receive the research output and pass it to the writer agent
3. Invoke the writer agent to produce the 300-word draft
4. Invoke the reviewer agent with both the draft and source material
5. If the reviewer flags issues, loop back to the writer for a revision
6. Present the final reviewed draft
---
## Why This Matters
Agent Teams (v2.1.32) gives Claude Code a mesh model that matches OpenClaw's
sub-agent architecture. Worktree isolation (v2.1.50) means each agent gets
its own working directory, preventing file conflicts in parallel runs.
The researcher-writer-reviewer pattern is the same loop that produces articles
for `fromaitochitta.com`. The agents here are minimal versions of that pipeline.

View file

@ -0,0 +1,83 @@
# Example 07: Messaging
**Capability:** Claude Code can send and receive messages via external channels.
Native Telegram support arrived in v2.1.80. Other channels use MCP servers.
**OpenClaw equivalent:** 15+ native channels (WhatsApp, Telegram, Discord, Slack,
Signal, iMessage, IRC, Matrix, Teams, and more).
---
## Architecture Difference
OpenClaw ships with all 15+ channels built in. Claude Code takes an MCP approach:
each channel is a separate server you opt into. This means more setup per channel,
but also more control over what data leaves your machine.
As of v2.1.80, Telegram is the first native channel in Claude Code. More are
expected to follow the same pattern.
---
## Option A: Telegram (Native, v2.1.80+)
Start Claude Code with the Channels flag:
```bash
claude --channels
```
Then in session:
```
Send a Telegram message to my personal chat that says:
"Claude Code pipeline completed. Check research-output.md for results."
```
Requires the Telegram plugin configured in `.claude/settings.json`. The
permission relay (v2.1.81) lets you approve tool calls from Telegram directly,
without returning to the terminal.
---
## Option B: Slack (via MCP)
Add to `.mcp.json`:
```json
{
"mcpServers": {
"slack": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-slack"],
"env": {
"SLACK_BOT_TOKEN": "xoxb-your-token",
"SLACK_TEAM_ID": "T0123456"
}
}
}
}
```
Then use the `/skills/send-slack-message` skill in this repo:
```
/send-slack-message channel=#general message="Pipeline finished successfully."
```
---
## What Happens
For Telegram: Claude Code calls the native Channels API to deliver the message.
For Slack: Claude Code calls the Slack MCP server, which relays via the Slack API.
Both confirm delivery in the terminal output.
---
## Honest Comparison
If you need 15 channels working out of the box, OpenClaw wins today. Claude Code
has Telegram natively and the rest via MCP. The gap is narrowing with each
release. For most personal automation needs, Telegram is sufficient.

View file

@ -0,0 +1,67 @@
# Example 08: Cron and Scheduled Automation
**Capability:** Claude Code supports scheduled and automated execution through
three complementary mechanisms, covering in-session polling through to
system-level cron jobs.
**OpenClaw equivalent:** HEARTBEAT.md, cron scheduler, webhooks, auto-reply.
---
## Three Approaches
### Approach 1: /loop (In-session polling, v2.1.71)
For tasks that should repeat while Claude Code is running:
```
/loop interval=60
Every 60 seconds, check if a file called 'trigger.txt' exists in this
directory. If it does, read its contents, execute the task described inside,
delete the file, and write the result to 'loop-output.md'. Then wait for
the next trigger.
```
Use this for development and testing. The loop runs as long as the session
is active.
---
### Approach 2: CronCreate (System-level scheduling, v2.1.71)
For tasks that should run on a schedule even when Claude Code is not open:
```
Create a cron job that runs the 'daily-briefing' skill every morning at 07:00.
Use the automation/daily-briefing.sh wrapper script. Show me the cron entry
before creating it so I can verify it.
```
Claude Code calls `CronCreate` to register the job with the system cron daemon.
Use `CronList` to see all registered jobs and `CronDelete` to remove them.
The `automation/daily-briefing.sh` script in this repo is a ready-made wrapper.
---
### Approach 3: /schedule (Remote trigger, web only)
For triggering runs from anywhere, including from a phone:
```
/schedule "Run the web-research skill on 'latest Anthropic news' and
email me a summary" at 2025-04-01T08:00:00
```
`/schedule` is available in the Claude web interface. It queues a headless
Claude Code run for the specified time. Combines with the Telegram permission
relay (v2.1.81) for approval-gated automation.
---
## Why This Matters
OpenClaw uses HEARTBEAT.md as a persistent loop marker. Claude Code achieves
the same outcome with more granularity: /loop for in-process polling, CronCreate
for system scheduling, /schedule for remote triggering. The `automation/` directory
in this repo provides macOS launchd examples as an alternative to cron.

View file

@ -0,0 +1,62 @@
# Example 09: Security Hooks
**Capability:** Claude Code executes hook scripts before and after every tool call.
PreToolUse hooks can block dangerous operations. PostToolUse hooks create audit trails.
**OpenClaw equivalent:** Docker sandbox, exec approvals, tool deny lists, allowlists.
---
## How the Hooks Work
The `hooks/` directory in this repo contains two scripts:
- `pre-tool-use.sh` - runs before every Bash tool call. Blocks destructive patterns.
- `post-tool-use.sh` - runs after every tool call. Appends to `hooks/audit.log`.
Both are registered in `.claude/settings.json` under the `hooks` key.
---
## The Prompt
```
Try running this shell command: rm -rf /tmp/test-deletion-target
Before running it, explain what you expect the PreToolUse hook to do.
After the attempt, check hooks/audit.log and show me the last 5 entries.
Then explain what was blocked and why it was flagged by the hook.
```
---
## What Happens
1. Claude Code calls the Bash tool with `rm -rf /tmp/test-deletion-target`
2. Before execution, `pre-tool-use.sh` receives the command as input
3. The hook matches the `rm -rf` pattern and exits with a non-zero code
4. Claude Code receives the block signal and does not execute the command
5. `post-tool-use.sh` logs the blocked attempt with timestamp and tool name
6. Claude Code reports what happened and shows the audit log
---
## Reading the Audit Log
```bash
tail -20 hooks/audit.log
```
Each entry has the format: `[timestamp] TOOL: bash | STATUS: blocked | CMD: rm -rf ...`
---
## Architecture Difference from OpenClaw
OpenClaw sandboxes via Docker: the agent runs inside a container that limits
what it can affect on the host. Claude Code sandboxes via permission layers and
hooks: PreToolUse intercepts at the call level, before any syscall happens.
For personal use, hooks are more flexible. You write exactly the rules you need.
For untrusted third-party agents, Docker isolation is stronger. See
`security/nemoclaw-comparison.md` for a full breakdown.

View file

@ -0,0 +1,72 @@
# Example 10: Full Pipeline
**Capability:** A complete workflow combining web search, multi-agent orchestration,
file I/O, memory, hooks, and logging in a single Claude Code run.
**OpenClaw equivalent:** End-to-end agent pipeline with messaging, skills, and hooks.
---
## What This Demonstrates
Every capability from examples 01-09 working together:
| Step | Capability | Example |
|------|-----------|---------|
| 1 | Web search | 03-web-search |
| 2 | Researcher agent | 06-multi-agent |
| 3 | Writer agent | 06-multi-agent |
| 4 | Reviewer agent | 06-multi-agent |
| 5 | File I/O | 02-shell-and-files |
| 6 | Memory update | 05-memory-system |
| 7 | Security logging | 09-security-hooks |
| 8 | Agent runtime loop | 01-agent-runtime |
---
## The Prompt
```
Run a full research-to-output pipeline on the topic: "How Claude Code handles
permission modes: plan, autoEdit, and bypassPermissions"
Pipeline steps:
1. Use the researcher agent to gather information from the web and official docs
2. Pass the research to the writer agent to draft a 400-word explainer
3. Send the draft to the reviewer agent for accuracy and clarity feedback
4. Incorporate the reviewer's feedback into a final version
5. Save the final version to pipeline-output/permission-modes.md
6. Append a pipeline execution summary to memory/pipeline-log.md with:
- Date and time
- Topic researched
- Word count of final output
- Any issues encountered
7. Show me the first 10 lines of the output file to confirm everything worked
```
---
## What Happens
Claude Code will coordinate the full pipeline autonomously:
- The researcher agent uses WebSearch and WebFetch
- The writer agent produces structured prose
- The reviewer agent critiques and returns specific feedback
- A revision loop runs if needed (bounded by maxTurns in settings.json)
- File writes are intercepted by PostToolUse for audit logging
- Memory is updated so the next session knows this pipeline ran
You will see each agent invocation streamed in sequence. The entire pipeline
typically completes in 2-4 minutes depending on web fetch latency.
---
## Why This Matters
This is what Claude Code looks like as an actual agent platform, not a
chat assistant. The same architecture, with different prompts and agents,
runs the article production pipeline at `fromaitochitta.com`.
The companion repo you are reading is the minimal version of that setup.
Clone it, open Claude Code, and run this prompt to see the full stack work.