tool-scripts

tool-scripts is a cursor rule for Cursor from mergisi/openclaw-rules. It costs 1,135 tokens per session, scanned A, original, MIT.

A set of rules and a template for writing standalone command-line scripts for OpenClaw agents, software agents that can run tools. The scripts use built-in Node.js features and print results for the agent to read.

In plain words
What is it for?
Use it when creating Node.js tool scripts that accept command-line arguments, call web services, read configuration, and return text or JSON.
Why use it?
It provides a consistent way to build small scripts without adding third-party packages. It also clarifies how scripts receive options, load secrets, and report errors.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: built for openclaw.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is const envPath = path.resolve(__dirname, "../secrets/.env");.

Good fit Use it when creating Node.js tool scripts that accept command-line arguments, call web services, read configuration, and return text or JSON.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/mergisi/openclaw-rules
agentmods
npx agentmods add rules/mergisi/openclaw-rules/tool-scripts

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tool-scripts

README.md
[![agentmods](https://agentmods.dev/badge/rules/mergisi/openclaw-rules/tool-scripts/github.svg)](https://agentmods.dev/rules/mergisi/openclaw-rules/tool-scripts)
Your own site
<a href="https://agentmods.dev/rules/mergisi/openclaw-rules/tool-scripts"><img src="https://agentmods.dev/badge/rules/mergisi/openclaw-rules/tool-scripts/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tool-scripts

Your own site · 80×15
<a href="https://agentmods.dev/rules/mergisi/openclaw-rules/tool-scripts"><img src="https://agentmods.dev/badge/rules/mergisi/openclaw-rules/tool-scripts.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,135 This file is loaded in full into every session.
When invoked 1,135 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01135 $0.01135
Opus 5.5 $0.00454 $0.00454
Sonnet 5.5 $0.00227 $0.00227
Haiku 4.5 $0.00113 $0.00113

Measured 1mo ago against content hash f1d0ce40d99f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

tool-scripts scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

project-rules/tool-scripts.mdc · 136 lines

How it starts

The opening of the file, as written. The whole thing — 136 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Writing Tool Scripts

When creating tool scripts for OpenClaw agents, follow these patterns.

Rules

  1. Zero npm dependencies. Use only Node.js built-ins: https, fs, path, crypto.
  2. CommonJS format. Use .cjs extension and require().
  3. Self-contained. Each script must work standalone with node tools/script.cjs.
  4. Accept CLI arguments. Date ranges, flags, output format.
  5. Print to stdout. The agent captures stdout. Use console.log() for output, console.error() for errors.

Template

#!/usr/bin/env node
// Tool Name — Short description
// Usage: node tool-name.cjs [date] [--json]
// Requires: API_KEY in .env or secrets/
const https = require("https");
const path = require("path");
const fs = require("fs");

// Load config
const envPath = path.resolve(__dirname, "../secrets/.env");
if (fs.existsSync(envPath)) {
  fs.readFileSync(envPath, "utf-8").split("\n").forEach(line => {
    const [k, ...v] = line.split("=");
    if (k && !k.startsWith("#")) process.env[k.trim()] = v.join("=").trim();
  });
}

const API_KEY = process.env.API_KEY;
if (!API_KEY) { console.error("Set API_KEY in secrets/.env"); process.exit(1); }

// HTTP helper — works with any JSON API
function httpGet(url, headers = {}) {
  return new Promise((resolve, reject) => {
    const u = new URL(url);
    const req = https.request({
      hostname: u.hostname,
      path: u.pathname + u.search,
      method: "GET",
      headers: { "User-Agent": "OpenClaw-Agent/1.0", ...headers },
      timeout: 15000,
    }, res => {
      let body = "";
      res.on("data", d => body += d);
      res.on("end", () => {
        try { resolve(JSON.parse(body)); }
        catch { resolve(body); }
      });
    });
    req.on("error", reject);
    req.on("timeout", () => { req.destroy(); reject(new Error("timeout")); });
    req.end();
  });
}

function httpPost(url, headers, data) {
  return new Promise((resolve, reject) => {
    const body = typeof data === "string" ? data : JSON.stringify(data);
    const u = new URL(url);
    const req = https.request({
      hostname: u.hostname,
      path: u.pathname + u.search,
      method: "POST",
      headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body), ...headers },
      timeout: 15000,
    }, res => {
      let b = "";
      res.on("data", d => b += d);
      res.on("end", () => {
        try { resolve(JSON.parse(b)); }
        catch { resolve(b); }
      });
    });
    req.on("error", reject);
    req.on("timeout", () => { req.destroy(); reject(new Error("timeout")); });
    req.write(body);
    req.end();
  });
}

// Date helpers
const yesterday = new Date(Date.now() - 86400000).toISOString().slice(0, 10);
const date = process.argv[2] || yesterday;
const jsonOutput = process.argv.includes("--json");

async function main() {
  // Your tool logic here
  const data = await httpGet(`https://api.example.com/data?date=${date}`);

  if (jsonOutput) {
    console.log(JSON.stringify(data, null, 2));
  } else {
    console.log(`Report for ${date}`);
    console.log("=".repeat(40));
    // Format and print results
  }
}

main().catch(e => { console.error("Fatal:", e.message); process.exit(1); });

Read the full file on GitHub · 136 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 136 lines · 1,135 tokens per session scan A f1d0ce40d99f

Subscribe to this mod's changes

tool-scripts is a cursor rule published in the GitHub repository mergisi/openclaw-rules (2 stars, last pushed 7mo ago), licensed MIT. It adds 1,135 tokens to every session, about $0.0045 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.