agentsclimarketplace

Nix agent tool design

Skill ComeOnOliver/skillshub/skills/Mind-Dragon/atoolix/nix-agent-tool-design

🧠 The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill nix-agent-tool-design

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

8.7 KB, ~2.2k tokens by cl100k_base, as published. Nobody here has run it

*nix Agent Tool Design

A single run(command="...") tool with Unix-style commands outperforms a catalog of typed function calls.

Credit: This design was authored by the backend lead at Manus and is implemented in the open-source agent-clip runtime by @epiral. This skill packages that knowledge for use in OpenCode, OpenClaw, and Pinix.


Core Philosophy

Unix and LLMs made the same architectural decision 50 years apart: everything is text.

  • Unix: text streams, pipes, exit codes, --help, stderr
  • LLMs: tokens in, tokens out β€” they only understand and produce text

This convergence means the Unix terminal interface is the LLM's native tool interface. Don't invent a new one.


Principle 1: Single run Tool

Replace a catalog of typed function calls with one tool:

run(command="...")

All capabilities exposed as CLI subcommands. The LLM composes strings instead of switching between unrelated API schemas.

Why it works:

  • LLMs have seen billions of shell commands in training data β€” they already know CLI
  • Command selection = string composition in one namespace
  • Function selection = context-switching between N unrelated APIs
  • Reduces "which tool?" cognitive load; agent focuses on "what do I need?"

Example reduction:

# Function-calling (3 calls):
read_file(path="/var/log/app.log")
search_text(text=<file>, pattern="ERROR")
count_lines(text=<matches>)

# CLI (1 call):
run(command="cat /var/log/app.log | grep ERROR | wc -l")

Principle 2: Chain Parser (parseChain)

Support four Unix chain operators so a single tool call = a complete workflow:

OperatorBehavior
|Pipe: stdout of previous β†’ stdin of next
&&And: next only if previous succeeded (exit 0)
||Or: next only if previous failed (exit β‰  0)
;Seq: next regardless of result

Examples:

curl -sL $URL -o data.csv && cat data.csv | head 5    # download β†’ inspect
cat access.log | grep "500" | sort | head 10           # read β†’ filter β†’ sort β†’ top 10
cat config.yaml || echo "config not found, using defaults"  # try A, fall back to B

Principle 3: Progressive --help Discovery (3 levels)

Never stuff full documentation into the system prompt. Use progressive disclosure:

Level 0 β€” Tool description β†’ command list (injected at conversation start)

Available commands:
  cat    β€” Read a text file. For images use 'see'. For binary use 'cat -b'.
  see    β€” View an image (auto-attaches to vision)
  ls     β€” List files in current topic
  write  β€” Write file. Usage: write <path> [content] or stdin
  grep   β€” Filter lines matching a pattern (supports -i, -v, -c)
  memory β€” Search or manage memory
  clip   β€” Operate external environments (sandboxes, services)

Level 1 β€” command with no args β†’ usage string

run(command="memory")
β†’ [error] memory: usage: memory search|recent|store|facts|forget

Level 2 β€” command subcommand with missing args β†’ specific parameters

run(command="memory search")
β†’ [error] memory: usage: memory search <query> [-t topic_id] [-k keyword]

Requirement: Every command and subcommand MUST have complete help output. A good help message means one-shot success. A missing one means a blind guess.


Principle 4: Error Messages as Navigation

Every error must contain: what went wrong + what to do instead.

# Traditional (useless to agents):
cat: binary file (standard output)

# Agent-optimized:
[error] cat: binary image file (182KB). Use: see photo.png
[error] unknown command: foo β€” Available: cat, ls, see, write, grep, memory, clip
[error] clip "sandbox" not found. Use 'clip list' to see available clips

Production lesson: Silent stderr caused 10 blind retries to find the right package manager. Always surface stderr on failure.

# WRONG:
if stdout != "": discard stderr

# RIGHT:
always attach stderr on failure:
output + "\n[stderr] " + stderr

Principle 5: Consistent Output Format

Append [exit:N | Xms] to every tool result:

