prioritize-reference-files
它能做什么
这项技能引导 AI 智能体在做任何其他事情之前,先找到并阅读任务中的参考文件。它适合期望 AI 使用自己文件的人。
适用场景
- ✓当你附上文件,并期望 AI 使用其中内容作答的时候。
- ✓当 AI 报告的数据没有出现在你的文件中的时候。
- ✓当读取 Word、PDF 或 Excel 文件时出现错误,你需要 AI 找到其他方法的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/prioritize-reference-files/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请使用我附上的 Excel 和 PDF 回答我的问题,不要编造任何数字。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会查找附在任务上的文件,为每种类型使用合适的读取器,并在网络搜索之前先阅读它们。如果文件读取失败,这项技能会列出可以尝试的备用方法。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Prioritize Reference Files
Purpose
This skill ensures that when reference files are provided in task context, you MUST read and extract data from them FIRST before attempting web searches or generating synthetic data. Ignoring available structured data leads to fabricated outputs and incorrect results.
Core Principle
Reference files in context > Web search > Data fabrication (never)
Workflow
Step 1: Scan Task Context for Reference Files
Before taking any action, identify all files provided in the task context:
- Look for file attachments, uploads, or references in the task description
- Common formats:
.xlsx,.csv,.json,.pdf,.docx,.txt - Check for phrases like "attached", "provided", "reference file", "see file"
Step 2: Read Reference Files First
Use the appropriate tool to read each reference file:
# For Excel files
read_file(filetype="xlsx", file_path="path/to/file.xlsx")
# For CSV files
read_file(filetype="csv", file_path="path/to/file.csv")
# For PDF files
read_file(filetype="pdf", file_path="path/to/file.pdf")
# For JSON files
read_file(filetype="json", file_path="path/to/file.json")
# For text files
read_file(filetype="txt", file_path="path/to/file.txt")
If read_file fails on .docx files (returns error, empty content, or 'unknown error'):
Fallback Approach 1: Direct zipfile/XML extraction via run_shell
# .docx files are ZIP archives containing XML; extract document.xml directly
unzip -p path/to/file.docx word/document.xml | grep -oP '(?<=<w:t>)[^<]+' | tr '\n' ' '
Or for more complete extraction:
mkdir -p /tmp/docx_extract && cd /tmp/docx_extract && unzip path/to/file.docx && cat word/document.xml
Fallback Approach 2: Use shell_agent for complex extraction If direct extraction fails, delegate to shell_agent:
shell_agent(task="Extract text content from path/to/file.docx using zipfile and XML parsing")
The agent will attempt multiple extraction methods and report results.
Fallback Approach 3: Verify extraction success before proceeding After any extraction method, confirm content was retrieved:
- Check that output is non-empty and contains expected document structure
- Look for familiar text from the document (headings, known phrases)
- If extraction appears incomplete, try an alternative method
- Document which method succeeded: "Content extracted using [method] after read_file failed"
Important: Never proceed to data fabrication if reference files exist but read_file fails. Always attempt at least one fallback extraction method first.
Step 3: Extract and Validate Data
After reading:
- Parse the content to understand the data structure
- Identify relevant fields/columns for your task
- Verify the data is complete and usable
- Note any limitations or missing information
Step 4: Use Reference Data as Primary Source
- Base all outputs on the reference file data
- Only supplement with web search if reference data is incomplete
- NEVER fabricate data when reference files exist
- If reference data is insufficient, explicitly state what's missing
Step 5: Document Data Source
In your outputs, acknowledge the source:
- "Data sourced from [filename]"
- "Based on provided reference file: [filename]"
- This confirms you used the actual provided data
Anti-Patterns to Avoid
❌ Ignoring reference files and searching the web instead ❌ Fabricating data when structured data is available ❌ Assuming file contents without reading them ❌ Using outdated web data when current reference files exist ❌ Giving up after read_file fails without trying fallback extraction methods
Example
Task Context: "Create a property listings report. See Massabama_active_listings.xlsx for current data."
Correct Approach:
1. Read Massabama_active_listings.xlsx first
2. Extract property addresses, prices, specifications
3. Generate report using actual listing data
4. Note: "Data sourced from Massabama_active_listings.xlsx"
Incorrect Approach:
1. Search web for "Massabama property listings"
2. Fabricate property data from search results
3. Create report with unverified/generated data
Verification Checklist
Before completing any task with reference files:
- I have identified all reference files in the task context
- I have read each reference file using appropriate tools
- I have extracted relevant data from the files
- My output is ba
常见问题
智能体如何决定先读哪些文件?
它会查找附件,以及任务中“附上”或“提供”之类的表述,然后优先读取这些文件。
如果 Excel 读取器失败怎么办?
智能体可以使用其他方法,例如脚本,来打开文件并读取其中的数据。
这项技能只适用于数据类任务吗?
它面向依赖所提供文件的任务,例如报告、分析和摘要。
详情
作者的原始描述
Ensures agents read and use provided reference files before searching or fabricating data
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12954
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。