← 返回 Skills 市场
wangxiaofei860208-source

Attachment Inject

作者 wangxiaofei860208-source · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
80
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install attachment-inject
功能描述
动态附件注入 — 在不修改system prompt的情况下注入动态内容。参考Claude Code的Attachment消息机制。
使用说明 (SKILL.md)

Attachment Inject — 动态附件注入

参考 Claude Code 的 attachments.ts,将动态内容作为attachment消息注入而非嵌入system prompt。

问题

每次注入技能列表、Agent列表等动态内容到system prompt会:

  1. 增加每次请求的token消耗
  2. 内容变化时破坏prompt cache
  3. 无法动态更新

解决方案

模式1: 按需读取(当前OpenClaw支持)

不预注入内容,而是在需要时读取:

用户提到"调度Agent" → 读 agents/*.md → 选择合适的Agent
用户提到"调试" → 读 skills/systematic-debugging/SKILL.md → 激活技能

模式2: 注册表文件(轻量注入)

维护一个注册表文件,包含名称+描述,不包含完整内容:

# agents/registry.md(自动生成)
| Agent | 描述 |
|-------|------|
| code-reviewer | 代码质量+安全审查 |
| planner | 实现规划(Opus) |
| chief-of-staff | 多渠道消息分诊 |
...

# skills/registry.md(自动生成)
| 技能 | 描述 |
|------|------|
| coordinator | 三层多Agent协调 |
| compact | 长会话压缩 |
...

模式3: 动态注入点

在AGENTS.md中定义占位符,每次会话开始时替换:

\x3C!-- INJECT:SKILLS_REGISTRY -->
\x3C!-- INJECT:AGENTS_REGISTRY -->
\x3C!-- INJECT:MEMORY_SUMMARY -->

注册表生成脚本

# 生成技能注册表
for dir in skills/*/; do
  name=$(basename "$dir")
  desc=$(grep "^description:" "$dir/SKILL.md" 2>/dev/null | head -1 | sed 's/description: *//' | cut -c1-60)
  echo "| $name | $desc |"
done

# 生成Agent注册表
for f in agents/*.md; do
  name=$(grep "^name:" "$f" | head -1 | sed 's/name: *//')
  desc=$(grep "^description:" "$f" | head -1 | sed 's/description: *//' | cut -c1-60)
  echo "| $name | $desc |"
done

最佳实践

  1. 注册表 \x3C 500 token — 只含名称和一行描述
  2. 完整内容按需加载 — 匹配到任务时才读SKILL.md
  3. 变化时只更新注册表 — 不动system prompt
  4. 核心技能始终加载 — 9个核心技能的描述直接在AGENTS.md中
安全使用建议
This skill is coherent with its stated goal (generate small registries and load content on demand), but it implicitly requires reading and writing local skill/agent files and modifying AGENTS.md. Before installing, confirm: 1) which exact paths the skill will read/write (have the developer declare them) and restrict permissions to a safe directory; 2) whether you want the skill to make persistent edits to AGENTS.md or other config files and have a review/backup process; 3) that the shell commands suggested (grep/sed loops) will run in a sandbox and won't be expanded to read unrelated files; and 4) that no secrets or sensitive files reside under the targeted paths. If you are not comfortable granting broad filesystem write access, ask the author to limit the scope (explicit config paths) or run the logic in a read-only/sandboxed environment and approve registry updates manually.
功能分析
Type: OpenClaw Skill Name: attachment-inject Version: 1.0.0 The skill bundle provides a design pattern and a bash script for optimizing prompt context by generating lightweight registries of available skills and agents. It uses standard Unix commands (grep, sed, cut) in SKILL.md to extract metadata from local files to reduce token consumption and improve prompt caching. No malicious behaviors, data exfiltration, or harmful prompt injection attempts were identified.
能力评估
Purpose & Capability
The name/description match the instructions: the skill explains patterns for injecting dynamic 'attachments' and generating lightweight registries. Requesting file read/write access is reasonable for this purpose. However, the package metadata in the registry shows no declared config paths while the SKILL.md explicitly references reading skills/*/SKILL.md, agents/*.md and writing registry files (agents/registry.md, skills/registry.md, AGENTS.md). The skill should declare the exact file paths it needs.
Instruction Scope
The SKILL.md tells the agent to read and parse local files (agents/*.md, skills/*/SKILL.md) and to write generated registry files and to replace placeholders in AGENTS.md each session. Those are concrete filesystem operations outside the skill bundle; the skill instructions therefore implicitly require filesystem access and the ability to modify repository/config files. The instructions do not limit scope (e.g., only under a sandboxed directory), so there's risk of unintended reading/modifying of other files if implemented broadly.
Install Mechanism
There is no install spec and no code files; this is instruction-only, which minimizes install-time risk.
Credentials
No environment variables or external credentials are requested. That aligns with the stated local-file registry generation purpose.
Persistence & Privilege
The skill does not request always:true and does not ask to be permanently enabled, but its recommended behavior includes persistent edits (writing registries and updating AGENTS.md each session). Persistent modification of agent/skill registry files is a meaningful privilege and should be explicitly scoped and approved by the user or admin.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install attachment-inject
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /attachment-inject 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release introducing dynamic attachment injection for OpenClaw, inspired by Claude Code's attachment mechanism. - Enables injecting dynamic content as attachments instead of modifying the system prompt. - Reduces token consumption and preserves prompt caching by not embedding full lists directly. - Supports multiple modes: on-demand reading, lightweight registries, and dynamic injection placeholders. - Includes registry generation scripts for agents and skills with name and description only. - Provides best practices for efficient and dynamic content management in prompts.
元数据
Slug attachment-inject
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Attachment Inject 是什么?

动态附件注入 — 在不修改system prompt的情况下注入动态内容。参考Claude Code的Attachment消息机制。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 80 次。

如何安装 Attachment Inject?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install attachment-inject」即可一键安装,无需额外配置。

Attachment Inject 是免费的吗?

是的,Attachment Inject 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Attachment Inject 支持哪些平台?

Attachment Inject 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Attachment Inject?

由 wangxiaofei860208-source(@wangxiaofei860208-source)开发并维护,当前版本 v1.0.0。

💬 留言讨论