【愚公系列】《OpenClaw实战指南》017-写作与整理:让OpenClaw 接管你的周报与公文(OpenClaw Skill调用详解)

💎【行业认证·权威头衔】

✔ 华为云天团核心成员:特约编辑/云享专家/开发者专家/产品云测专家

✔ 开发者社区全满贯:CSDN博客&商业化双料专家/阿里云签约作者/腾讯云内容共创官/掘金&亚马逊&51CTO顶级博主

✔ 技术生态共建先锋:横跨鸿蒙、云计算、AI等前沿领域的技术布道者

🏆【荣誉殿堂】

🎖 连续三年蝉联"华为云十佳博主"(2022-2024)

🎖 双冠加冕CSDN"年度博客之星TOP2"(2022&2023)

🎖 十余个技术社区年度杰出贡献奖得主

📚【知识宝库】

覆盖全栈技术矩阵:

◾ 编程语言:.NET/Java/Python/Go/Node...

◾ 移动生态:HarmonyOS/iOS/Android/小程序

◾ 前沿领域:物联网/网络安全/大数据/AI/元宇宙

◾ 游戏开发:Unity3D引擎深度解析

文章目录


🚀前言

你有没有算过这样 笔账:一个普通职场人每周花在写周报、整理会议纪 要、撰写各种材料上的时间有多少?

我做过 个相略统计 以我自已为例、每周写周报大约需要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

Skill 名称 功能 适用场景 使用频率 依赖
file-reader 读取本地文件 读取各种格式的文档 极高
pdf-parser 解析 PDF 文档 提取 PDF 中的文字和表格 pdfplumber
docx-reader 读取 Word 文档 提取 Word 文档内容 python-docx
excel-reader 读取 Excel 表格 提取表格数据 pandas
ppt-reader 读取 PPT 文档 提取演示文稿内容 python-pptx
image-ocr 图片文字识别 提取图片中的文字 paddleocr
csv-reader 读取 CSV 文件 提取结构化数据 pandas
markdown-reader 读取 Markdown 提取 Markdown 内容 markdown

表5-7 内容生成类 Skill

Skill 名称 功能 适用场景 使用频率 主要参数
content-generator 通用内容生成 各种写作任务 极高 model, prompt, temperature
summarizer 文本摘要 长文档总结 max_length, focus
translator 文本翻译 多语言转换 source_lang, target_lang
rewriter 文本改写 润色、降重 style, tone
expander 文本扩写 内容扩充 expansion_ratio
optimizer 内容优化 提升表达质量 goals, constraints
question-generator 问题生成 生成问答对 num_questions
outline-generator 大纲生成 生成文章大纲 depth, structure

表5-8 格式处理类 Skill

Skill 名称 功能 适用场景 使用频率
format-applier 格式应用 文档排版
template-engine 模板引擎 批量生成
markdown-converter Markdown 转换 格式互转
table-formatter 表格格式化 表格美化
html-converter HTML 转换 网页格式转换
pdf-converter PDF 转换 生成 PDF

表5-9 外部联动类 Skill

Skill 名称 功能 适用场景 使用频率
feishu-connector 飞书连接 飞书数据读写
wps-connector WPS 连接 WPS 文档处理
wechat-connector 微信连接 微信消息发送
email-connector 邮件连接 邮件发送
notion-connector Notion 连接 Notion 数据同步
calendar-connector 日历连接 日程管理

表5-10 知识库类 Skill

Skill 名称 功能 适用场景 使用频率
doc-indexer 文档索引 建立知识库索引
smart-retriever 智能检索 知识库查询 极高
kb-manager 知识库管理 知识库维护
similarity-search 相似度搜索 语义检索
kb-backup 知识库备份 数据备份

🔎2.Skill 调用方法

OpenClaw 支持多种方法调用 Skill,适应不同的使用场景。

🦋方法一:命令行调用

最直接的方式是通过命令行调用。