file1.txt
file2.txt
dir1/
[exit:0 | 12ms]

Exit code semantics (LLMs already know these):

  • exit:0 β€” success
  • exit:1 β€” general error
  • exit:127 β€” command not found

Duration signals cost:

  • 12ms β€” cheap, call freely
  • 3.2s β€” moderate
  • 45s β€” expensive, use sparingly

Consistent format = agent internalizes pattern over the conversation. Inconsistency makes every call feel like the first.


Principle 6: Two-Layer Architecture (CRITICAL)

Raw command output β‰  what the LLM should receive. Two hard LLM constraints drive this:

  • Constraint A: Context window is finite and expensive
  • Constraint B: LLMs cannot process binary data (produces meaningless high-entropy tokens that degrade surrounding attention)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Layer 2: LLM Presentation Layer                β”‚  ← Designed for LLM constraints
β”‚  Binary guard | Truncation+overflow | Meta      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Layer 1: Unix Execution Layer                  β”‚  ← Pure Unix semantics
β”‚  Command routing | pipe | chain | exit code     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CRITICAL: Layer 1 must be raw, lossless, metadata-free. If you truncate in Layer 1, grep only searches the first 200 lines. If you add [exit:0] in Layer 1, it becomes grep data. Processing only happens in Layer 2.

Layer 2 Mechanisms

A. Binary Guard

Null byte detected β†’ binary
UTF-8 validation failed β†’ binary  
Control character ratio > 10% β†’ binary

β†’ [error] binary image (182KB). Use: see photo.png
β†’ [error] binary file (1.2MB). Use: cat -b file.bin

B. Overflow Mode

Output > 200 lines or > 50KB?
  β†’ Truncate to first 200 lines (rune-safe)
  β†’ Write full output to /tmp/cmd-output/cmd-{n}.txt
  β†’ Return:
    [first 200 lines]
    --- output truncated (5000 lines, 245.3KB) ---
    Full output: /tmp/cmd-output/cmd-3.txt
    Explore: cat /tmp/cmd-output/cmd-3.txt | grep <pattern>
             cat /tmp/cmd-output/cmd-3.txt | tail 100
    [exit:0 | 1.2s]

The agent already knows grep, head, tail β€” overflow mode turns large data into a familiar navigation problem.

C. Metadata Footer

[exit:0 | 1.2s]

Appended after the pipe chain completes. Never in Layer 1.

D. stderr Attachment

output + "\n[stderr] " + stderr

Always on failure. Never drop it when stdout is non-empty.


When NOT to Use CLI

Typed APIs may be better when:

  • Strongly-typed interactions β€” DB queries, GraphQL, schema validation required
  • High security β€” CLI string concatenation has injection risk; use typed params + sandbox isolation
  • Native multimodal β€” Pure audio/video binary stream processing

Safety boundaries are external (not iteration limits):

  • Sandbox isolation (e.g., BoxLite containers)
  • API spending caps
  • User cancellation with graceful shutdown

Production War Stories

StoryRoot CauseFixLesson
PNG caused 20 iterations of thrashingNo binary guard in Layer 2isBinary() + Use: see photo.pngReturn garbage = agent goes blind
10 blind retries to find package managerSilent stderr when stdout non-emptyAlways attach stderr on failurestderr is most needed when commands fail
5,000-line log overwhelmed contextNo overflow modeTruncate + write to /tmp + give explore commandsA map beats the entire territory

Implementation Reference

Original implementation by @epiral:

RepoDescription
epiral/agent-clipThe agent as a Pinix Clip β€” full Go implementation of these principles
epiral/pinixDecentralized runtime platform that hosts Clips (BoxLite micro-VMs, Edge Clips)
FileResponsibility
internal/tools.goCommand routing, single run entry point
internal/chain.goPipe/&&/||/; chain parser
internal/loop.goTwo-layer agentic loop
internal/fs.goBinary guard
internal/clip.gostderr handling
internal/browser.goVision auto-attach
internal/memory.goSemantic memory commands

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,970. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.