← Back to Skills Marketplace
wangxiaofei860208-source

Attachment Inject

by wangxiaofei860208-source · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
80
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install attachment-inject
Description
动态附件注入 — 在不修改system prompt的情况下注入动态内容。参考Claude Code的Attachment消息机制。
README (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中
Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install attachment-inject
  3. After installation, invoke the skill by name or use /attachment-inject
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
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.
Metadata
Slug attachment-inject
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Attachment Inject?

动态附件注入 — 在不修改system prompt的情况下注入动态内容。参考Claude Code的Attachment消息机制。 It is an AI Agent Skill for Claude Code / OpenClaw, with 80 downloads so far.

How do I install Attachment Inject?

Run "/install attachment-inject" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Attachment Inject free?

Yes, Attachment Inject is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Attachment Inject support?

Attachment Inject is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Attachment Inject?

It is built and maintained by wangxiaofei860208-source (@wangxiaofei860208-source); the current version is v1.0.0.

💬 Comments