fabric
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFabric
Fabric
Fabric is an open-source AI prompt orchestration framework by Daniel Miessler. It provides a library of reusable AI prompts called Patterns — each designed for a specific real-world task — wired into a simple Unix pipeline with stdin/stdout.
Fabric是Daniel Miessler开发的开源AI提示词编排框架,它提供了名为Pattern的可复用AI提示词库——每个Pattern都针对特定的现实场景任务设计,可通过stdin/stdout接入简单的Unix管道。
When to use this skill
适用场景
- Summarize or extract insights from YouTube videos, articles, or documents
- Apply any of 250+ pre-built AI patterns to content via Unix piping
- Route different patterns to different AI providers (OpenAI, Claude, Gemini, etc.)
- Create custom patterns for repeatable AI workflows
- Run Fabric as a REST API server for integration with other tools
- Process command output, files, or clipboard content through AI patterns
- Use as an AI agent utility — pipe any tool output through patterns for intelligent summarization
- 从YouTube视频、文章或文档中总结或提取洞见
- 通过Unix管道将250多个预构建的AI Pattern应用到内容处理中
- 将不同的Pattern路由到不同的AI服务商(OpenAI、Claude、Gemini等)
- 为可复用的AI工作流创建自定义Pattern
- 将Fabric作为REST API服务器运行,方便与其他工具集成
- 通过AI Pattern处理命令输出、文件或剪贴板内容
- 作为AI Agent工具使用——将任意工具的输出通过管道传入Pattern,实现智能总结
Instructions
使用指南
Step 1: Install Fabric
步骤1:安装Fabric
bash
undefinedbash
undefinedmacOS/Linux (one-liner)
macOS/Linux 一键安装
macOS via Homebrew
macOS 通过Homebrew安装
brew install fabric-ai
brew install fabric-ai
Windows
Windows 安装
winget install danielmiessler.Fabric
winget install danielmiessler.Fabric
After install — configure API keys and default model
安装完成后,配置API密钥和默认模型
fabric --setup
undefinedfabric --setup
undefinedStep 2: Learn the core pipeline workflow
步骤2:了解核心管道工作流
Fabric works as a Unix pipe. Feed content through stdin and specify a pattern:
bash
undefinedFabric基于Unix管道运行,通过stdin传入内容并指定Pattern即可使用:
bash
undefinedSummarize a file
总结文件内容
cat article.txt | fabric -p summarize
cat article.txt | fabric -p summarize
Stream output in real time
实时流式输出结果
cat document.txt | fabric -p extract_wisdom --stream
cat document.txt | fabric -p extract_wisdom --stream
Pipe any command output through a pattern
将任意命令的输出通过管道传入Pattern处理
git log --oneline -20 | fabric -p summarize
git log --oneline -20 | fabric -p summarize
Process clipboard (macOS)
处理剪贴板内容(macOS)
pbpaste | fabric -p summarize
pbpaste | fabric -p summarize
Pipe from curl
处理curl拉取的内容
curl -s https://example.com/article | fabric -p summarize
undefinedcurl -s https://example.com/article | fabric -p summarize
undefinedStep 3: Discover patterns
步骤3:查找可用Pattern
bash
undefinedbash
undefinedList all available patterns
列出所有可用Pattern
fabric -l
fabric -l
Update patterns from the repository
从仓库更新Pattern库
fabric -u
fabric -u
Search patterns by keyword
按关键词搜索Pattern
fabric -l | grep summary
fabric -l | grep code
fabric -l | grep security
Key patterns:
| Pattern | Purpose |
|---------|---------|
| `summarize` | Summarize any content into key points |
| `extract_wisdom` | Extract insights, quotes, habits, and lessons |
| `analyze_paper` | Break down academic papers into actionable insights |
| `explain_code` | Explain code in plain language |
| `write_essay` | Write essays from a topic or rough notes |
| `clean_text` | Remove noise and formatting from raw text |
| `analyze_claims` | Fact-check and assess credibility of claims |
| `create_summary` | Create a structured, markdown summary |
| `rate_content` | Rate and score content quality |
| `label_and_rate` | Categorize and score content |
| `improve_writing` | Polish and improve text clarity |
| `create_tags` | Generate relevant tags for content |
| `ask_secure_by_design` | Review code or systems for security issues |
| `capture_thinkers_work` | Extract the core ideas of a thinker or author |
| `create_investigation_visualization` | Create a visual map of complex investigations |fabric -l | grep summary
fabric -l | grep code
fabric -l | grep security
核心Pattern:
| Pattern | 用途 |
|---------|---------|
| `summarize` | 将任意内容总结为核心要点 |
| `extract_wisdom` | 提取洞见、引语、习惯和经验教训 |
| `analyze_paper` | 拆解学术论文,提炼可落地的洞见 |
| `explain_code` | 用通俗语言解释代码逻辑 |
| `write_essay` | 根据主题或草稿生成文章 |
| `clean_text` | 移除原始文本中的噪声和格式干扰 |
| `analyze_claims` | 事实核查,评估主张的可信度 |
| `create_summary` | 生成结构化的Markdown格式总结 |
| `rate_content` | 评估内容质量并打分 |
| `label_and_rate` | 对内容进行分类并打分 |
| `improve_writing` | 优化文本,提升清晰度 |
| `create_tags` | 为内容生成相关标签 |
| `ask_secure_by_design` | 检查代码或系统的安全问题 |
| `capture_thinkers_work` | 提取思想家或作者的核心观点 |
| `create_investigation_visualization` | 为复杂调查生成可视化脉络图 |Step 4: Process YouTube videos
步骤4:处理YouTube视频
bash
undefinedbash
undefinedSummarize a YouTube video
总结YouTube视频内容
fabric -y "https://youtube.com/watch?v=VIDEO_ID" -p summarize
fabric -y "https://youtube.com/watch?v=VIDEO_ID" -p summarize
Extract key insights from a video
提取视频的核心洞见
fabric -y "https://youtube.com/watch?v=VIDEO_ID" -p extract_wisdom
fabric -y "https://youtube.com/watch?v=VIDEO_ID" -p extract_wisdom
Get transcript only (no pattern applied)
仅获取视频字幕(不应用Pattern)
fabric -y "https://youtube.com/watch?v=VIDEO_ID" --transcript
fabric -y "https://youtube.com/watch?v=VIDEO_ID" --transcript
Transcript with timestamps
获取带时间戳的字幕
fabric -y "https://youtube.com/watch?v=VIDEO_ID" --transcript-with-timestamps
undefinedfabric -y "https://youtube.com/watch?v=VIDEO_ID" --transcript-with-timestamps
undefinedStep 5: Create custom patterns
步骤5:创建自定义Pattern
Each pattern is a directory with a file inside . The body should follow this structure:
system.md~/.config/fabric/patterns/bash
mkdir -p ~/.config/fabric/patterns/my-pattern
cat > ~/.config/fabric/patterns/my-pattern/system.md << 'EOF'每个Pattern都是存储在下的目录,目录内包含一个文件,内容结构参考如下:
~/.config/fabric/patterns/system.mdbash
mkdir -p ~/.config/fabric/patterns/my-pattern
cat > ~/.config/fabric/patterns/my-pattern/system.md << 'EOF'IDENTITY AND PURPOSE
身份与目标
You are an expert at [task]. Your job is to [specific goal].
Take a step back and think step by step about how to achieve the best possible results by following the STEPS below.
你是[任务领域]的专家,你的职责是[具体目标]。
请先梳理思路,按照下方步骤逐步操作,输出最优结果。
STEPS
操作步骤
- [Step 1]
- [Step 2]
- [步骤1]
- [步骤2]
OUTPUT INSTRUCTIONS
输出要求
- Only output Markdown.
- [Format instruction 2]
- Do not give warnings or notes; only output the requested sections.
- 仅输出Markdown格式内容
- [其他格式要求2]
- 不要输出警告或备注,仅输出要求的内容部分
INPUT
输入
INPUT:
EOF
Use it immediately:
```bash
echo "input text" | fabric -p my-pattern
cat file.txt | fabric -p my-pattern --streamINPUT:
EOF
创建后即可立即使用:
```bash
echo "输入文本" | fabric -p my-pattern
cat file.txt | fabric -p my-pattern --streamStep 6: Multi-provider routing and advanced usage
步骤6:多服务商路由与高级用法
bash
undefinedbash
undefinedRun as REST API server (port 8080 by default)
作为REST API服务器运行(默认端口8080)
fabric --serve
fabric --serve
Use web search capability
使用网页搜索能力
fabric -p analyze_claims --search "claim to verify"
fabric -p analyze_claims --search "待验证的主张"
Per-pattern model routing in ~/.config/fabric/.env
在~/.config/fabric/.env中配置单个Pattern的调用模型
FABRIC_MODEL_PATTERN_SUMMARIZE=anthropic|claude-opus-4-5
FABRIC_MODEL_PATTERN_EXTRACT_WISDOM=openai|gpt-4o
FABRIC_MODEL_PATTERN_EXPLAIN_CODE=google|gemini-2.0-flash
FABRIC_MODEL_PATTERN_SUMMARIZE=anthropic|claude-opus-4-5
FABRIC_MODEL_PATTERN_EXTRACT_WISDOM=openai|gpt-4o
FABRIC_MODEL_PATTERN_EXPLAIN_CODE=google|gemini-2.0-flash
Create shell aliases for frequently used patterns
为高频使用的Pattern创建shell别名
alias summarize="fabric -p summarize"
alias wisdom="fabric -p extract_wisdom"
alias explain="fabric -p explain_code"
alias summarize="fabric -p summarize"
alias wisdom="fabric -p extract_wisdom"
alias explain="fabric -p explain_code"
Chain patterns
链式调用多个Pattern
cat paper.txt | fabric -p summarize | fabric -p extract_wisdom
cat paper.txt | fabric -p summarize | fabric -p extract_wisdom
Save output
保存输出结果
cat document.txt | fabric -p extract_wisdom > insights.md
undefinedcat document.txt | fabric -p extract_wisdom > insights.md
undefinedStep 7: Use in AI agent workflows
步骤7:在AI Agent工作流中使用
Fabric is a powerful utility for AI agents — pipe any tool output through patterns for intelligent analysis:
bash
undefinedFabric是AI Agent的高效工具,可将任意工具的输出通过管道传入Pattern进行智能分析:
bash
undefinedAnalyze test failures
分析测试失败原因
npm test 2>&1 | fabric -p analyze_logs
npm test 2>&1 | fabric -p analyze_logs
Summarize git history for a PR description
总结git历史生成PR描述
git log --oneline origin/main..HEAD | fabric -p create_summary
git log --oneline origin/main..HEAD | fabric -p create_summary
Explain a code diff
解释代码diff
git diff HEAD~1 | fabric -p explain_code
git diff HEAD~1 | fabric -p explain_code
Summarize build errors
总结构建错误
make build 2>&1 | fabric -p summarize
make build 2>&1 | fabric -p summarize
Analyze security vulnerabilities in code
分析代码中的安全漏洞
cat src/auth.py | fabric -p ask_secure_by_design
cat src/auth.py | fabric -p ask_secure_by_design
Process log files
处理日志文件
cat /var/log/app.log | tail -100 | fabric -p analyze_logs
undefinedcat /var/log/app.log | tail -100 | fabric -p analyze_logs
undefinedREST API server mode
REST API服务器模式
Run Fabric as a microservice and call it from other tools:
bash
undefined将Fabric作为微服务运行,可供其他工具调用:
bash
undefinedStart server
启动服务器
fabric --serve --port 8080
fabric --serve --port 8080
Call via HTTP
通过HTTP调用
curl -X POST http://localhost:8080/chat
-H "Content-Type: application/json"
-d '{"prompts":[{"userInput":"Summarize this","patternName":"summarize"}]}'
-H "Content-Type: application/json"
-d '{"prompts":[{"userInput":"Summarize this","patternName":"summarize"}]}'
undefinedcurl -X POST http://localhost:8080/chat
-H "Content-Type: application/json"
-d '{"prompts":[{"userInput":"总结这段内容","patternName":"summarize"}]}'
-H "Content-Type: application/json"
-d '{"prompts":[{"userInput":"总结这段内容","patternName":"summarize"}]}'
undefinedBest practices
最佳实践
- Run before first use and regularly to get the latest community patterns.
fabric -u - Use for long content to see results progressively instead of waiting.
--stream - Create shell aliases () for your most-used patterns.
alias wisdom="fabric -p extract_wisdom" - Use per-pattern model routing to optimize cost vs. quality for each task type.
- Keep custom patterns in — they persist across updates.
~/.config/fabric/patterns/ - For YouTube, transcript extraction works best with videos that have captions enabled.
- Chain patterns with Unix pipes for multi-step processing workflows.
- Follow the IDENTITY → STEPS → OUTPUT INSTRUCTIONS structure when creating custom patterns.
- 首次使用前和定期运行,获取最新的社区贡献Pattern
fabric -u - 处理长内容时使用参数,可逐步查看结果无需等待全部生成
--stream - 为常用Pattern创建shell别名(比如)提升效率
alias wisdom="fabric -p extract_wisdom" - 为不同Pattern配置不同的调用模型,平衡任务成本与输出质量
- 将自定义Pattern保存在目录下,更新工具时不会丢失
~/.config/fabric/patterns/ - 处理YouTube视频时,开启字幕的视频提取字幕效果更好
- 通过Unix管道链式调用Pattern,实现多步骤处理工作流
- 创建自定义Pattern时遵循「身份→步骤→输出要求」的结构