bash 复制代码
# 基本语法
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 配置文件。

yaml 复制代码
# task_config.yaml
task:
  name: "周报生成"
  description: "自动生成工作周报"

steps:
  - skill: file-reader
    params:
      input: "./data/本周数据.xlsx"
      sheet: "Sheet1"

  - skill: data-analyzer
    params:
      metrics: ["GMV", "订单数", "转化率"]

  - skill: content-generator
    params:
      prompt: "根据以上数据生成本周工作总结"
      model: deepseek
      temperature: 0.5

  - skill: format-applier
    params:
      template: "周报模板"

  - skill: file-writer
    params:
      output: "./output/周报.docx"
      format: docx

执行:

bash 复制代码
openclaw run task_config.yaml

🦋方法三:API 调用

如果你需要在程序中调用 Skill,可以使用 Python API。

python 复制代码
import openclaw

# 初始化客户端
client = openclaw.Client()

# 调用 file-reader Skill
result = 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 Skill
content = client.skills.content_generator(
    prompt="写一篇关于人工智能的文章",
    model="deepseek",
    max_tokens=2000,
    temperature=0.7
)

# 调用 summarizer Skill
summary = client.skills.summarizer(
    input=content,
    max_length=200,
    focus="核心观点"
)

# 调用 format-applier Skill
formatted = client.skills.format_applier(
    input=content,
    template="企业公文"
)

# 保存结果
client.file.write(formatted, "./output/article.docx")

🦋方法四:工作流集成

对于需要多 Skill 协作的复杂任务,可以使用工作流。

yaml 复制代码
# workflow.yaml
workflow:
  name: "复杂材料写作流程"
  version: "1.0"

steps:
  - id: read_docs
    name: "读取参考资料"
    skill: file-reader
    params:
      input: "{{input_files}}"
      recursive: true

  - id: analyze
    name: "分析内容"
    skill: content-analyzer
    params:
      input: "{{steps.read_docs.output}}"
      analysis_type: "comprehensive"
      focus: ["关键数据", "核心观点", "逻辑结构"]

  - id: generate
    name: "生成初稿"
    skill: content-generator
    params:
      prompt: "{{template}}"
      context: "{{steps.analyze.output}}"
      model: deepseek
      temperature: 0.5

  - id: optimize
    name: "优化内容"
    skill: content-optimizer
    params:
      input: "{{steps.generate.output}}"
      goals: ["逻辑性", "说服力", "专业性"]

  - id: format
    name: "格式排版"
    skill: format-applier
    params:
      input: "{{steps.optimize.output}}"
      template: "政府公文"

  - id: save
    name: "保存文档"
    skill: file-writer
    params:
      input: "{{steps.format.output}}"
      output: "{{output_path}}"
      format: docx

执行:

bash 复制代码
openclaw workflow run workflow.yaml \
  --input_files "./refs/*.pdf" \
  --template "项目方案模板" \
  --output_path "./output/方案.docx"

🦋通用参数说明

不同 Skill 有不同的参数,但有一些通用参数,见表5-11。

表5-11 通用参数说明

参数名 说明 示例值 适用 Skill
input 输入文件或内容 "/path/to/file.pdf" 读取类
output 输出文件路径 "./output/result.docx" 写入类
model 使用的 AI 模型 deepseek, kimi, doubao 生成类
prompt 提示词 "总结这篇文章" 生成类
template 模板名称 "政府公文", "企业公文" 格式类
format 输出格式 docx, pdf, md, txt 写入类
max_tokens 最大生成字数 2000 生成类
temperature 创造性程度 0.7 生成类
top_k 返回结果数量 5 检索类
verbose 显示详细信息 true/false 所有

🔎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

yaml 复制代码
skill:
  name: weekly-report-generator
  version: "1.0.0"
  description: "自动生成运营周报"
  author: "your_name"
  license: "MIT"

