script-creation-rules
SKILL.md
Script Creation Rules
Rule (CRITICAL)
When creating scripts, follow this priority order:
- First choice: Shell script one-liners
- Second choice: TypeScript with Deno (only when variables or complex branching are necessary)
- Prohibited: Node.js and Python
Priority Order
1. Shell Script One-Liners (PREFERRED)
Use shell script one-liners for simple operations:
# File operations
find . -name "*.js" -type f | xargs grep "pattern"
# Text processing
cat file.txt | grep "pattern" | sed 's/old/new/g'
# File counting
ls -1 | wc -l
# Directory operations
mkdir -p path/to/dir && cd path/to/dir
# Conditional execution
[ -f file.txt ] && echo "exists" || echo "not found"
2. TypeScript with Deno (When Necessary)
Use TypeScript with Deno only when:
- Variables are needed for complex logic
- Complex branching/conditionals are required
- Error handling beyond simple shell constructs is needed
Execution: Always use sfw deno run <file> to execute Deno scripts.
// Example: Complex script with variables and branching
const files = Deno.readDirSync(".");
const results: string[] = [];
for (const file of files) {
if (file.isFile && file.name.endsWith(".ts")) {
const content = Deno.readTextFileSync(file.name);
if (content.includes("pattern")) {
results.push(file.name);
}
}
}
console.log(results.join("\n"));
Execute with:
sfw deno run --allow-read script.ts
IMPORTANT: Always use sfw deno run instead of deno run directly.
Prohibited Technologies
The following are strictly prohibited:
- Node.js:
node script.js,npm run, etc. - Python:
python script.py,python3 script.py,pip install, etc. - Direct Deno execution:
deno run(usesfw deno runinstead)
Decision Flow
When creating a script:
- Can it be done with a shell one-liner? -> Use shell script
- Does it need variables or complex logic? -> Use TypeScript with Deno (execute with
sfw deno run <file>) - Never use Node.js or Python
- Never use
deno rundirectly -> Always usesfw deno run
Examples
Good: Shell One-Liner
# Find and count TypeScript files
find . -name "*.ts" -type f | wc -l
Good: TypeScript with Deno
// Complex file processing with error handling
try {
const files = Array.from(Deno.readDirSync(".")).filter((f) => f.isFile && f.name.endsWith(".ts"));
for (const file of files) {
const content = Deno.readTextFileSync(file.name);
// Complex processing...
}
} catch (error) {
console.error("Error:", error);
}
Bad: Node.js
// DO NOT USE
const fs = require("fs");
const files = fs.readdirSync(".");
Bad: Python
# DO NOT USE
import os
files = os.listdir('.')
Common Patterns
File Operations
# Shell one-liner
find . -type f -name "*.md" -exec wc -l {} \;
Text Processing
# Shell one-liner
grep -r "pattern" . | sed 's/old/new/g' | sort | uniq
Conditional Logic (Simple)
# Shell one-liner
[ -d "dir" ] && echo "exists" || mkdir -p "dir"
Conditional Logic (Complex)
// TypeScript with Deno
const dirs = ["dir1", "dir2", "dir3"];
for (const dir of dirs) {
try {
const stat = Deno.statSync(dir);
if (stat.isDirectory) {
console.log(`${dir} exists`);
}
} catch {
Deno.mkdirSync(dir, { recursive: true });
console.log(`Created ${dir}`);
}
}
Execute with:
sfw deno run --allow-read --allow-write script.ts
Weekly Installs
7
Repository
totto2727-dotfi…s/agentsFirst Seen
Feb 19, 2026
Security Audits
Installed on
github-copilot7
codex7
kimi-cli7
gemini-cli7
amp7
opencode7