一键导入
ben-script
Create a new TypeScript utility script in the `~/bin/ts` project that will be compiled to a standalone executable with auto-rebuild capability.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create a new TypeScript utility script in the `~/bin/ts` project that will be compiled to a standalone executable with auto-rebuild capability.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | ben-script |
| description | Create a new TypeScript utility script in the `~/bin/ts` project that will be compiled to a standalone executable with auto-rebuild capability. |
Create a new TypeScript utility script in the ~/bin/ts project that will be compiled to a standalone executable with auto-rebuild capability.
Before starting, read these files to understand the system:
~/bin/ts/README.md - Project architecture and workflow~/bin/ts/src/manifest.ts - Script registry and examples~/AGENTS.md - Section on "Working with TypeScript Modules (bin/ts)"~/bin/ts/src/ directory - Browse 1-2 existing scripts for patternsEvery new script must:
~/bin/ts/src/#!/usr/bin/env tsxyargs for CLI argument parsing (already in dependencies)manifest.tsRead the following files (in parallel when possible):
Read: ~/bin/ts/README.md
Read: ~/bin/ts/src/manifest.ts
Read: ~/AGENTS.md (sections on bin/ts)
Glob: ~/bin/ts/src/*.ts (to see existing scripts)
Pick 1-2 similar scripts to read as examples:
Read: ~/bin/ts/src/<similar-script>.ts
my-script)src/lib/ to use:
logger.ts - logError, logInfo, logSuccess, etc.git.ts - execGit, execGitSafeprompts.ts - prompt, confirmAction, promptYesNopackage.jsonWrite the script following this template structure:
#!/usr/bin/env tsx
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
// Import from lib/ if needed
// import { logError, logInfo, logSuccess } from "./lib/logger";
async function main(): Promise<void> {
const argv = await yargs(hideBin(process.argv))
.scriptName("my-script")
.usage("$0 [options]")
.option("option-name", {
alias: "o",
type: "string",
description: "Description",
default: "default-value",
})
.help()
.alias("help", "h")
.example("$0 --option value", "Example usage")
.argv;
// Your script logic here
console.log("Script output");
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
Key points:
Add an entry to ~/bin/ts/src/manifest.ts:
export const scripts: Record<string, ScriptEntry> = {
// ... existing scripts ...
"my-script": {
file: "my-script.ts",
description: "Clear, concise description of what it does",
},
};
Maintain alphabetical order within logical groupings (check existing groupings).
cd ~/bin/ts
bun run build
This will:
dist/bin/ with auto-rebuildsrc/ for developmentTest the script:
my-script --help
my-script [test with actual arguments]
Run quality checks:
cd ~/bin/ts
bun run typecheck # Type checking
bun run check # Linting and formatting
If there are issues, fix them before completing.
Add a comment block at the top of the script explaining:
import { logError, logInfo, logSuccess } from "./lib/logger";
import { execGit, execGitSafe } from "./lib/git";
import { prompt, confirmAction } from "./lib/prompts";
const argv = await yargs(hideBin(process.argv))
.command("subcommand", "Description", (yargs) => {
return yargs.option("opt", { type: "string" });
})
.demandCommand(1, "You must specify a command")
.help()
.argv;
try {
// risky operation
} catch (error) {
logError(`Operation failed: ${error}`);
process.exit(1);
}
The script is complete when:
src/manifest.tsbun run build completes successfullybun run typecheck passesbun run check passessrc/lib/Inform the user:
<script-name> in their PATHben-scripts to see all available scripts