agentleFS
tboome33tboome33/obsidian-mcp-router/skills/write-patch/SKILL.md

write-patch

Skill1 starsChanged 7 months agoApache-2.0View on GitHub

Surgical edit — insert/replace under a specific heading, block id, or frontmatter key. Use when you need to modify ONE section of a long note without rewriting the whole file.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Call the obsidian-router patch_file MCP tool with arguments parsed from $ARGUMENTS.

    line 16
  2. Very specific:

    If the call fails, do NOT silently redo it with direct-filesystem tools (Read/Edit/Write on the vault's real path):

    line 50
  3. Distinctive:

    After the patch, report what was patched (target type, target, operation).

    line 58

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

write-patch

Call the obsidian-router patch_file MCP tool with arguments parsed from $ARGUMENTS.

Arguments

Required:

  • path — file path relative to vault root.
  • operation — append, prepend, or replace.
  • targetType — heading, block, or frontmatter.
  • target — the target identifier:
    • heading → the FULL heading path joined by :: (e.g. Section 1::Subsection). Just the heading name alone won't work; the parent path is required.
    • block → the block id without the leading ^ (e.g. atp-config).
    • frontmatter → the property name (e.g. status).
  • content — new content. String for heading/block; for frontmatter accepts string/number/boolean/array/object (types preserved).

Optional:

  • vault — omit for default.
  • targetDelimiter — override the heading delimiter (default ::).
  • createTargetIfMissing — create the target if absent (heading/frontmatter only).
  • applyIfContentPreexists — skip if target already contains the content (idempotency).
  • trimTargetWhitespace — trim whitespace around the target before applying.
  • ifMatch — a contentSha256 from a prior get_file. Whole-file precondition: the patch is refused with a 409 conflict if the file changed since you read it. (The precondition is checked before patching; the patch itself is not hash-locked — this catches patching stale content, it does not make the patch atomic.)

Argument parsing from $ARGUMENTS

This tool has many parameters. If $ARGUMENTS doesn't make the intent crystal-clear, ask the user before calling. A typical bare invocation as $ARGUMENTS should be path=... operation=... targetType=... target=... content=....

Common quick patterns

  • Set a frontmatter key: path=X operation=replace targetType=frontmatter target=<key> content=<value> (consider using write-frontmatter-set instead — friendlier wrapper).
  • Append under a heading: path=X operation=append targetType=heading target="Section::Sub" content="...".
  • Replace a block: path=X operation=replace targetType=block target=<block-id> content="...".

On failure — remediate, NEVER fall back to filesystem writes

If the call fails, do NOT silently redo it with direct-filesystem tools (Read/Edit/Write on the vault's real path):

  • Connection error (ECONNREFUSED, timeout) → vault closed; list_vaults, then ask the user to open it via the openUri link and wait.
  • Validation / API error (HTTP 4xx, e.g. invalid-target = heading not the FULL ::-joined path) → fix the arguments, or use a coarser router tool (write_file, append_to_file).

Rationale + message template: the default-vault-health-check convention (canonical source).

Output

After the patch, report what was patched (target type, target, operation).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.