Use this skill for any task that involves reading, understanding, searching, or modifying source code in a project — across JavaScript, TypeScript, Vue, Reac... You can see every single script that's in this. This does not call a remote script at all. You might have to run npm update. That's not a security vulnerability. CallHub sucks at this security scanning.
---
name: agentic_cli_coding
description: "Use this skill for any task that involves reading, understanding, searching, or modifying source code in a project — across JavaScript, TypeScript, Vue, React, Node, Python, Go, Ruby, PHP, Java, Rust, C/C++, shell scripts, JSON, YAML, HTML, CSS, SQL, and Markdown. Trigger whenever the user asks to fix a bug, add a feature, refactor, rename, restructure, search a codebase, locate a function or symbol, apply a patch, modify configuration, or make any multi-file change. Also use when the user references files by path or name and wants something done to them, when reviewing or auditing code, or when planning an edit before making it. Provides the `oce` command — a unified, validation-aware, transaction-capable editing toolkit that backs up every change and rolls back on syntax failure. Prefer `oce` over raw sed/awk/perl-i for any persistent edit; those are read-only here."
---
# Agentic CLI Coding
A code-editing toolkit for agents. Provides the `oce` command, which wraps reads, searches, edits, validation, formatting, backups, and multi-file transactions behind one predictable interface that always validates after writing and rolls back on syntax failure.
This skill exists because raw `sed`, `awk`, and `perl -i` are too sharp for autonomous use — they apply changes silently, give regex-style false matches, leave no audit trail, and can't roll back. `oce` keeps the speed of CLI editing while adding the safety rails an agent needs.
---
## Invocation — `oce` shorthand
Throughout this document, the command `oce <subcommand>` is shown for readability. The actual invocation is one of:
```bash
# Option A — direct (works immediately, no setup):
bash <skill-path>/scripts/oce.sh <subcommand> [args]
# Option B — one-time alias for the session (recommended for agents):
alias oce="bash <skill-path>/scripts/oce.sh"
# Option C — install a wrapper on PATH (persistent):
bash <skill-path>/scripts/install.sh
```
For agentic use, set up the alias once at the top of any session that involves editing, then use `oce <subcommand>` for the rest of the session. Replace `<skill-path>` with the actual install location of the skill (often something like `/home/agent/.skills/agentic_cli_coding`).
---
## Setup verification
After setting up the alias (or installing), run this once at the start of any editing session:
```bash
oce doctor
```
Exit code 0 with `Setup OK` means the toolkit is ready. The "core tools" must all be present (node, patch, diff, grep, acorn). Missing optional tools (prettier, gofmt, etc.) only affect formatting for that language — editing still works.
If you see `oce: command not found`, the alias wasn't set or the install wrapper isn't on PATH. Use Option A (direct invocation) instead.
---
## Methodology — how to approach any code task
Skip directly to the relevant step if the user's task is simple. For anything non-trivial, walk through all four.
### 1. Orient — understand the project
Before editing, know what you're editing.
```bash
oce tree --depth 2 # What's in this project?
oce find "<keyword>" --type <lang> # Where does the relevant code live?
oce ast symbols path/to/file.js # What functions/classes does that file define?
```
Don't skip orientation just because you "know" the answer from training. Repository conventions vary; assumptions are how agents break codebases.
### 2. Read — load the exact context you'll need
```bash
oce read src/server.js --around "handleAuth" --context 20
oce grep-context "TODO" src/server.js -c 5
oce read src/auth.js --lines 45:120
```
Read enough surrounding context that you can predict what your edit will affect. The cheapest way to break code is to edit a function in isolation without seeing its callers.
### 3. Plan — write down what you'll change before changing anything
For non-trivial edits, state the plan explicitly before executing:
- **What's being added** (new lines, new files)
- **What's being removed** (deletions, deprecations)
- **What's being modified** (in-place changes)
- **What's at risk** (files that touch the same symbols, public APIs, tests)
- **What you'll validate** (which files need to compile, which tests should still pass)
If the change spans multiple files, **start a transaction** before the first edit:
```bash
TXN=$(oce transaction begin)
```
Then pass `--txn "$TXN"` to every subsequent `oce replace`, `oce insert`, `oce delete`, `oce write`, `oce patch`, or `oce ast` command. At the end you commit (validates everything atomically) or roll back (restores every file).
### 4. Execute — pick the right edit tool, then verify
The decision flow:
```
Need to change code?
├── Tiny, surgical, exact-string change → oce replace
├── Insert new code at a known anchor → oce insert --before-match | --after-match | --line
├── Remove specific lines or matching lines → oce delete --lines | --match
├── Multi-line precision change with context → oce patch apply (write a unified diff)
├── Rename a JS/JSX identifier scope-wide → oce ast rename
├── Replace an entire function/class body → oce ast replace-symbol
├── Brand-new file or full rewrite → oce write
└── Coordinated changes across multiple files → oce transaction + any of the above
```
After every edit, the toolkit auto-validates the file's syntax and rolls back if it broke. You don't need to re-validate manually, but you should `oce diff <file>` to confirm the change matches your intent.
---
## Decision tree — which command for which job
```
DISCOVERY READING
──────────────── ────────────────
project layout? tree full file? read <file>
where is X? find specific lines? read <file> --lines A:B
function/class list? ast symbols context around X? read <file> --around X -c N
match in context? grep-context match with ctx? grep-context X file -c N
EDITING (small) EDITING (large / structural)
──────────────── ────────────────
exact string swap replace full file rewrite write
insert at anchor insert apply unified diff patch apply
delete lines/matches delete rename symbol (JS/JSX) ast rename
replace function body ast replace-symbol
VERIFY & RECOVER
────────────────
syntax check validate (auto-runs after every edit)
canonical format format (manual)
view recent change diff (vs last backup)
list backups backup list
restore backup restore <file> [--at N]
MULTI-FILE ATOMIC
────────────────
TXN=$(oce transaction begin)
oce <edit> ... --txn "$TXN" (repeat)
oce transaction validate "$TXN"
oce transaction commit "$TXN" | oce transaction rollback "$TXN"
```
---
## Standard workflows
### Modifying an existing function (single file)
```bash
oce find "function processRequest" --type js
oce read src/server.js --around "processRequest" --context 15
oce replace src/server.js \
--old "return data;" \
--new "return sanitize(data);"
oce diff src/server.js
```
### Adding a new code block at a known anchor
```bash
oce find "// END ROUTES" src/server.js
cat > /tmp/new_route.js <<'EOF'
app.get('/health', (req, res) => res.json({ ok: true }));
EOF
oce insert src/server.js --before-match "// END ROUTES" --content-file /tmp/new_route.js
```
### Multi-file rename / refactor
```bash
TXN=$(oce transaction begin)
oce replace src/auth.js --old "validateToken" --new "verifyToken" --all --txn "$TXN"
oce replace src/api.js --old "validateToken" --new "verifyToken" --all --txn "$TXN"
oce replace tests/auth.test.js --old "validateToken" --new "verifyToken" --all --txn "$TXN"
oce transaction validate "$TXN"
oce transaction commit "$TXN" # or rollback if anything looks wrong
```
For pure JS/JSX, `oce ast rename` is preferable — it walks the AST and only renames real identifier references, not strings or comments.
### Precise multi-line patch
When you need exact control over a multi-line change, write a unified diff:
```bash
cat > /tmp/fix.patch <<'EOF'
--- a/src/auth.js
+++ b/src/auth.js
@@ -12,6 +12,10 @@
function authenticate(req) {
+ if (!req.headers.authorization) {
+ throw new Error('Missing auth header');
+ }
const token = req.headers.authorization.split(' ')[1];
EOF
oce patch apply /tmp/fix.patch
```
The patch is dry-run-checked first; if it doesn't apply cleanly the command fails before touching anything. After applying, every affected file is validated and the entire patch is rolled back if any file's syntax broke.
### Recovering from a bad edit
```bash
oce backup list <file> # See available snapshots
oce backup diff <file> # Compare current vs. most recent backup
oce backup restore <file> # Restore most recent backup
oce backup restore <file> --at 3 # Restore the 4th-most-recent (0-indexed)
```
Backups are auto-created before every destructive operation. They live in `.oce/backups/` in the workspace.
---
## Anti-patterns — never do these
These are the failure modes that bite agents most often. Internalize them.
**Do not use `sed -i`, `awk` redirected to the same file, or `perl -i`** for editing. They give zero validation, no backup, and silent partial-success on regex misses. Use `oce replace` (literal match) or `oce patch` (precise) instead.
**Do not use `oce write` to make small edits.** `write` replaces the entire file. If you only need to change three lines, use `replace`, `patch`, or `insert`. Full rewrites are reserved for new files or when you've already loaded and modified the entire file's content programmatically.
**Do not pass a non-unique `--old` to `oce replace` without `--all`.** The command will fail with an "ambiguous match" error — that's by design. Either make `--old` more specific (include surrounding context like an indent or a closing brace) or pass `--all` if you genuinely want every occurrence changed.
**Do not edit multiple files for a single logical change without a transaction.** If file 2's edit fails validation, file 1 is now in an inconsistent state. `transaction begin` + `--txn` + `commit`/`rollback` keeps everything atomic.
**Do not skip `oce diff` after a non-trivial edit.** It takes one command and tells you whether the change matches your mental model. The auto-validation only catches syntax errors, not logic errors.
**Do not assume a formatter ran.** `oce format` only runs if the formatter is installed. Check `oce doctor` output if you care.
**Do not edit binary files.** `oce` refuses by default; if you find yourself reaching for `OCE_MAX_FILE_SIZE` overrides or trying to bypass the binary check, stop and reconsider.
**Do not invent file paths.** Always confirm a file exists with `oce read` or `oce tree` before editing it. The toolkit will fail loudly on missing files, but the better habit is checking first.
---
## Output format — `--json` for programmatic parsing
Every command supports `--json`, which emits a single-line JSON object on stdout (or stderr for errors). Use this when chaining commands or parsing results.
Quick reference (full schema in `references/json-schema.md`):
```json
// Success
{"status":"success", "file":"src/x.js", "replacements":3, "backup":"/path/to/backup"}
// Error
{"status":"error", "message":"Found 5 matches; pass --all or make --old more unique"}
// Dry run
{"status":"dry_run", "file":"src/x.js", "matches":3, "message":"would replace 3 occurrence(s)"}
// Validation
{"status":"success", "file":"src/x.js", "language":"javascript", "validator":"node --check", "valid":true, "output":""}
```
For ambiguous results (find with many hits, ast symbols), the JSON includes a `matches` or `symbols` array.
---
## Global flags
These work on every command:
| Flag | Effect |
|---|---|
| `--json` | Emit machine-readable JSON instead of human text |
| `--dry-run` | Show what would happen, change nothing (writes only) |
| `--no-color` | Disable ANSI colors |
| `--txn <id>` | Register backups with a transaction (write commands only) |
---
## Language support summary
`oce` knows about and handles edits for files in: JavaScript (.js .mjs .cjs .jsx), TypeScript (.ts .tsx), Vue (.vue), Svelte (.svelte), Python (.py), Ruby (.rb), Go (.go), Rust (.rs), Java (.java), Kotlin (.kt), Swift (.swift), C/C++ (.c .h .cpp .hpp), C# (.cs), PHP (.php), Bash/Zsh (.sh .bash .zsh), JSON, YAML, TOML, XML, HTML, CSS/SCSS/LESS, Markdown, SQL, Dockerfile, Makefile.
Validation depth varies by what's installed locally. See `references/language-support.md` for the full matrix.
AST-level operations (`oce ast`) are JS/JSX-native (acorn parses them directly). On TypeScript files, AST commands work for the JS-compatible subset — for full TS support, install local `tsc`. For other languages, use text-based edits (`replace`, `patch`).
---
## Storage and state
The skill writes nothing to your home directory. All state lives in `.oce/` inside the current working directory:
```
<project>/.oce/
├── backups/ Snapshot of every file before destructive edit
├── transactions/ Active and historical transactions
└── edit.log Audit log of every edit
```
You can safely add `.oce/` to `.gitignore`. To clean up, `oce backup clean [DAYS]` removes backups older than DAYS (default 30).
---
## Reference material
For deeper docs, read these as needed:
- **`references/json-schema.md`** — Exact JSON output schema for every command. Read this when chaining commands or parsing output programmatically.
- **`references/workflows.md`** — Longer worked examples: bug fix flow, feature add flow, refactor flow, dependency upgrade flow, Vue/React component editing.
- **`references/language-support.md`** — Per-language validator and formatter matrix; what works without extra installs, what needs project-local tooling.
- **`references/troubleshooting.md`** — Symptom → cause → fix table for the failure modes you'll hit in practice.
---
## One-line summary
`oce <verb> <file> [options]` — every verb backs up first, validates after, and rolls back on syntax failure. Use transactions for multi-file changes. Read before you write. Plan before you execute.
don't have the plugin yet? install it then click "run inline in claude" again.
added explicit intent section, separated inputs with environment setup guidance, broke procedure into sequential steps with input/output contracts, extracted decision logic into dedicated section with edge cases, formalized output contract and backup storage details, clarified outcome signals and anti-patterns
a code-editing toolkit for agents. provides the oce command, which wraps reads, searches, edits, validation, formatting, backups, and multi-file transactions behind one predictable interface that always validates after writing and rolls back on syntax failure.
this skill exists because raw sed, awk, and perl -i are too sharp for autonomous use. they apply changes silently, give regex-style false matches, leave no audit trail, and can't roll back. oce keeps the speed of cli editing while adding the safety rails an agent needs.
use this skill for any task that involves reading, understanding, searching, or modifying source code in a project across javascript, typescript, vue, react, node, python, go, ruby, php, java, rust, c/c++, shell scripts, json, yaml, html, css, sql, and markdown. trigger whenever the user asks to fix a bug, add a feature, refactor, rename, restructure, search a codebase, locate a function or symbol, apply a patch, modify configuration, or make any multi-file change. use when the user references files by path or name and wants something done to them, when reviewing or auditing code, or when planning an edit before making it. prefer oce over raw sed/awk/perl -i for any persistent edit; those are read-only here.
required:
bash --version).oce/ for backups and transaction state)oce doctor): node, patch, diff, grep, acornoptional but recommended for full feature set:
external connections:
environment setup:
<skill-path> refers to where the skill is installed (typically /home/agent/.skills/agentic-cli-coding or similar)alias oce="bash <skill-path>/scripts/oce.sh" (recommended for agentic use)bash <skill-path>/scripts/oce.sh <subcommand> (works without setup)bash <skill-path>/scripts/install.sh adds wrapper to pathoce doctor
exit code 0 with "setup ok" means toolkit is ready. all core tools must be present. missing optional tools only affect formatting for that language; editing still works.
if "oce: command not found" appears, the alias wasn't set. use direct invocation instead: bash <skill-path>/scripts/oce.sh <subcommand>.
discover project structure and locate relevant code:
oce tree --depth 2 # outputs: nested tree of project layout
oce find "<keyword>" --type <lang> # outputs: list of files matching keyword and language type
oce ast symbols path/to/file.js # outputs: functions, classes, exports in file
input: keyword (string to search), file path (string), language type (js, ts, py, go, etc.)
output: file paths and/or symbol names matching the search
note: do not skip orientation. repository conventions vary; assumptions break codebases.
fetch file content with surrounding context:
oce read src/server.js --around "handleAuth" --context 20
oce grep-context "TODO" src/server.js -c 5
oce read src/auth.js --lines 45:120
input: file path (string), anchor text or line range (string or int:int), context window (integer, default 5)
output: file content with line numbers, context highlighted
note: read enough surrounding context to predict what your edit will affect. the cheapest break is editing a function in isolation without seeing its callers.
for non-trivial edits, state the plan explicitly before running any edit command:
for multi-file changes, start a transaction:
TXN=$(oce transaction begin)
input: (none; creates unique transaction id)
output: transaction id (stored in .oce/transactions/)
then pass --txn "$TXN" to every subsequent edit command. commit (validates everything atomically) or rollback (restores every file) at the end.
choose edit command based on change type:
tiny surgical changes: exact-string replace with oce replace
oce replace src/server.js \
--old "return data;" \
--new "return sanitize(data);"
input: file path, old text (literal match), new text
output: number of replacements made, backup location
insert code at anchor: oce insert with line or text anchor
oce insert src/server.js --before-match "// END ROUTES" --content-file /tmp/new_route.js
oce insert src/server.js --line 42 --content "new line here"
input: file path, anchor (text match or line number), new content (inline or file)
output: insertion point, backup location
remove lines: oce delete by line range or match
oce delete src/server.js --lines 10:15
oce delete src/server.js --match "TODO.*\n"
input: file path, line range or regex match
output: lines deleted, backup location
multi-line precision: write unified diff and apply with oce patch apply
cat > /tmp/fix.patch <<'EOF'
--- a/src/auth.js
+++ b/src/auth.js
@@ -12,6 +12,10 @@
function authenticate(req) {
+ if (!req.headers.authorization) {
+ throw new Error('Missing auth header');
+ }
const token = req.headers.authorization.split(' ')[1];
EOF
oce patch apply /tmp/fix.patch
input: unified diff file (text)
output: files patched, backup locations, validation results
rename js/jsx identifier: scope-aware rename with oce ast rename
oce ast rename src/auth.js --old "validateToken" --new "verifyToken"
input: file path, old identifier name, new identifier name
output: number of references renamed, backup location
note: js/jsx only; walks ast and renames only real references, not strings or comments.
replace function/class body: oce ast replace-symbol
oce ast replace-symbol src/auth.js --symbol "authenticate" --body "$(cat /tmp/new_body.js)"
input: file path, symbol name (function or class), new body text
output: symbol replaced, backup location
new file or full rewrite: oce write
oce write path/to/newfile.js --content "$(cat /tmp/content.js)"
oce write src/config.json --content '{"debug":true}'
input: file path, content (inline or stdin)
output: file written, backup of prior version if file existed
multi-file transaction: chain any edit commands with --txn "$TXN"
TXN=$(oce transaction begin)
oce replace src/auth.js --old "validateToken" --new "verifyToken" --all --txn "$TXN"
oce replace src/api.js --old "validateToken" --new "verifyToken" --all --txn "$TXN"
oce transaction validate "$TXN"
oce transaction commit "$TXN" # or rollback "$TXN" if anything looks wrong
input: transaction id (string)
output: per-command outputs (replacements made, files affected), final validation report
after every edit, validate and verify:
oce diff src/server.js # compare current vs. most recent backup
oce validate src/server.js # syntax check (auto-runs after edit, but you can re-check)
input: file path
output: diff/validation result
auto-validation catches syntax errors and rolls back on failure. you don't need to re-validate manually, but you should oce diff to confirm the change matches your intent.
if an edit broke something, backups are auto-created before every destructive operation:
oce backup list src/server.js # see all snapshots for that file
oce backup diff src/server.js # compare current vs. most recent backup
oce backup restore src/server.js # restore most recent backup
oce backup restore src/server.js --at 3 # restore 4th-most-recent (0-indexed)
oce backup clean 30 # remove backups older than 30 days
input: file path, backup index (optional), age threshold in days (optional)
output: backup restored, list of snapshots, or cleanup summary
backups live in .oce/backups/ in the workspace.
setup method: if the skill is used once, use direct invocation bash <skill-path>/scripts/oce.sh <subcommand>. if used repeatedly in same session, set alias once with alias oce="bash <skill-path>/scripts/oce.sh". if used across sessions or by multiple agents, run bash <skill-path>/scripts/install.sh for persistent installation.
orientation required: if you "know" where the code is from training data, still run oce tree and oce find. repository conventions vary; skip orientation at your peril.
read context: if you're changing a function, always read with --context 20 or higher. if you're changing a single line in isolation, --context 5 is acceptable.
edit tool choice: if the change is exact-string and single-line, use oce replace. if it spans multiple lines and you have a unified diff, use oce patch apply. if it's multi-line but no diff handy, use oce insert or oce delete in sequence or write a diff first. if it's a js/jsx identifier rename, use oce ast rename. if it's an entire function body, use oce ast replace-symbol. if you're creating a new file, use oce write.
transaction required: if editing one file, no transaction needed. if editing two or more files for a single logical change, use TXN=$(oce transaction begin) and --txn "$TXN" on every edit. commit or rollback atomically.
non-unique match: if oce replace --old "X" fails with "ambiguous match", either make --old more specific (add surrounding context like indent or closing brace) or pass --all if you genuinely want every occurrence changed.
formatting: oce format only runs if the formatter is installed on the local system. check oce doctor output if you care about canonical formatting. formatting is optional; validation is not.
binary files: if oce refuses to edit a file, it's likely binary. do not attempt to bypass with env vars or override flags. reconsider the approach.
edge case: rate limits: not applicable; this skill is local-only.
edge case: auth expiry: not applicable; no external api connections.
edge case: empty result sets: if oce find returns zero matches, the keyword or language type was wrong or the code doesn't exist. re-read the codebase with oce tree and try again.
edge case: network timeout: not applicable; local filesystem only.
edge case: syntax validation failure: if a file fails validation after edit, oce automatically rolls back the change and reports the syntax error. check the error message, fix the logic, and try again.
edge case: patch apply failure: if oce patch apply fails with "patch does not apply cleanly", the file has changed since you wrote the diff. re-read the current file, update the diff, and try again.
success indicators:
oce commands exit with code 0 on success, non-zero on error.oce/backups/<filename>.<timestamp> before destructive operation--json flag produces single-line json object on stdout conforming to schema in references/json-schema.mdbackup storage:
.oce/backups/ inside current working directory<filename>.<iso8601-timestamp>.gzaudit trail:
.oce/edit.log inside current working directoryoce backup clean)validation output:
file state after successful edit:
.oce/backups/oce format is explicitly calledtransaction state:
.oce/transactions/<txn-id>/ with per-file backup copiesthe user knows the skill worked when:
oce doctor outputs "setup ok" and lists all available toolsoce tree --depth 2 outputs a readable tree of the project structureoce find <keyword> outputs file paths containing the keywordoce read <file> outputs the file content with correct syntax highlighting and line numbersoce replace/oce insert/oce delete/oce patch apply output a message like "replaced X occurrences" or "inserted Y lines" and exit with code 0oce diff <file> outputs a readable unified diff showing exactly what changedoce backup list <file> outputs a list of available snapshotsoce backup restore <file> restores the file and outputs confirmationoce transaction commit outputs success with no rollback.oce/backups/full documentation lives in the skill's reference directory:
references/json-schema.md exact json output schema for every command; read when chaining or parsing programmaticallyreferences/workflows.md worked examples: bug fix flow, feature add flow, refactor flow, dependency upgrade flow, vue/react component editingreferences/language-support.md per-language validator and formatter matrix; what works without extra installs, what needs local toolingreferences/troubleshooting.md symptom to cause to fix table for common failuresstorage and state:
.oce/ inside current working directory.oce/ to .gitignoreoce backup clean 30anti-patterns to avoid:
sed -i, awk redirected to same file, or perl -i; use oce replace or oce patch insteadoce write for small edits; use replace, patch, or insert instead--old to oce replace without --all; command will fail with "ambiguous match" erroroce diff after non-trivial edits; catches logic errors auto-validation missesoce doctor if you careoce refuses by designoce read or oce tree firstone-line summary: oce <verb> <file> [options] every verb backs up first, validates after, and rolls back on syntax failure. use transactions for multi-file changes. read before you write. plan before you execute.
credits: original by encryptshawn on clawhub. enriched per implexa standards.