Token-safe prompt assembly with memory orchestration. Use for any agent that needs to construct LLM prompts with memory retrieval. Guarantees no API failure due to token overflow. Implements two-phase context construction, memory safety valve, and hard limits on memory injection.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install prompt-assemble或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install prompt-assemble⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/prompt-assemble/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: prompt-assemble description: Token-safe prompt assembly with memory orchestration. Use for any agent that needs to construct LLM prompts with memory retrieval. Guarantees no API failure due to token overflow. Implements two-phase context construction, memory safety valve, and hard limits on memory injection. ---
A standardized, token-safe prompt assembly framework that guarantees API stability. Implements Two-Phase Context Construction and Memory Safety Valve to prevent token overflow while maximizing relevant context.
Design Goals:
Use this skill when:
User Input
↓
Need-Memory Decision
↓
Minimal Context Build
↓
Memory Retrieval (Optional)
↓
Memory Summarization
↓
Token Estimation
↓
Safety Valve Decision
↓
Final Prompt → LLM Call
# Model Context Windows (2026-02-04)
# - MiniMax-M2.1: 204,000 tokens (default)
# - Claude 3.5 Sonnet: 200,000 tokens
# - GPT-4o: 128,000 tokens
MAX_TOKENS = 204000 # Set to your model's context limit
SAFETY_MARGIN = 0.75 * MAX_TOKENS # Conservative: 75% threshold = 153,000 tokens
MEMORY_TOP_K = 3 # Max 3 memories
MEMORY_SUMMARY_MAX = 3 lines # Max 3 lines per memory
Design Philosophy:
def need_memory(user_input):
triggers = [
"previously",
"earlier we discussed",
"do you remember",
"as I mentioned before",
"continuing from",
"before we",
"last time",
"previously mentioned"
]
for trigger in triggers:
if trigger.lower() in user_input.lower():
return True
return False
memories = memory_search(query=user_input, top_k=MEMORY_TOP_K)
for mem in memories:
summarized_memories.append(summarize(mem, max_lines=MEMORY_SUMMARY_MAX))
Calculate estimated tokens for base_context + summarized_memories.
if estimated_tokens > SAFETY_MARGIN:
base_context.append("[System Notice] Relevant memory skipped due to token budget.")
return assemble(base_context)
Hard Rules:
final_prompt = assemble(base_context + summarized_memories)
return final_prompt
Copy scripts/prompt_assemble.py to your agent and use:
from prompt_assemble import build_prompt
# In your agent's prompt construction:
final_prompt = build_prompt(user_input, memory_search_fn, get_recent_dialog_fn)
prompt_assemble.py - Complete implementation with all phases (PromptAssembler class)memory_standards.md - Detailed memory content guidelinestoken_estimation.md - Token counting strategies安装 Prompt Safe 后,可以对 AI 说这些话来触发它
Help me get started with Prompt Safe
Explains what Prompt Safe does, walks through the setup, and runs a quick demo based on your current project
Use Prompt Safe to token-safe prompt assembly with memory orchestration
Invokes Prompt Safe with the right parameters and returns the result directly in the conversation
What can I do with Prompt Safe in my documents & notes workflow?
Lists the top use cases for Prompt Safe, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/prompt-assemble/ 目录(个人级,所有项目可用),或 .claude/skills/prompt-assemble/(项目级)。重启 AI 客户端后,用 /prompt-assemble 主动调用,或让 AI 根据上下文自动发现并使用。
Prompt Safe 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Prompt Safe 可免费安装使用。请查阅仓库了解许可证信息。
Token-safe prompt assembly with memory orchestration. Use for any agent that needs to construct LLM prompts with memory retrieval. Guarantees no API failure due to token overflow. Implements two-phase context construction, memory safety valve, and hard limits on memory injection.
Prompt Safe 属于「Documents & Notes」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my documents & notes tasks using Prompt Safe
Identifies repetitive steps in your workflow and sets up Prompt Safe to handle them automatically