写作与整理:让OpenClaw 接管你的周报与公文(OpenClaw Skill调用详解)

🚀前言
你有没有算过这样 笔账:一个普通职场人每周花在写周报、整理会议纪 要、撰写各种材料上的时间有多少?
我做过 个相略统计 以我自已为例、每周写周报大约需要2小时,整理 会议纪要1.5小时,撰写各种临时材料3~4小时,加起来就是6~7.5小时。 按每周40小时工作制计算,这意味着我将近20%的工作时间都用在“写字” 上——不是创造性的写作,而是格式化的、重复性的文字工作。一年下来、就 是300多个小时这相当丁 个多月的全职工作时间全部消耗在了“写材料” 这件事上
本系列要解决的问题就是:如何让AI 接管这些重复性的写作任务、把你从 大量重复的工作中解放出来
OpenClaw 在写作与整理方面的能力,远不止“帮你写一段文字”那么简 单。它能读取你的计算机上的本地文件,建立属于你的知识库 ;能按照你指定 的格式自动排版;能与飞书、WPS 等工具联动,实现从数据到文档的自动化流 转;更重要的是,它能通过调川Skill(技能模块),完成复杂材料的结构化写作
读完这一系列,你将掌握一套完整的“AI 写作工作流 ”:从知识库 搭建、到 公文自动化,再到复杂材料的智能生成。你的周报、会议纪要、项目方案、都可以交给AI 来完成初稿,你只需做最后的审核和调整。
让我们开始吧。
🚀一、OpenClaw Skill调用详解
前面的案例已经涉及不少 Skill 的使用。本节将系统介绍 OpenClaw 的 Skill 体系,帮助你更深入地理解和使用它们。
什么是 Skill? Skill 是 OpenClaw 的可复用功能模块,类似于“插件”或“工具”。每个 Skill 封装了特定的能力——比如读取 PDF、生成内容、格式排版、连接飞书等。通过组合不同的 Skill,你可以像搭积木一样构建复杂的自动化工作流。
🔎1.常用 Skill 介绍
OpenClaw 的 Skill 分为几大类:文档处理、内容生成、格式处理、外部联动、知识库等。以下是核心 Skill 的详细介绍。
表5-6 文档处理类 Skill
|
|
|
|
|
|
|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-7 内容生成类 Skill
|
|
|
|
|
|
|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-8 格式处理类 Skill
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-9 外部联动类 Skill
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
表5-10 知识库类 Skill
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
🔎2.Skill 调用方法
OpenClaw 支持多种方法调用 Skill,适应不同的使用场景。
🦋方法一:命令行调用
最直接的方式是通过命令行调用。
# 基本语法openclaw <skill-name> [参数]# 示例:使用 file-reader 读取文件openclaw file-reader --input "/path/to/document.pdf"# 示例:使用 summarizer 生成摘要openclaw summarizer --input "/path/to/article.txt" --length 200# 示例:使用 content-generator 生成内容openclaw content-generator \--prompt "写一篇关于人工智能的文章" \--model deepseek \--output "article.md"# 示例:使用 translator 翻译openclaw translator \--input "hello world" \--source_lang en \--target_lang zh
🦋方法二:配置文件调用
对于复杂的任务,可以使用 YAML 配置文件。
# task_config.yamltask:name: "周报生成"description: "自动生成工作周报"steps:- skill: file-readerparams:input: "./data/本周数据.xlsx"sheet: "Sheet1"- skill: data-analyzerparams:metrics: ["GMV", "订单数", "转化率"]- skill: content-generatorparams:prompt: "根据以上数据生成本周工作总结"model: deepseektemperature: 0.5- skill: format-applierparams:template: "周报模板"- skill: file-writerparams:output: "./output/周报.docx"format: docx
执行:
openclaw run task_config.yaml
🦋方法三:API 调用
如果你需要在程序中调用 Skill,可以使用 Python API。
import openclaw# 初始化客户端client = openclaw.Client()# 调用 file-reader Skillresult = client.skills.file_reader(input="/path/to/document.pdf",extract_tables=True,extract_images=False)print(f"文档内容:{result.text}")print(f"表格数量:{len(result.tables)}")# 调用 content-generator Skillcontent = client.skills.content_generator(prompt="写一篇关于人工智能的文章",model="deepseek",max_tokens=2000,temperature=0.7)# 调用 summarizer Skillsummary = client.skills.summarizer(input=content,max_length=200,focus="核心观点")# 调用 format-applier Skillformatted = client.skills.format_applier(input=content,template="企业公文")# 保存结果client.file.write(formatted, "./output/article.docx")
🦋方法四:工作流集成
对于需要多 Skill 协作的复杂任务,可以使用工作流。
# workflow.yamlworkflow:name: "复杂材料写作流程"version: "1.0"steps:- id: read_docsname: "读取参考资料"skill: file-readerparams:input: "{{input_files}}"recursive: true- id: analyzename: "分析内容"skill: content-analyzerparams:input: "{{steps.read_docs.output}}"analysis_type: "comprehensive"focus: ["关键数据", "核心观点", "逻辑结构"]- id: generatename: "生成初稿"skill: content-generatorparams:prompt: "{{template}}"context: "{{steps.analyze.output}}"model: deepseektemperature: 0.5- id: optimizename: "优化内容"skill: content-optimizerparams:input: "{{steps.generate.output}}"goals: ["逻辑性", "说服力", "专业性"]- id: formatname: "格式排版"skill: format-applierparams:input: "{{steps.optimize.output}}"template: "政府公文"- id: savename: "保存文档"skill: file-writerparams:input: "{{steps.format.output}}"output: "{{output_path}}"format: docx
执行:
openclaw workflow run workflow.yaml \--input_files "./refs/*.pdf" \--template "项目方案模板" \--output_path "./output/方案.docx"
🦋通用参数说明
不同 Skill 有不同的参数,但有一些通用参数,见表5-11。
表5-11 通用参数说明
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
🔎3.自定义 Skill 开发入门
如果内置 Skill 不能满足你的需求,可以开发自定义 Skill。
🦋1. Skill 的基本结构
一个 OpenClaw Skill 本质上是一个 Python 模块,包含以下部分:
- Skill 定义
:描述 Skill 的基本信息( skill.yaml) - 参数定义
:定义 Skill 接受的参数 - 执行逻辑
:实现 Skill 的核心功能( main.py) - 返回结果
:定义 Skill 的输出格式
🦋2. 开发示例:周报生成器 Skill
(1)创建 Skill 目录结构
weekly-report-skill/├── __init__.py├── skill.yaml # Skill 定义文件├── main.py # 主逻辑├── requirements.txt # 依赖└── templates/└── weekly_report.md # 模板文件
(2)编写 Skill 定义文件(skill.yaml)
skill:name: weekly-report-generatorversion: "1.0.0"description: "自动生成运营周报"author: "your_name"license: "MIT"inputs:- name: data_sourcetype: stringrequired: truedescription: "数据源路径"- name: week_starttype: daterequired: truedescription: "周报开始日期"- name: week_endtype: daterequired: truedescription: "周报结束日期"- name: output_formattype: stringrequired: falsedefault: "docx"options: ["docx", "pdf", "md"]description: "输出格式"- name: templatetype: stringrequired: falsedefault: "default"description: "使用的模板"outputs:- name: report_filetype: filedescription: "生成的周报文件路径"- name: summarytype: stringdescription: "周报摘要"- name: statstype: objectdescription: "数据统计信息"dependencies:- openclaw-core>=2.5.0- pandas>=1.3.0- python-docx>=0.8.11- openpyxl>=3.0.0metadata:category: "productivity"tags: ["report", "weekly", "automation"]
(3)编写主逻辑(main.py)
import pandas as pdfrom datetime import datetimefrom openclaw import SkillBase, ContentGenerator, FormatApplierimport logginglogger = logging.getLogger(__name__)class WeeklyReportGenerator(SkillBase):"""周报生成器 Skill"""def __init__(self):super().__init__()self.content_generator = ContentGenerator()self.format_applier = FormatApplier()self.logger = loggerdef execute(self, data_source, week_start, week_end, output_format="docx", template="default"):"""执行周报生成Args:data_source: 数据源路径week_start: 周报开始日期week_end: 周报结束日期output_format: 输出格式template: 使用的模板Returns:dict: 包含 report_file 和 summary 的字典"""self.logger.info(f"开始生成周报:{week_start} 至 {week_end}")try:# 1. 读取数据self.logger.info("读取数据...")data = self._load_data(data_source, week_start, week_end)# 2. 分析数据self.logger.info("分析数据...")analysis = self._analyze_data(data)# 3. 生成内容self.logger.info("生成周报内容...")content = self._generate_content(analysis, week_start, week_end, template)# 4. 格式排版self.logger.info("格式排版...")formatted_content = self._format_content(content)# 5. 保存文件self.logger.info("保存文件...")output_path = self._save_file(formatted_content, week_end, output_format)self.logger.info(f"周报生成完成:{output_path}")return {"report_file": output_path,"summary": analysis["summary"],"stats": {"total_gmv": analysis["total_gmv"],"total_orders": analysis["total_orders"],"document_count": len(data)}}except Exception as e:self.logger.error(f"周报生成失败:{str(e)}")raisedef _load_data(self, data_source, week_start, week_end):"""读取数据"""# 支持 Excel、CSV、飞书表格等多种数据源if data_source.endswith('.xlsx') or data_source.endswith('.xls'):df = pd.read_excel(data_source)elif data_source.endswith('.csv'):df = pd.read_csv(data_source)else:# 假设是飞书表格 IDdf = self._load_feishu_table(data_source)# 过滤日期范围df['日期'] = pd.to_datetime(df['日期'])week_start = pd.to_datetime(week_start)week_end = pd.to_datetime(week_end)mask = (df['日期'] >= week_start) & (df['日期'] <= week_end)return df[mask]def _analyze_data(self, data):"""分析数据"""analysis = {"total_gmv": data['GMV'].sum(),"total_orders": data['订单数'].sum(),"total_visitors": data['访客数'].sum(),"avg_conversion": data['转化率'].mean(),"avg_aov": data['客单价'].mean(),"summary": f"本周GMV{data['GMV'].sum():.0f}元,订单{data['订单数'].sum():.0f}单"}return analysisdef _generate_content(self, analysis, week_start, week_end, template):"""生成周报内容"""template_content = self._load_template(template)prompt = f"""请根据以下数据生成本周运营周报:时间范围:{week_start} 至 {week_end}本周GMV:{analysis['total_gmv']:.0f}元本周订单数:{analysis['total_orders']:.0f}单本周访客数:{analysis['total_visitors']:.0f}人平均转化率:{analysis['avg_conversion']:.2f}%平均客单价:{analysis['avg_aov']:.2f}元模板:{template_content}要求:1. 按照模板结构填充内容2. 数据要准确3. 分析要有洞察4. 使用专业术语5. 逻辑清晰"""return self.content_generator.generate(prompt, model="deepseek")def _format_content(self, content):"""格式排版"""return self.format_applier.apply(content, template="企业公文")def _save_file(self, content, week_end, output_format):"""保存文件"""filename = f"运营周报_{week_end}.{output_format}"output_path = f"./output/{filename}"if output_format == "docx":self._save_docx(content, output_path)elif output_format == "pdf":self._save_pdf(content, output_path)else:self._save_md(content, output_path)return output_pathdef _load_template(self, template_name):"""加载模板"""template_path = f"templates/{template_name}.md"with open(template_path, "r", encoding="utf-8") as f:return f.read()def _load_feishu_table(self, table_id):"""从飞书表格加载数据"""from openclaw.skills import FeishuConnectorconnector = FeishuConnector()return connector.read_table(table_id)def _save_docx(self, content, path):"""保存为 Word 文档"""from docx import Documentfrom docx.shared import Pt, Inchesfrom docx.enum.text import WD_ALIGN_PARAGRAPHdoc = Document()title = doc.add_heading("运营周报", 0)title.alignment = WD_ALIGN_PARAGRAPH.CENTERdoc.add_paragraph(content)doc.save(path)def _save_pdf(self, content, path):"""保存为 PDF"""from reportlab.pdfgen import canvasfrom reportlab.lib.pagesizes import A4c = canvas.Canvas(path, pagesize=A4)c.drawString(100, 800, "运营周报")c.drawString(100, 780, content[:500]) # 简化示例c.save()def _save_md(self, content, path):"""保存为 Markdown"""with open(path, "w", encoding="utf-8") as f:f.write(content)# 注册 Skillskill = WeeklyReportGenerator()
(4)安装和测试 Skill
# 安装自定义 Skillopenclaw skill install --custom ./weekly-report-skill/# 测试 Skillopenclaw run weekly-report-generator \--data_source "./data/运营数据.xlsx" \--week_start "2024-12-16" \--week_end "2024-12-22" \--output_format "docx"# 查看 Skill 信息openclaw skill info weekly-report-generator# 卸载 Skillopenclaw skill uninstall weekly-report-generator
(5)调试和优化
# 启用调试模式openclaw --debug run weekly-report-generator [参数]# 查看详细日志openclaw logs --skill weekly-report-generator# 性能分析openclaw profile --skill weekly-report-generator# 单元测试openclaw test --skill weekly-report-generator
🔎3.附:AI提示词模板与完整回答示例
以下是一个典型的AI提示词模板,用于让 OpenClaw 数字员工使用自定义 Skill 执行“周报生成”任务。同时,我会给出该 Agent 可能产生的完整回答/执行报告。
🦋提示词模板(用户在飞书中@数字员工输入)
@我的数字员工【任务名称】:使用自定义 Skill 生成运营周报【Skill 名称】:weekly-report-generator(已安装)【输入参数】:- data_source: "/Users/xxx/data/运营数据.xlsx"- week_start: "2026-04-11"- week_end: "2026-04-17"- output_format: "docx"- template: "default"【任务目标】:请调用 weekly-report-generator Skill,根据指定的数据源和日期范围,自动生成一份运营周报。【输出要求】:- 周报文件保存到桌面“周报”文件夹- 将周报摘要通过飞书消息发送给我- 如果 Skill 执行失败,请给出具体的错误信息和排查建议【注意事项】:- 确保数据源文件存在且格式正确(必须包含“日期”“GMV”“订单数”“访客数”“转化率”“客单价”列)- 如果数据量过大,只分析前1000行- 总耗时控制在1分钟内
🦋AI Agent(数字员工)的完整回答(飞书消息)
@张伟 您好!您要求的“使用自定义 Skill 生成运营周报”任务已完成。以下是执行报告。---## 📊 Skill 执行报告**Skill 名称**:weekly-report-generator**执行时间**:2026-04-18 10:15:22 - 10:16:05(耗时43秒)**执行状态**:✅ 成功---### 一、Skill 调用参数| 参数 | 值 ||------|-----|| data_source | /Users/xxx/data/运营数据.xlsx || week_start | 2026-04-11 || week_end | 2026-04-17 || output_format | docx || template | default |---### 二、执行日志
[10:15:22] 开始生成周报:2026-04-11 至 2026-04-17 [10:15:23] 读取数据… 共读取 1,247 行,过滤后有效数据 1,052 行 [10:15:25] 分析数据… 计算完成 [10:15:30] 生成周报内容… 调用 DeepSeek 模型,耗时 5 秒 [10:15:45] 格式排版… 应用“企业公文”模板 [10:15:50] 保存文件… 输出格式 docx [10:16:05] 周报生成完成:./output/运营周报_2026-04-17.docx
---### 三、数据统计摘要| 指标 | 本周数值 | 上周数值 | 环比变化 ||------|----------|----------|----------|| GMV | 1,285,000元 | 1,120,000元 | +14.7% || 订单数 | 3,420单 | 3,150单 | +8.6% || 访客数 | 28,500人 | 26,800人 | +6.3% || 平均转化率 | 4.12% | 3.98% | +0.14% || 平均客单价 | 376元 | 356元 | +5.6% |**本周亮点**:- GMV 环比增长 14.7%,主要得益于“春季大促”活动- 客单价提升明显,说明高客单价商品销售占比增加**待改进点**:- 转化率提升幅度较小,建议优化商品详情页---### 四、输出文件- **文件路径**:`/Users/xxx/Desktop/周报/运营周报_2026-04-17.docx`- **文件大小**:约 156 KB- **文件格式**:Microsoft Word 文档(.docx)您可以直接打开该文件查看完整周报。周报包含以下章节:1. 本周数据概览(表格 + 环比分析)2. 主要工作回顾3. 问题与反思4. 下周计划5. 数据洞察---### 五、飞书消息摘要(已发送)> 📈 **运营周报摘要(2026-04-11 至 2026-04-17)**> 本周 GMV 128.5 万元(环比 +14.7%),订单数 3420 单(环比 +8.6%),访客数 2.85 万人(环比 +6.3%),转化率 4.12%(环比 +0.14%)。> 亮点:春季大促效果显著,客单价提升至 376 元。> 待改进:转化率提升缓慢,建议优化详情页。> 详细周报已保存至桌面“周报”文件夹。---### 六、后续建议1. 您可以在 Word 中打开周报文件,对“主要工作”和“下周计划”部分进行个性化调整。2. 如需将此 Skill 设置为每周五自动执行,请回复“设置定时”。3. 如果需要修改周报模板(如增加“竞品动态”章节),请提供模板文件路径,我可以帮您更新。—— 您的数字员工 🤖
夜雨聆风