Show HN: 使用 Unix 管道执行 Markdown 文件
3 分•作者: jedwhite•6 个月前
我想像运行 shell 脚本一样运行 Markdown 文件。因此,我构建了一个开源工具,允许你使用 shebang 将它们通过 Claude Code 管道传输,并提供完整的 stdin/stdout 支持。
task.md:
```
#!/usr/bin/env claude-run
分析此代码库并总结其架构。
```
然后:
```
chmod +x task.md
./task.md
```
这些不仅仅是提示。Claude Code 具有工具使用功能,因此 Markdown 文件可以运行 shell 命令、编写脚本、读取文件、进行 API 调用。提示会编排所有内容。
一个运行你的测试并报告结果的脚本 (`run_tests.md`):
```
#!/usr/bin/env claude-run --permission-mode bypassPermissions
运行 ./test/run_tests.sh 并总结通过和失败的内容。
```
由于 stdin/stdout 的工作方式与任何 Unix 程序一样,你可以将它们链接起来:
```
cat data.json | ./analyze.md > results.txt
git log -10 | ./summarize.md
./generate.md | ./review.md > final.txt
```
或者将它们与传统的 shell 脚本混合使用:
```
for f in logs/*.txt; do
cat "$f" | ./analyze.md >> summary.txt
done
```
这为我们替换了大量的 Python 粘合代码。需要 LLM 编排库的任务现在是使用标准 Unix 工具编写的 Markdown 文件。它们可以作为构建块进行组合,作为 cron 作业运行等。
我们没有预料到的一件事是,这些比 shell 脚本更可审计(和可共享)。像 `curl -fsSL <https://bun.com/install | bash` 这样的安装脚本可以变成:
```
`curl -fsSL https://bun.com/install.md | claude-run`
```
其中 install.md 类似于“检测我的操作系统和架构,从 GitHub 发布版下载正确的二进制文件,解压到 ~/.local/bin,更新我的 shell 配置。” 正常人实际上可以阅读和验证这一点。
(真正酷的) 可执行 Markdown 想法和可审计性示例来自 Pete Koomen (@koomen on X)。正如 Pete 所说:“Markdown 感觉越来越重要,但我认为大多数人还没有完全理解这一点。”
我们实现了它并添加了 Unix 管道语义。目前与 Claude Code 配合使用 - 希望也能支持其他 AI 编码工具。如果你希望为自动化作业进行单独计费,你还可以通过不同的云提供商(AWS Bedrock 等)路由脚本。
GitHub: <https://github.com/andisearch/claude-switcher>
你会将它用于哪些工作流程?
查看原文
I wanted to run markdown files like shell scripts. So I built an open source tool that lets you use a shebang to pipe them through Claude Code with full stdin/stdout support.<p>task.md:<p><pre><code> #!/usr/bin/env claude-run
Analyze this codebase and summarize the architecture.
</code></pre>
Then:<p><pre><code> chmod +x task.md
./task.md
</code></pre>
These aren't just prompts. Claude Code has tool use, so a markdown file can run shell commands, write scripts, read files, make API calls. The prompt orchestrates everything.<p>A script that runs your tests and reports results (`run_tests.md`):<p><pre><code> #!/usr/bin/env claude-run --permission-mode bypassPermissions
Run ./test/run_tests.sh and summarize what passed and failed.
</code></pre>
Because stdin/stdout work like any Unix program, you can chain them:<p><pre><code> cat data.json | ./analyze.md > results.txt
git log -10 | ./summarize.md
./generate.md | ./review.md > final.txt
</code></pre>
Or mix them with traditional shell scripts:<p><pre><code> for f in logs/\*.txt; do
cat "$f" | ./analyze.md >> summary.txt
done
</code></pre>
This replaced a lot of Python glue code for us. Tasks that needed LLM orchestration libraries are now markdown files composed with standard Unix tools. Composable as building blocks, runnable as cron jobs, etc.<p>One thing we didn't expect is that these are more auditable (and shareable) than shell scripts. Install scripts like `curl -fsSL <a href="https://bun.com/install" rel="nofollow">https://bun.com/install</a> | bash` could become:<p><pre><code> `curl -fsSL https://bun.com/install.md | claude-run`
</code></pre>
Where install.md says something like "Detect my OS and architecture, download the right binary from GitHub releases, extract to ~/.local/bin, update my shell config." A normal human can actually read and verify that.<p>The (really cool) executable markdown idea and auditability examples are from Pete Koomen (@koomen on X). As Pete says: "Markdown feels increasingly important in a way I'm not sure most people have wrapped their heads around yet."<p>We implemented it and added Unix pipe semantics. Currently works with Claude Code - hoping to support other AI coding tools too. You can also route scripts through different cloud providers (AWS Bedrock, etc.) if you want separate billing for automated jobs.<p>GitHub: <a href="https://github.com/andisearch/claude-switcher" rel="nofollow">https://github.com/andisearch/claude-switcher</a><p>What workflows would you use this for?