DeepAgents 社媒技能实战:用 SKILL.md 编写“研究先行”的 LinkedIn 与 Twitter 内容工作流

发布时间:2026/9/10 15:33:32
DeepAgents 社媒技能实战:用 SKILL.md 编写“研究先行”的 LinkedIn 与 Twitter 内容工作流 DeepAgents 社媒技能实战用 SKILL.md 编写“研究先行”的 LinkedIn 与 Twitter 内容工作流【免费下载链接】deepagentsThe batteries-included agent harness.项目地址: https://gitcode.com/GitHub_Trending/de/deepagentsdeepagents 的 Content Builder Agent 示例展示了如何用文件系统原语记忆、技能、子代理拼装一个内容写作 Agent。其中 social-media 技能 负责社媒场景当用户要求撰写 LinkedIn 帖子、Twitter/X 推文或线程时该技能规定了完整的执行流程——先委派researcher子代理做调研再按平台格式写稿最后用generate_social_image工具生成配图做到“图文一体、缺图即未完成”。读完本文你将理解该技能文件的每个规则如何落地以及背后的 SkillsMiddleware、task 委派机制和图像工具的源码实现。技能如何被加载渐进式披露机制social-media/SKILL.md 采用 YAML frontmatter Markdown 指令体结构frontmatter 定义了两个必填字段--- name: social-media description: Drafts engaging social media posts, writes hooks, suggests hashtags, creates thread structures, and generates companion images. Use when the user asks to write a LinkedIn post, tweet, Twitter/X thread, social media caption, social post, or repurpose content for social platforms. ---这个文件在示例中通过create_deep_agent的skills参数挂载见 content_writer.pydef create_content_writer(): Create a content writer agent configured by filesystem files. return create_deep_agent( memory[./AGENTS.md], # Loaded by MemoryMiddleware skills[./skills/], # Loaded by SkillsMiddleware tools[generate_cover, generate_social_image], # Image generation subagentsload_subagents(EXAMPLE_DIR / subagents.yaml), # Custom helper backendFilesystemBackend(root_dirEXAMPLE_DIR), )从源码结构看加载逻辑位于 SkillsMiddlewarebefore_agent钩子扫描技能目录下所有含SKILL.md的子目录用yaml.safe_load解析 frontmatter校验name1–64 字符、小写字母与连字符、须与目录名一致和description上限 1024 字符。加载采用渐进式披露progressive disclosure系统提示词中只注入每个技能的名称、描述和路径Read path for full instructionsAgent 在任务匹配到某个技能描述时才用read_file建议limit1000读取全文。这就是为什么该技能把description写得如此详尽——“LinkedIn post、tweet、Twitter/X thread、caption、repurpose content” 这些关键词是触发路由的依据。多个技能源按声明顺序加载后加载的同名技能覆盖先加载的last one wins这支持 base → user → project 的分层覆写。本示例只有一个源./skills/包含 blog-post 与 social-media 两个技能Agent 按用户请求选择其一。第一步强制委派调研Research First技能的第一条硬性规则写任何社媒内容之前必须委派调研。规范动作是调用task工具、指定subagent_type: researcher并在描述中同时给出主题与保存路径task( subagent_typeresearcher, descriptionResearch [TOPIC]. Save findings to research/[slug].md )文档给出的具体示例task( subagent_typeresearcher, descriptionResearch renewable energy trends in 2025. Save findings to research/renewable-energy.md )调研完成后Agent 必须先读取research/*.md结果文件再动笔。researcher 子代理的定义与来源researcher并非内置能力而是本示例在 subagents.yaml 中声明的researcher: description: ALWAYS use this first to research any topic before writing content. Searches the web for current information, statistics, and sources. When delegating, tell it the topic AND the file path to save results (e.g., Research renewable energy and save to research/renewable-energy.md). model: anthropic:claude-haiku-4-5-20251001 system_prompt: | You are a research assistant. You have access to web_search and write_file tools. ## Your Process 1. Use web_search to find information on the topic 2. Make 2-3 targeted searches with specific queries 3. Gather key statistics, quotes, and examples 4. Save findings to the file path specified in your task ## Important - The user will tell you WHERE to save the file - use that exact path - Always include source URLs in your findings tools: - web_search几个值得注意的实现细节task工具由框架提供。subagents 中间件 为每个声明的子代理构建独立图并注入名为task的结构化工具其入参含subagent_typeThe type of subagent to use与任务描述调用不存在的类型会直接返回错误信息并列出合法类型。researcher 是隔离模式isolated它只看到委派描述不继承父会话系统提示词要求它做 2–3 次定向搜索、收集统计/引语/示例并把结果连同来源 URL 写入指定路径。YAML 外置是示例的自定义做法。content_writer.py 中的load_subagents()明确注释deepagents 不像memory和skills那样原生从文件加载子代理此处将其外置到 YAML 只是为了配置与代码分离解析后按name/description/system_prompt/model/tools组装工具名通过available_tools字典映射到真实工具对象web_search。researcher 用 Haiku 模型、主 Agent 用默认Anthropic 主力模型体现了“便宜模型干调研、贵模型干写作”的分工。web_search工具本身在 content_writer.py 中以tool装饰器实现底层调用 Tavily需TAVILY_API_KEY未配置时返回错误对象而非抛异常。第二步强制的图文输出结构技能规定每条社媒内容必须同时包含正文和图片且两者同目录存放LinkedIn 帖子linkedin/ └── slug/ ├── post.md # The post content └── image.png # REQUIRED: Generated visualTwitter/X 线程tweets/ └── slug/ ├── thread.md # The thread content └── image.png # REQUIRED: Generated visual例如关于 prompt engineering 的 LinkedIn 帖子 →linkedin/prompt-engineering/。文档强调两步缺一不可1) 用文件写入工具写正文到对应路径2) 用图像工具生成图片存到帖子旁。“A social media post is NOT complete without its image.”这里的slug目录是内容寻址的产物FilesystemBackend(root_dirEXAMPLE_DIR)把 content-builder-agent 目录 作为根write_file与图像工具都在同一根下工作因此输出目录结构在示例 README 中可直接对应linkedin/ └── ai-agents/ ├── post.md # Post content └── image.png # Generated image research/ └── prompt-engineering.md # Research notes见 README.md 的 Output 一节。平台格式指南LinkedIn 与 Twitter/X技能按平台给出硬性的格式、语气与结构约束这是技能区别于“通用写作指令”的核心价值。LinkedIn格式约束1,300 字符上限约 210 字符后触发 “show more” 折叠首行决定生死——必须写成钩子用空行分行提升可读性结尾 3–5 个话题标签语气要求专业但不失个人色彩分享洞察与经验用提问驱动互动使用第一人称 I。固定结构模板原文档原样继承[Hook - 1 compelling line] [Empty line] [Context - why this matters] [Empty line] [Main insight - 2-3 short paragraphs] [Empty line] [Call to action or question] #hashtag1 #hashtag2 #hashtag3注意空行是结构的一部分折叠前的首屏只露出钩子和上下文开头段落间的空行控制信息密度。Twitter/X格式约束每条推文 280 字符上限长内容用线程采用1/格式每条推文最多 2 个话题标签线程结构模板1/ [Hook - the main insight] 2/ [Supporting point 1] 3/ [Supporting point 2] 4/ [Example or evidence] 5/ [Conclusion CTA]该模板的叙事节奏是“钩子 → 论据 → 论据 → 证据 → 结论CTA”第 1 条负责留存中间条数负责递进末条负责转化。配图生成generate_social_image 工具与提示词工程工具用法技能规定使用generate_social_imagegenerate_social_image(promptA detailed description..., platformlinkedin, slugyour-post-slug)工具会把图片保存到platform/slug/image.png与正文同目录——这与上文输出结构严格对应。源码实现该工具定义在 content_writer.pytool def generate_social_image(prompt: str, platform: str, slug: str) - str: Generate an image for a social media post. Args: prompt: Detailed description of the image to generate. platform: Either linkedin or tweets slug: Post slug. Image saves to platform/slug/image.png try: from google import genai client genai.Client() response client.models.generate_content( modelgemini-2.5-flash-image, contents[prompt], ) for part in response.parts: if part.inline_data is not None: image part.as_image() output_path EXAMPLE_DIR / platform / slug / image.png output_path.parent.mkdir(parentsTrue, exist_okTrue) image.save(str(output_path)) return fImage saved to {output_path} return No image generated except Exception as e: return fError: {e}实现要点模型为gemini-2.5-flash-imageGoogle GenAI 客户端需GOOGLE_API_KEY与 blog-post 技能使用的generate_cover存blogs/slug/hero.png是同一套模式platform取值是linkedin或tweets直接参与路径拼接因此技能中的目录约定linkedin/、tweets/与工具参数一一对应slug 必须一致图片才会落在帖子旁边失败路径返回No image generated或Error: ...字符串而非异常AgentDisplay 会依据 ToolMessage 中是否含 saved 打印✓ Image saved或✗ Image failed形成可观察的执行反馈。社媒图片最佳实践技能给出四条针对“拥挤信息流中缩略图场景”的准则大胆简洁的构图——单一清晰焦点高对比度——滚动浏览时依然醒目图中不放文字——缩略图上看不清平台也会自加文字正方形或 4:5 比例——跨平台通用有效提示词的四个要素单一焦点一个明确主体而非杂乱场景大胆风格鲜艳色彩、强烈形状、高对比简单背景纯色、渐变或细腻纹理情绪/能量匹配帖子基调鼓舞、紧迫、深思技能提供了三段可直接复用的示例提示词洞察/技巧类帖子Single glowing lightbulb floating against a deep purple gradient background, lightbulb made of interconnected golden geometric lines, rays of soft light emanating outward. Minimal, striking, high contrast. Square composition.公告/新闻类Abstract rocket ship made of colorful geometric shapes launching upward with a trail of particles. Bright coral and teal color scheme against clean white background. Energetic, celebratory mood. Bold flat illustration style.思想启发类内容Two overlapping translucent circles, one blue one orange, creating a glowing intersection in the center. Represents collaboration or intersection of ideas. Dark charcoal background, soft ethereal glow. Minimalist and contemplative.三类内容模板技能按内容意图划分三类帖子各给出三步要点公告类Announcement Posts以新闻本身开头说明影响附上链接或下一步动作洞察类Insight Posts分享一个具体心得简要交代背景使其可执行提问类Question Posts提出真诚的问题先给出自己的看法聚焦单一主题质量检查清单Quality Checklist技能以清单收尾要求交付前逐项确认帖子已存至linkedin/slug/post.md或tweets/slug/thread.md配图已生成并与帖子同目录首行是钩子内容符合平台字符上限语气符合平台惯例有明确的 CTA 或提问话题标签相关拒绝泛标签完整运行流程与端到端验证结合 content-builder-agent/README.md整条链路为Agent 接收任务 → 依据技能描述命中 social-media 技能read_file读取完整指令调task委派researcher→ 结果落盘research/slug.md按平台模板写稿 → 落盘linkedin/slug/post.md或tweets/slug/thread.md调generate_social_image→ 图片落到同目录image.png。运行方式需 Python 3.11 与对应 API Keyuv首次运行自动装依赖依赖清单见 pyproject.toml核心依赖deepagents0.6.12、google-genai、pyyaml、rich、tavily-pythonexport ANTHROPIC_API_KEY... export GOOGLE_API_KEY... # For image generation export TAVILY_API_KEY... # For web search (optional) cd examples/content-builder-agent uv run python content_writer.py Create a LinkedIn post about AI agents uv run python content_writer.py Write a Twitter thread about the future of codingAgentDisplay对关键工具调用做了专门着色输出 Researching:、 Generating image...、 Writing:、✓ Research complete便于人工核验四步流程是否都执行了。安全方面README 提示该 Agent 拥有文件系统读写能力应在非敏感目录运行发布前人工复核内容。把这套模式迁移到你自己的场景技能的可定制性是示例刻意展示的设计改品牌语气编辑 AGENTS.md品牌声音、写作标准、内容支柱、格式规范由 MemoryMiddleware 常驻注入系统提示词例如它的“Research Requirements”要求至少 3 个可信来源加新内容类型新建skills/name/SKILL.mdfrontmatter 中name必须与目录名一致SkillsMiddleware 会按 Agent Skills 规范校验description写清“做什么 何时用”并堆叠路由关键词加新子代理在 subagents.yaml 追加条目如editor审阅草稿tools留空则继承默认工具集加新工具在content_writer.py用tool定义后加入tools[...]。这一示例的整体思想是工作流知识沉淀在 SKILL.md按需加载、可分层覆写品牌约束沉淀在 AGENTS.md常驻执行能力拆到子代理与工具代码。社媒技能本身就是一个“研究先行 平台约束 强制配图 交付清单”的完整工作流范式值得直接复制为模板改写到任何结构化内容生产场景。【免费下载链接】deepagentsThe batteries-included agent harness.项目地址: https://gitcode.com/GitHub_Trending/de/deepagents创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考