inputs:
  - name: data_source
    type: string
    required: true
    description: "数据源路径"
  - name: week_start
    type: date
    required: true
    description: "周报开始日期"
  - name: week_end
    type: date
    required: true
    description: "周报结束日期"
  - name: output_format
    type: string
    required: false
    default: "docx"
    options: ["docx", "pdf", "md"]
    description: "输出格式"
  - name: template
    type: string
    required: false
    default: "default"
    description: "使用的模板"

outputs:
  - name: report_file
    type: file
    description: "生成的周报文件路径"
  - name: summary
    type: string
    description: "周报摘要"
  - name: stats
    type: object
    description: "数据统计信息"

dependencies:
  - openclaw-core>=2.5.0
  - pandas>=1.3.0
  - python-docx>=0.8.11
  - openpyxl>=3.0.0

metadata:
  category: "productivity"
  tags: ["report", "weekly", "automation"]

(3)编写主逻辑(main.py

python 复制代码
import pandas as pd
from datetime import datetime
from openclaw import SkillBase, ContentGenerator, FormatApplier
import logging

logger = logging.getLogger(__name__)


class WeeklyReportGenerator(SkillBase):
    """周报生成器 Skill"""

    def __init__(self):
        super().__init__()
        self.content_generator = ContentGenerator()
        self.format_applier = FormatApplier()
        self.logger = logger

    def 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)}")
            raise

    def _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:
            # 假设是飞书表格 ID
            df = 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 analysis

    def _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_path

    def _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 FeishuConnector
        connector = FeishuConnector()
        return connector.read_table(table_id)

    def _save_docx(self, content, path):
        """保存为 Word 文档"""
        from docx import Document
        from docx.shared import Pt, Inches
        from docx.enum.text import WD_ALIGN_PARAGRAPH

        doc = Document()
        title = doc.add_heading("运营周报", 0)
        title.alignment = WD_ALIGN_PARAGRAPH.CENTER
        doc.add_paragraph(content)
        doc.save(path)

    def _save_pdf(self, content, path):
        """保存为 PDF"""
        from reportlab.pdfgen import canvas
        from reportlab.lib.pagesizes import A4

        c = 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)


# 注册 Skill
skill = WeeklyReportGenerator()

(4)安装和测试 Skill

bash 复制代码
# 安装自定义 Skill
openclaw skill install --custom ./weekly-report-skill/

# 测试 Skill
openclaw 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

# 卸载 Skill
openclaw skill uninstall weekly-report-generator

(5)调试和优化

bash 复制代码
# 启用调试模式
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. 如果需要修改周报模板(如增加"竞品动态"章节),请提供模板文件路径,我可以帮您更新。 ------ 您的数字员工 🤖

相关推荐
chimooing2 小时前
OpenClaw 浏览器自动化:Playwright 深度集成
运维·自动化
ZPC82102 小时前
ROS2 通信提速快过UDP
人工智能·算法·机器人
YOULANSHENGMENG2 小时前
深度学习的一些基础知识
人工智能·深度学习
Henry-SAP2 小时前
SAP MRP销售订单与预测驱动的业务解析
人工智能·sap·erp
RD_daoyi2 小时前
谷歌2026年 3 月核心更新深度解析:SEO 从内容优化到信息供给系统的全面重构
人工智能·算法·重构
KKKlucifer2 小时前
安全智能体:数据安全运营自动化与自主决策的技术突破
运维·安全·自动化
思绪无限2 小时前
YOLOv5至YOLOv12升级:常见车型识别系统的设计与实现(完整代码+界面+数据集项目)
人工智能·深度学习·yolo·目标检测·目标跟踪·yolov12·yolo全家桶
何妨呀~2 小时前
Subversion与Jenkins自动化平台
运维·自动化·jenkins
lkforce2 小时前
MiniMind学习笔记(零)--基础概念
人工智能·算法·机器学习·token·分词器·minimind·词汇表