Tool & Script Development
TRIGGER
Activate when user wants to build any standalone tool, script, CLI, automation, scraper, helper, or utility — not app/website code.
CORE RULES
-
Pick the right language for the job
- Quick Windows automation / file ops → PowerShell
- Cross-platform CLI / scraping / APIs → Python
- Fast single-binary / concurrency → Go
- Web-connected tool / easy deps → Node.js
- Ask if unsure; default to Python for general tools.
-
Always make it runnable, not snippets
- Full file, not fragments.
- Include
if __name__ == "__main__":(Python) /fn main()(Go) / shebang (PowerShell/Node). - No placeholders like
// TODOunless explicitly requested.
-
Structure
tool-name/ tool.py # main entry requirements.txt # deps (if Python) README.md # usage (only if asked) -
Argument parsing — never hardcode inputs
- Python:
argparse(orclickfor richer CLIs) - Node:
process.argv/commander - Go:
flagpackage - PowerShell:
param()block - Support
-h/--helpautomatically.
- Python:
-
Error handling (non-negotiable)
- Wrap network/IO in try/except; print clear messages, exit non-zero on failure.
- Never crash with raw stack traces for expected errors (file missing, bad URL, rate limit).
- Respect rate limits / add small delays for scrapers.
-
OPSEC by default
- No secrets hardcoded — read from env vars or a local
.env(gitignored). - Never log tokens/keys.
- Rotate user-agents; disguise automation as normal traffic.
- Cover geography: never expose real location (use VPN + cover country).
- No secrets hardcoded — read from env vars or a local
-
Output
- Print concise, parseable results (JSON or table).
- Write results to a file when bulk (e.g.
results.json/results.txt).
WORKFLOW
- Clarify: what does it do, input source, output format, target OS.
- Choose language + deps.
- Write the full tool with arg parsing + error handling.
- Show a run example:
python tool.py --input x.txt --out results.json. - Note OPSEC/usage caveats.
EXAMPLE (Python CLI skeleton)
pythonimport argparse, sys, json def main(): p = argparse.ArgumentParser() p.add_argument("--input", required=True) p.add_argument("--out", default="results.json") args = p.parse_args() try: data = open(args.input).read().splitlines() except OSError as e: print(f"[!] cannot read {args.input}: {e}", file=sys.stderr) sys.exit(1) # ... process ... json.dump({"count": len(data)}, open(args.out, "w")) print(f"[+] saved {args.out}") if __name__ == "__main__": main()


