OpenClaw: Part 4: File Management and the exec Permission Model
With artificial intelligence, we are summoning the demon, Elon Musk
AI won’t replace humans, but those who use AI will replace those who don’t, Garry Kasparov
Hands: File Tools, Obsidian, and Safe Shell Access
In Parts 1 through 3 we gave our OpenClaw agent a body (the Gateway and the workspace), a memory (skills, QMD), and senses (Gmail, Calendar, web search). But an agent that can only talk is an advisor. In this fourth installment we give it hands — the ability to read, search, and edit files, manage your notes, and run shell commands, all under a permission model that keeps you in control.
OpenClaw's file tools give the agent direct access to the machine it runs on — no copy-paste required. But 'file management' is really six tools with different risk profiles, and the difference between a useful agent and a dangerous one is knowing which tool to reach for and which permission mode to leave it in.
Here is the roadmap. We start with a detour through the official Obsidian CLI, which turns your notes vault into a structured, scriptable knowledge base the agent can search, read, and write without leaving the terminal. Then, we tour the six OpenClaw file tools — read, write, edit, apply_patch, search, and the powerful but dangerous exec — and work through a realistic example: installing a zsh function that finds which Hugo posts reference a given image.
After that comes the heart of the article: the exec parameters that matter (timeout, yieldMs, host, security, ask) and the permission model — deny, allowlist, ask, auto, full — that lets the agent work while you sleep. We close with a safety checklist and two complete skill builds — an RSS news aggregator wired into your daily briefing, and a daily Gospel reader — to see the file and shell tools working together in practice.
Obsidian CLI: the official command line, not a third-party wrapper
Obsidian now ships an official CLI that controls the running desktop app from your terminal. This is preferable to third‑party wrappers because it guarantees compatibility, avoids extra dependencies, and lets you script the vault directly.
- Enable it. In the Obsidian desktop app: Settings → General → Command line interface. On macOS, registration creates /usr/local/bin/obsidian pointing at the app-bundled CLI; on Linux it copies the binary to ~/.local/bin/obsidian.
- Verify:
obsidian version,obsidian help. - Obsidian desktop tracks vaults in
~/Library/Application Support/obsidian/obsidian.json. This is the source of truth for which vaults exist and which one is open. The OpenClaw Obsidian skill reads this file rather than guessing paths. - Uses:
# A. Command grammar
# The CLI uses key=value parameters and boolean flags:
obsidian command [name=value ...] [flag]
# format=json gives structured output, which is what you want when an agent is parsing results.
obsidian vault="Notes" search query="meeting notes" format=json
# B. Open and read
# file=name uses Obsidian-style name resolution.
obsidian open file=Agenda.md
# path="Folder/Note.md" is exact vault-relative resolution.
obsidian open path="assets/Todo.md"
# obsidian read with no argument reads the active file
obsidian read
# C. Search
# matches returns matching lines; format=json returns structured results
obsidian search query="TODO" matches
obsidian search query="TODO" matches format=json
# D. Create, append
obsidian create name="New Note"
obsidian create path="Inbox/Idea.md" content="# Idea"
obsidian append file=Note content="New line"
# E. Move, delete
obsidian move file=Note to=Archive/
obsidian move path="Inbox/Old.md" to="Projects/New.md"
obsidian delete file=Note
OpenClaw File Management: Read, Write, Edit, Search, and Exec
OpenClaw’s file tools give the agent direct access to the machine it runs on — no copy‑paste required. But “file management” is really six tools with different risk profiles, and the difference between a useful agent and a dangerous one is knowing which tool to reach for and which permission mode to leave it in.
This article covers the tool surface, a realistic worked example (adding a zsh function), the exec parameters that matter, and the correct way to put exec behind approval.
OpenClaw File Management: Read, Write, Edit, Search, and Exec — Practically
OpenClaw’s file tools give the agent direct access to the machine it runs on — no copy‑paste required. But “file management” is really six tools with different risk profiles, and the difference between a useful agent and a dangerous one is knowing which tool to reach for and which permission mode to leave it in.
This article covers the tool surface, a realistic worked example (adding a zsh function), the exec parameters that matter, and the correct way to put exec behind approval.
1. The tool surface at a glance
| Tool | Group | What it is for | Risk |
|---|---|---|---|
read |
group:fs |
Read file contents (text or images), with offset/limit for large files | Low (read-only) |
write |
group:fs |
Create or overwrite a file; creates parent directories | High (overwrites silently) |
edit |
group:fs |
Exact string replacement in an existing file | Medium–high (a wrong match corrupts) |
apply_patch |
group:fs |
Structured diff-based patching (experimental) | Medium |
exec |
group:runtime |
Run shell commands, foreground or background | Highest |
process |
group:runtime |
Poll, log, kill, clear background exec sessions |
Medium |
2. Reading and writing files
The single most important habit: read first, then edit or write. write overwrites without warning, and edit fails (or corrupts) if the exact string is not present.
# Prompt Example
Read README.md in my Python directory and summarize it.
# Output
Here's a summary of the README.md in ~/macOS/myPython:
Hugo Content Toolkit (v0.17)
A Python toolkit that reviews, enriches, and quality-checks Markdown pages of your Hugo website (justtothepoint) using a local LLM (Ollama) and the live Hugo server. [...]
edit does an exact string replacement, not a regex and not a fuzzy match. If whitespace differs — tabs vs spaces, trailing spaces — the edit fails. That is a safety feature: it will not silently match the wrong occurrence. The practical fix is to copy the exact block from a fresh read, then replace it.
If you do not want the agent touching dotfiles or system paths, set:
{
# Safety measure: Keep the agent inside the workspace
"tools": {
"fs": {
"workspaceOnly": true
}
}
}
This restricts read/write/edit to the workspace directory. It does not restrict exec — which is exactly why the two controls must be considered separately.
3. Search before you edit
Most file tasks start with “find where this is.” exec plus ripgrep is the right tool; read is the wrong one.
# Find files containing a phrase
rg -l 'Talonario Recetas' ~/macOS
# Case-insensitive, with line numbers
rg -in 'talonario recetas' ~/macOS
# Restrict to Markdown, skip .git and node_modules
rg -l -g '*.md' -g '!.git/**' -g '!node_modules/**' 'Talonario Recetas' ~/macOS
Practical notes:
-llists filenames only; drop it to see matching lines.--hiddenincludes dotfiles;--no-ignoreignores.gitignore. Both widen the search and can produce noise, so add-g '!.git/**'when you use them.- Prefer a literal search (
-F) when the pattern contains regex metacharacters such as.or[.
4. Worked example: adding hugo-image-posts to .zsh_functions
The goal: a function that, given an image filename, prints every Hugo post that references it.
hugo-image-posts() {
local content="/Volumes/MacDatosMaster/justtothepoint/content"
# A **zsh history modifier** that takes the tail (basename) of a path.
# `hugo-image-posts /a/b/hero.png` searches for `hero.png`, not the full path.
local image="${1:t}" # Use the filename even if you pass a full path
if [[ -z "$1" ]]; then
# Writes to **stderr** (fd 2), so the message is not captured as normal output.
print -u2 -- "Usage: hugo-image-posts "
# Distinct exit codes: `2` = usage error, `1` = missing directory.
return 2
fi
if [[ ! -d "$content" ]]; then
print -u2 -- "Hugo content directory not found: $content"
return 1
fi
# `rg -F`: **Fixed-string** match. The `.` in `hero.png` is literal, not “any character.”
# `rg -l`: Print **filenames only**, which is what you want for “which posts reference this.”
# `--sort path`: Deterministic output order
# `--hidden --no-ignore`: Includes hidden files and ignores `.gitignore`.
# `-g '*.md'`: Limits to Markdown.
# `-- "$image"`: The `--` separates options from the pattern, so a filename starting with `-` is not parsed as a flag.
rg -F -l --sort path --hidden --no-ignore -g '*.md' -- "$image" "$content"
}
Add the following zsh function to `~/.zsh_functions`.
First read the file and inspect its contents. Preserve everything already there. Append the function at the end only if it is not already present; if it is present, update that function without changing unrelated content. Use a targeted patch rather than rewriting the whole file.
After editing, run `zsh -n ~/.zsh_functions` to check the file’s syntax. Provide a comment to explain its functionality.
Function to add:
hugo-image-posts() {
local content="/Volumes/MacDatosMaster/justtothepoint/content"
local image="${1:t}"
if [[ -z "$1" ]]; then
print -u2 -- "Usage: hugo-image-posts "
return 2
fi
if [[ ! -d "$content" ]]; then
print -u2 -- "Hugo content directory not found: $content"
return 1
fi
rg -F -l --sort path --hidden --no-ignore -g '*.md' -- "$image" "$content"
}
Then, reload and test:
source ~/.zsh_functions
hugo-image-posts MomSittingThinkingBedroomDog.jpg
Expected output is the list of .md files, exactly as in the example.
5. The exec tool: parameters that matter
exec is not just “run a command.” These parameters change its behaviour:
| Parameter | Default | Practical meaning |
|---|---|---|
command |
required | The shell command. |
workdir |
current directory | Set it explicitly when the command depends on a project root. |
timeout |
1800 s | Kills the process on expiry. Long enough for builds; too long for a hung command you forgot about. |
yieldMs |
10000 ms | After 10 s, the command is moved to the background automatically. |
background |
false |
Background immediately. |
pty |
false |
Use a pseudo-terminal — needed for TTY-only CLIs, interactive coding agents, and terminal UIs. |
host |
sandbox |
Where it runs: sandbox, gateway, or node. |
security |
deny (sandbox) / allowlist (gateway + node) |
deny, allowlist, or full. |
ask |
on-miss |
off, on-miss, or always — approval prompts for gateway/node. |
elevated |
false |
Requests elevated mode on the gateway host. |
With host=gateway, OpenClaw merges your login-shell PATH into the exec environment, but the daemon itself runs with a minimal PATH — on macOS, /opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin. If a command works in your terminal but not through the agent, the usual cause is that the binary lives somewhere the daemon does not see. Therefore, you must fix the environment (tools.exec.pathPrepend), not the command.
6. The permission model
# Run commands that match the configured allowlist, and request human approval for commands that don’t.
{
"tools": {
"exec": {
"mode": "ask"
}
}
}
Or from the CLI:
openclaw config set tools.exec.mode ask
openclaw approvals get # verify the effective policy
openclaw gateway restart # apply
tools.exec.mode is the normalized policy interface. Each mode resolves to an underlying security / ask pair:
| Mode | security / ask |
Behaviour | Use when |
|---|---|---|---|
deny |
deny / off |
Blocks host exec entirely | No host commands should run |
allowlist |
allowlist / off |
Runs allowlisted commands; silently refuses misses | You have a known-safe command set |
ask |
allowlist / on-miss |
Runs allowlisted commands; prompts a human on a miss | Every new command form should be reviewed |
auto |
allowlist / on-miss |
Same, plus a native automatic reviewer before human approval | Coding sessions that need practical but guarded access |
full |
full / off |
Runs host exec without prompts | A trusted host/session only |
The docs’ recommended default for coding agents is auto, not ask: it keeps the allowlist and only escalates to a human when the automatic reviewer cannot safely approve.
7. Safety checklist
- Read before edit or overwrite. Always.
- Dry-run destructive commands first:
rg -lbeforesed -i,lsbeforemv,--dry-runwhere supported. - Prefer trash over
rm. On macOS,brew install trashgives atrashcommand; or move files into a dated folder instead of deleting them. - Keep the workspace in git. Version control is the only reliable undo for a wrong
writeor a bad patch. - Set
tools.fs.workspaceOnly: trueif the agent has no business reading dotfiles or system paths. - Constrain
execseparately.execis mutating even whenwrite/editare disabled. - Verify the effective policy with
openclaw approvals get, not by reading the config file alone.
8. Quick reference
# Read / search
rg -l -g '*.md' -g '!.git/**' 'pattern' ~/macOS
rg -in 'pattern' path/
# Safe edit workflow
# 1) read the target 2) locate a unique anchor 3) edit/apply_patch 4) re-read to confirm
# zsh inventory
zsh -ic 'alias -L'
zsh -ic 'functions'
# exec policy
openclaw config set tools.exec.mode ask
openclaw approvals get
openclaw gateway restart
# Inspect what the agent can actually do
openclaw config get tools.fs
openclaw config get tools.exec
openclaw-feeds
- What it does? This is a concurrent RSS aggregator. It fetches all current entries from curated feeds across three categories — news, games, and finance. It streams JSON to stdout, so it composes well with jq, pipes, and skill runners. No API key is required.
- Install the skill
openclaw skills install @nesdeq/openclaw-feeds. Confirm the skill directory exists before continuing:ls ~/macOS/claude/skills/openclaw-feeds. You should seescripts/feeds.py(and usually a SKILL.md). - Create the virtual environment.
cd ~/macOS/claude/skills/openclaw-feeds python3 -m venv .venv # Update pip. .venv/bin/python -m pip install --upgrade pip # Install the package feedparser. .venv/bin/python -m pip install feedparser # Sanity check that the right interpreter sees the right package: .venv/bin/python -c "import feedparser, sys; print(feedparser.__version__, sys.executable)" 6.0.14 /Users/nmaximo7/macOS/claude/skills/openclaw-feeds/.venv/bin/python # Run the script with that environment’s Python and verify: .venv/bin/python scripts/feeds.py --category news # Verify the shape once before wiring it into anything: # Note. brew install jq if you don't have it. .venv/bin/python scripts/feeds.py --category news | jq '.[0], .[1]' ❯ .venv/bin/python scripts/feeds.py --category news | jq '.[0], .[1]' { "category": "news", "total_entries": 398, "sources": [ "aeon.co", "arstechnica.com", "asteriskmag.com", "harpers.org", "heise.de", "lowtechmagazine.com", "nautil.us", "noemamag.com", "nytimes.com", "quantamagazine.org", "slashdot.org", "techcrunch.com", "techdirt.com", "thenewatlantis.com", "thepointmag.com", "theverge.com", "wired.com" ], "fetched_at": "2026-11-11 10:08:40" } { "title": "Nvidia’s crisis has corporate governance experts reaching for the popcorn", "url": "https://techcrunch.com/2026/11/10/nvidias-crisis-has-corporate-governance-experts-reaching-for-the-popcorn/", "source": "techcrunch.com", "date": "Wed, 11 Nov 2026 07:30:51 +0000", "summary": "The governance experts we talked to say nobody has seen anything like what's unfolding right now." } - Wire it into the Daily Briefing skill. Add (or replace) section 5 of your Daily Briefing SKILL.md.
### 5. Tech News — latest headlines Use the `openclaw-feeds` skill to fetch the latest tech news. Run the skill's own interpreter so `feedparser` resolves: ```bash ~/macOS/claude/skills/openclaw-feeds/.venv/bin/python3 \ ~/macOS/claude/skills/openclaw-feeds/scripts/feeds.py --category news ``` - Parse the JSON output. The first element is metadata; the rest are entries with `title`, `url`, `source`, `date`, `summary`. - Select the 5 most interesting or highest-priority headlines. - Group by theme if there are clear clusters (e.g. AI, Hardware, Industry, Security). - For each: **headline as markdown link** — one-line summary *(source)*. - If zero entries or error, say "tech news unavailable" — do not invent headlines. [...] ## Output format 📰 Tech News **[<headline>](url)** — summary *(source)* - ...
Daily Gospel
- Create a directory for your skill, a virtual environment for that skill, and install feedparser.
SKILL="$HOME/macOS/claude/skills/daily-gospel" mkdir -p "$SKILL/scripts" python3 -m venv "$SKILL/.venv" "$SKILL/.venv/bin/python3" -m pip install --upgrade pip "$SKILL/.venv/bin/python3" -m pip install feedparser - Create a script for your skill,
code ~/macOS/claude/skills/daily-gospel/scripts/daily_gospel.py.#!/usr/bin/env python3 """Fetch the latest daily Gospel reading from the Evangelizo RSS feed.""" import json import sys import urllib.request from html.parser import HTMLParser import feedparser FEED_URL = "https://rss.evangelizo.org/rss/v2/evangelizo_rss-am.xml" TIMEOUT_SECONDS = 20 USER_AGENT = "daily-gospel-skill/1.0" class _TextExtractor(HTMLParser): """Collapse an HTML fragment to normalized plain text.""" def __init__(self) -> None: super().__init__(convert_charrefs=True) self._parts = [] def handle_data(self, data: str) -> None: self._parts.append(data) def text(self) -> str: return " ".join(" ".join(self._parts).split()) def fetch(url: str) -> bytes: request = urllib.request.Request(url, headers={"User-Agent": USER_AGENT}) with urllib.request.urlopen(request, timeout=TIMEOUT_SECONDS) as response: return response.read() def main() -> int: try: raw = fetch(FEED_URL) except Exception as exc: print(f"error: could not fetch feed: {exc}", file=sys.stderr) return 1 feed = feedparser.parse(raw) if not feed.entries: reason = feed.get("bozo_exception", "no entries") print(f"error: no entries found in feed ({reason})", file=sys.stderr) return 1 entry = feed.entries[0] content = entry.get("content") or [] raw_html = content[0].get("value", "") if content else entry.get("summary", "") extractor = _TextExtractor() extractor.feed(raw_html) result = { "title": entry.get("title", ""), "date": entry.get("published", entry.get("updated", "")), "reading": extractor.text(), "link": entry.get("link", ""), } print(json.dumps(result, ensure_ascii=False, indent=2)) return 0 if __name__ == "__main__": sys.exit(main()) - Test it.
"$HOME/macOS/claude/skills/daily-gospel/.venv/bin/python3" \ "$HOME/macOS/claude/skills/daily-gospel/scripts/daily_gospel.py" - Create the skill manifest,
nvim ~/macOS/claude/skills/daily-gospel/SKILL.md--- name: daily-gospel description: Fetch the latest daily Gospel reading from the Evangelizo RSS feed. --- When the user asks for the daily Gospel or daily reading, run: `{baseDir}/.venv/bin/python3 {baseDir}/scripts/daily_gospel.py` Present the title, date, and reading. Include the feed link if useful. If the script reports an error or no entry, report that instead of inventing a reading.
{baseDir} is substituted by the skill runner with the skill’s directory.