{"id":"672c2366-0b12-423e-8dd5-441d179bcdb7","entityType":"agent","slug":"clawhub-margaretzybgl-optimize-prompt","name":"Optimize Prompt","canonicalUrl":"https://www.xpersona.co/agent/clawhub-margaretzybgl-optimize-prompt","canonicalPath":"/agent/clawhub-margaretzybgl-optimize-prompt","generatedAt":"2026-10-11T10:51:26.160Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-11T07:35:40.609Z","emptyReason":null},"description":"优化、压缩与审计 AI Prompt · Optimize prompts Skill: Optimize Prompt Owner: margaretzybgl Summary: 优化、压缩与审计 AI Prompt · Optimize prompts Tags: latest:0.1.3 Version history: v0.1.3 | 2026-07-31T17:14:01.936Z | user 补充中英文双语简介并保持现有分类。Added a concise bilingual summary while preserving marketplace categories. v0.1.2 | 2026-07-12T06:53:46.553Z | user Improve onboarding with Before/After examples, quick starts, real-world use cases, bilingual documentation, FAQ, roadma","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.","installCommand":"clawhub skill install s170y02ayvkmssb1ej7zeae4cx841f3g:optimize-prompt","sourceUrl":"https://clawhub.ai/margaretzybgl/optimize-prompt","homepage":"https://clawhub.ai/margaretzybgl/skills/optimize-prompt","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/margaretzybgl/optimize-prompt","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/margaretzybgl/skills/optimize-prompt","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":61,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"优化、压缩与审计 AI Prompt · Optimize prompts Skill: Optimize Prompt Owner: margaretzybgl Summary: 优化、压缩与审计 AI Prompt · Optimize prompts Tags: latest:0.1.3 Version hist"},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-11T07:35:40.609Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T07:35:40.609Z","emptyReason":null},"stars":null,"forks":null,"downloads":1122,"packageName":null,"latestVersion":"0.1.3","tractionLabel":"1.1K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T07:35:40.549Z","emptyReason":null},"lastUpdatedAt":"2026-10-11T07:35:40.609Z","lastCrawledAt":"2026-10-11T07:35:40.549Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-12T07:35:40.549Z","lastVerifiedAt":null,"highlights":[{"version":"0.1.3","createdAt":"2026-07-31T17:14:01.936Z","changelog":"补充中英文双语简介并保持现有分类。Added a concise bilingual summary while preserving marketplace categories.","fileCount":14,"zipByteSize":23251},{"version":"0.1.2","createdAt":"2026-07-12T06:53:46.553Z","changelog":"Improve onboarding with Before/After examples, quick starts, real-world use cases, bilingual documentation, FAQ, roadmap, and product cross-links.","fileCount":14,"zipByteSize":23157},{"version":"0.1.1","createdAt":"2026-07-11T18:08:59.729Z","changelog":"Rename public skill from optimize-prompt-v1 to optimize-prompt.","fileCount":13,"zipByteSize":18264},{"version":"0.1.0","createdAt":"2026-07-11T17:52:17.381Z","changelog":"- Initial release of the optimize-prompt-v1 skill: compresses and clarifies user prompts while preserving intent and constraints. - Adds audit ledger extraction to identify actions, entities, constraints, outputs, ambiguities, and risk factors in the prompt. - Implements conservative pass-through for ambiguous, unsafe, or highly-structured input. - Validates prompt fidelity, ensuring no added or missing critical elements in the optimization process. - Introduces a qualitative scoring system for original prompt clarity and completeness with actionable feedback. - Returns results in a structured JSON shape for traceability, auditing, and downstream integration.","fileCount":3,"zipByteSize":3118}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s170y02ayvkmssb1ej7zeae4cx841f3g:optimize-prompt","setupComplexity":"low","setupSteps":["Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-11T10:51:26.159Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-margaretzybgl-optimize-prompt/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-10-11T07:35:40.609Z","emptyReason":null},"readme":"Skill: Optimize Prompt\n\nOwner: margaretzybgl\n\nSummary: 优化、压缩与审计 AI Prompt · Optimize prompts\n\nTags: latest:0.1.3\n\nVersion history:\n\nv0.1.3 | 2026-07-31T17:14:01.936Z | user\n\n补充中英文双语简介并保持现有分类。Added a concise bilingual summary while preserving marketplace categories.\n\nv0.1.2 | 2026-07-12T06:53:46.553Z | user\n\nImprove onboarding with Before/After examples, quick starts, real-world use cases, bilingual documentation, FAQ, roadmap, and product cross-links.\n\nv0.1.1 | 2026-07-11T18:08:59.729Z | user\n\nRename public skill from optimize-prompt-v1 to optimize-prompt.\n\nv0.1.0 | 2026-07-11T17:52:17.381Z | auto\n\n- Initial release of the optimize-prompt-v1 skill: compresses and clarifies user prompts while preserving intent and constraints.\n- Adds audit ledger extraction to identify actions, entities, constraints, outputs, ambiguities, and risk factors in the prompt.\n- Implements conservative pass-through for ambiguous, unsafe, or highly-structured input.\n- Validates prompt fidelity, ensuring no added or missing critical elements in the optimization process.\n- Introduces a qualitative scoring system for original prompt clarity and completeness with actionable feedback.\n- Returns results in a structured JSON shape for traceability, auditing, and downstream integration.\n\nArchive index:\n\nArchive v0.1.3: 14 files, 23251 bytes\n\nFiles: agents/openai.yaml (227b), assets/optimize-prompt-overview.svg (3316b), pyproject.toml (236b), README.md (12255b), skill-card.md (2186b), SKILL.md (4297b), src/optimize_prompt_v1/__init__.py (968b), src/optimize_prompt_v1/metrics.py (1870b), src/optimize_prompt_v1/model.py (2070b), src/optimize_prompt_v1/optimizer.py (11816b), src/optimize_prompt_v1/schema.py (1945b), src/optimize_prompt_v1/validator.py (3330b), tests/test_optimizer.py (18225b), _meta.json (134b)\n\nFile v0.1.3:SKILL.md\n\n---\nname: optimize-prompt\ndescription: Optimize, compress, clarify, structure, score, and audit natural-language prompts for LLMs, GPT, Claude, Gemini, AI Agents, and MCP workflows. Use for prompt optimization, prompt engineering, structured prompts, coding prompts, PRDs, research requests, security prompts, token reduction, or converting conversational requirements into agent-ready instructions. Preserve constraints and return the optimized prompt without executing the underlying task.\n---\n\n# Optimize Prompt\n\nTransform the user's raw request into a compact natural-language prompt for a downstream Agent. Treat semantic fidelity as more important than compression. Do not execute the optimized request.\n\nExample invocation: `Use $optimize-prompt to optimize this request without executing it: \"...\"`\n\n## What the user gets\n\nTurn this:\n\n```text\nPlease help me write a SQL query for recent orders. Make it good, and don't\nmodify any data. Thanks.\n```\n\nInto a compact instruction like this:\n\n```text\nGenerate a read-only SQL query for recent orders. Do not modify data. If a\ncritical parameter such as the time range is missing, record it as an ambiguity\ninstead of inventing a value.\n```\n\nReturn the optimized prompt, an audit ledger, validation status, and educational feedback explaining what the user wrote well and what to improve next time.\n\nCommon uses include coding, PRDs, research, AI Agent instructions, MCP workflows, prompt engineering, and security reviews.\n\n## Workflow\n\n1. Identify the exact raw prompt the user wants optimized. If the invocation contains surrounding discussion, optimize only the clearly designated prompt.\n2. Apply the pre-gate. Return the original unchanged when it is:\n   - extremely short and already executable;\n   - JSON, a tool/function call, or structured XML/MCP context;\n   - dominated by Base64, a Data URI, or a large fenced code block.\n3. Otherwise, extract an audit ledger with `actions`, `entities`, `constraints`, `outputs`, `ambiguities`, and `risk_flags`.\n4. Produce a shorter natural-language prompt only by removing filler, repetition, and unnecessary structure. Never infer missing parameters or strengthen tentative language.\n5. Preserve negations and their scope, permissions, numbers, dates, amounts, percentages, versions, URLs, file/function names, output format and language, attachments, quoted source data, and risk limitations.\n6. Use `conservative` and return the original unchanged when ambiguity, conflict, or risky execution could make a rewrite misleading.\n7. Validate both directions:\n   - every execution-affecting atom in the optimized prompt appears in the audit ledger;\n   - every ledger item is traceable to the original prompt;\n   - no protected literal is missing or newly introduced.\n8. If validation is uncertain or fails, return the original unchanged.\n\n## Learning score\n\nScore only the original prompt's expression quality from 0 to 100. Evaluate clarity, constraint completeness, and conciseness. Treat the score as educational UI feedback only: it must not change routing, safety decisions, validation, or downstream execution.\n\nGive up to three strengths and three actionable improvements. Do not equate a high score with safety or permission. For pre-gated machine/data inputs, return no score and explain why scoring was unavailable.\n\n## Output\n\nReturn a concise JSON object using this shape:\n\n```json\n{\n  \"version\": \"v1\",\n  \"mode\": \"passthrough | optimized | conservative\",\n  \"original_prompt_score\": null,\n  \"score_status\": \"scored | not_scored | invalid\",\n  \"score_feedback\": {\n    \"strengths\": [],\n    \"improvements\": []\n  },\n  \"score_unavailable_reason\": \"\",\n  \"optimized_prompt\": \"\",\n  \"prompt_ir\": {\n    \"actions\": [],\n    \"entities\": [],\n    \"constraints\": [],\n    \"outputs\": [],\n    \"ambiguities\": [],\n    \"risk_flags\": []\n  },\n  \"confidence\": 0,\n  \"validation_failed\": false,\n  \"gate_reason\": \"\",\n  \"fallback_reason\": \"\",\n  \"conservative_reason\": \"\"\n}\n```\n\nKeep `optimized_prompt` as the only downstream instruction. Keep `prompt_ir` solely for audit, debugging, and regression testing.\n\n## Related skill\n\nWhen the user needs prompt-injection or policy defense instead of writing-quality optimization, recommend [LLM Prompt Firewall](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall).\n\nFile v0.1.3:README.md\n\n# Optimize Prompt\n\n### Compress • Clarify • Structure • Audit LLM Prompts\n\n[English](#english) · [中文](#中文) · [ClawHub](https://clawhub.ai/margaretzybgl/skills/optimize-prompt)\n\n![Optimize Prompt turns vague requests into agent-ready prompts](assets/optimize-prompt-overview.svg)\n\n## English\n\nTurn conversational, repetitive, or loosely structured requests into compact, auditable prompts for GPT, Claude, Gemini, MCP tools, and downstream AI Agents—without silently changing intent.\n\n### See the difference in 10 seconds\n\n**Before**\n\n```text\nHey, could you please help me write a SQL query for recent orders?\nMake it good, and please don't modify any data. Thanks.\n```\n\n**After**\n\n```text\nGenerate a read-only SQL query for recent orders. Preserve all stated scope and\ndo not modify data. If a critical parameter such as the time range is missing,\nrecord it as an ambiguity instead of inventing a value.\n```\n\nOptimize Prompt removes filler and repetition, preserves constraints, records ambiguity, validates protected literals, and returns only a downstream-ready prompt. When rewriting could be unsafe, it returns the original unchanged.\n\n## Install and get a result in under one minute\n\n```bash\nnpx clawhub@latest install @margaretzybgl/optimize-prompt\n```\n\nThen try:\n\n```text\nUse $optimize-prompt to optimize this without executing it:\n\"Please help me create a launch plan for Project Atlas by 2026-09-30.\nOnly create a draft. Do not publish or send anything. Output Markdown.\"\n```\n\nYou receive:\n\n- an `optimized_prompt` for the downstream Agent;\n- a minimal Prompt IR audit ledger;\n- validation and fallback status;\n- an educational quality score with strengths and next-time improvements.\n\nThe score is learning feedback only. It never changes routing, safety decisions, or execution.\n\n## Copy-ready quick starts\n\n### 1. Coding\n\n```text\nUse $optimize-prompt to optimize this coding request without implementing it:\n\"Refactor app.py for readability. Keep Python 3.11 compatibility, do not change\npublic APIs, and return a unified diff plus a short explanation.\"\n```\n\n### 2. Product requirements\n\n```text\nUse $optimize-prompt to optimize this PRD request without writing the PRD:\n\"Draft an MVP PRD for team task reminders. Prioritize mobile, exclude billing,\nand output goals, non-goals, user stories, acceptance criteria, and open questions.\"\n```\n\n### 3. MCP Agent workflow\n\n```text\nUse $optimize-prompt to optimize this MCP Agent instruction without running tools:\n\"Review the attached Q2 report, create an email draft for the finance team, and\ndo not send it. Preserve every amount and percentage. Output English Markdown.\"\n```\n\n### 4. Security review\n\n```text\nUse $optimize-prompt to optimize this security request without executing commands:\n\"Analyze auth.py for authentication weaknesses. Read only; do not modify files,\nrun exploits, expose secrets, or contact external services. Return a risk-ranked report.\"\n```\n\n## Real-world use cases\n\n| Use case | What Optimize Prompt adds |\n|---|---|\n| Coding | Scope, compatibility, non-goals, output expectations |\n| Writing | Audience, tone, structure, language, exclusions |\n| Research | Time range, sources, uncertainty, citation requirements |\n| AI Agent / MCP | Tool permissions, draft-only limits, attachment references |\n| Security review | Read-only boundaries, prohibited actions, risk-ranked output |\n\nUsed for: **Coding · Research · PRDs · AI Agents · MCP workflows · Prompt engineering · Security reviews**\n\n## Why not just ask a general chatbot?\n\nA one-off chatbot rewrite can be useful. Optimize Prompt makes the workflow reusable and predictable:\n\n- **Structured:** emits a stable natural-language prompt plus an audit ledger.\n- **Repeatable:** applies the same preservation and fallback policy every time.\n- **Consistent:** separates prompt optimization from task execution.\n- **Agent-ready:** explicitly preserves permissions, formats, attachments, and literals.\n- **Safer compression:** rejects rewrites that drop or invent protected parameters.\n- **Token-aware:** reports compression results and can reduce downstream prompt size when safe.\n\n## How it works\n\n```text\nOriginal Prompt -> Cheap Pre-Gate -> LLM Optimizer -> Validator -> optimized_prompt\n                            |                         |\n                            +-> passthrough           +-> fallback original\n\nPrompt IR -> logs / audit / regression tests\n```\n\nPre-Gate directly passes through machine or non-compressible inputs such as JSON, tool calls, Base64/Data URIs, code-dominant requests, and structured XML/MCP contexts. Validator protects negation scope, permissions, numbers, dates, amounts, percentages, URLs, file/function names, output requirements, and Prompt ↔ IR traceability.\n\nThree modes:\n\n- `passthrough`: already suitable or not meaningfully compressible;\n- `optimized`: safely rewritten and validated;\n- `conservative`: ambiguity, conflict, or risk requires the original prompt.\n\n## Python integration\n\n```python\nfrom optimize_prompt_v1 import OptimizerConfig, PromptOptimizer\n\noptimizer = PromptOptimizer(\n    config=OptimizerConfig(min_chars_for_model=20),\n    model=my_model_adapter,\n    tokenizer=my_provider_tokenizer,\n)\nresult = optimizer.optimize(user_prompt)\nsend_to_downstream(result.optimized_prompt)\n```\n\nThe model adapter remains vendor-neutral. Token fields describe this optimization only; API spending, historical costs, and ROI analysis are intentionally out of scope.\n\n## FAQ\n\n**When should I use it?**\n\nUse it before handing a conversational, repetitive, multi-constraint, or ambiguous request to an Agent, model, or MCP workflow.\n\n**When should I skip it?**\n\nSkip it for already-final JSON/tool calls, large code or Base64 payloads, and very short instructions that are already executable. The built-in Pre-Gate handles these cases.\n\n**Does it execute my request?**\n\nNo. It optimizes and audits the prompt only.\n\n**Which models does it support?**\n\nThe Skill instructions are model-agnostic. The Python library accepts an injected adapter for the provider you choose.\n\n**Does a high quality score mean the prompt is safe?**\n\nNo. The score teaches writing quality only; safety, validation, and execution permissions remain independent.\n\n**Can it guarantee fewer tokens?**\n\nNo. Semantic fidelity comes first. It reports the actual compression ratio and keeps the original when compression would be misleading.\n\n## Product family\n\nNeed prompt-injection and policy defense? Try **[LLM Prompt Firewall](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall)**.\n\n- **Optimize Prompt:** improve what you ask before execution.\n- **LLM Prompt Firewall:** inspect whether a prompt should be trusted or allowed.\n\n## Roadmap\n\n- [x] Safe prompt compression\n- [x] Prompt quality scoring and learning feedback\n- [x] Multilingual prompt optimization\n- [x] Agent/MCP-aware preservation rules\n- [ ] Provider adapter examples\n- [ ] Public compression and fidelity benchmark\n- [ ] Agent-specific prompt templates\n- [ ] More copy-ready onboarding recipes\n\n## Contributing\n\nIssues, examples, provider adapters, benchmark cases, and documentation improvements are welcome. Please open a [GitHub issue](https://github.com/margaretzybgl/optimize-prompt-v1/issues) with the original prompt, expected preservation behavior, and observed result—but remove secrets or personal data first.\n\nIf this Skill saves you time, please consider giving the [GitHub repository](https://github.com/margaretzybgl/optimize-prompt-v1) a ⭐. It helps more Agent builders discover the project.\n\n---\n\n## 中文\n\n将口语化、重复或结构松散的需求，转换为适合 GPT、Claude、Gemini、MCP 工具和下游 Agent 执行的紧凑 Prompt，同时避免静默改变用户意图。\n\n### 10 秒看懂价值\n\n**优化前**\n\n```text\n你好，麻烦帮我写一个查询最近订单的 SQL，写好一点，千万不要修改数据，谢谢。\n```\n\n**优化后**\n\n```text\n生成用于查询最近订单的只读 SQL。保留用户声明的全部范围，不得修改数据。\n如果缺少时间范围等关键参数，将其记录为歧义，不得自行补充。\n```\n\nOptimize Prompt 会删除填充与重复表达，保留强约束，记录歧义并校验关键字面量；如果改写可能误导执行，则原文透传。\n\n## 一分钟开始使用\n\n```bash\nnpx clawhub@latest install @margaretzybgl/optimize-prompt\n```\n\n安装后直接尝试：\n\n```text\n使用 $optimize-prompt 优化下面的请求，但不要执行它：\n“请为 Atlas 项目制定 2026-09-30 前的发布计划。只创建草稿，不发布、\n不发送。使用 Markdown 输出。”\n```\n\n输出包含：供下游使用的 `optimized_prompt`、最小 Prompt IR、验证与回退状态，以及只用于学习的原始 Prompt 质量评分和改进建议。评分不参与路由、安全判断或执行。\n\n## 适用场景\n\n- **编码：** 明确范围、兼容版本、禁止项与输出要求。\n- **PRD：** 补齐用户已经表达的目标、非目标、优先级和结构。\n- **研究：** 保留时间范围、来源要求、不确定性与引用格式。\n- **Agent / MCP：** 保留工具权限、附件引用和“只生成草稿，不发送”等限制。\n- **安全审查：** 固化只读边界、禁止动作和风险排序方式。\n\n适用于：**编码 · 研究 · PRD · AI Agent · MCP 工作流 · Prompt Engineering · 安全审查**\n\n## 为什么不直接让通用聊天模型改写？\n\n通用模型可以完成一次性改写；Optimize Prompt 将它变成稳定、可复用的网关流程：\n\n- 结构稳定：自然语言 Prompt 与审计 IR 分离；\n- 结果可重复：每次应用相同的保留与回退策略；\n- Agent-ready：显式保护权限、格式、附件与关键字面量；\n- 安全压缩：遗漏或新增关键参数时拒绝改写；\n- Token 可见：在安全时减少下游 Prompt，并报告实际压缩率。\n\n## 工作原理\n\n```text\n原始 Prompt -> Cheap Pre-Gate -> LLM 优化器 -> Validator -> optimized_prompt\n                         |                         |\n                         +-> 直接透传              +-> 回退原文\n\nPrompt IR -> 日志 / 调试 / 审计 / 回归测试\n```\n\n支持 `passthrough`、`optimized` 和 `conservative` 三种模式。Pre-Gate 直接透传 JSON、工具调用、Base64/Data URI、代码块占优和结构化 XML/MCP 等不适合压缩的输入。Validator 保护否定范围、权限、数字、日期、金额、比例、URL、文件名、函数名、输出要求和 Prompt ↔ IR 可追溯性。\n\n## 常见问题\n\n**什么时候需要？**\n\n当请求口语化、重复、多约束、结构混乱或可能存在关键歧义，并准备交给 Agent、模型或 MCP 工作流时。\n\n**什么时候不需要？**\n\n已经定稿的 JSON/工具调用、大段代码或 Base64 数据，以及已经简短可执行的指令。Pre-Gate 会自动处理。\n\n**会执行我的请求吗？**\n\n不会，只优化和审计 Prompt。\n\n**支持哪些模型？**\n\nSkill 指令与模型无关；Python 库通过注入适配器支持不同供应商。\n\n**高分是否代表安全？**\n\n不代表。评分只帮助用户学习如何写得更清楚，安全与执行权限独立判断。\n\n**一定能减少 Token 吗？**\n\n不能保证。语义完整性优先；无法安全压缩时保留原文。\n\n## 产品矩阵\n\n需要 Prompt Injection 与策略防护？试试 **[LLM Prompt Firewall](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall)**。\n\n- **Optimize Prompt：** 改善执行前“如何提问”。\n- **LLM Prompt Firewall：** 判断 Prompt 是否可信、是否允许进入执行链路。\n\n## Roadmap\n\n- [x] 安全 Prompt 压缩\n- [x] Prompt 评分与学习反馈\n- [x] 多语言优化\n- [x] Agent/MCP 约束保护\n- [ ] 模型供应商适配示例\n- [ ] 公开压缩率与语义保真基准\n- [ ] Agent 专用 Prompt 模板\n- [ ] 更多可复制的首次体验案例\n\n## 参与贡献\n\n欢迎提交 Issue、真实案例、供应商适配器、回归测试和文档改进。提交案例前请移除密钥与个人数据。\n\n如果这个 Skill 为你节省了时间，欢迎给 [GitHub 仓库](https://github.com/margaretzybgl/optimize-prompt-v1) 一个 ⭐，帮助更多 Agent 开发者发现它。\n\nFile v0.1.3:_meta.json\n\n{\n  \"ownerId\": \"kn77vr23k0jkt48km70rt63jh9840f4n\",\n  \"slug\": \"optimize-prompt\",\n  \"version\": \"0.1.3\",\n  \"publishedAt\": 1785518041936\n}\n\nFile v0.1.3:skill-card.md\n\n## Description:\n\nOptimizes, compresses, scores, and audits natural-language prompts for LLMs and agent workflows while preserving constraints and avoiding task execution.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[margaretzybgl](https://clawhub.ai/user/margaretzybgl)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers, prompt engineers, and agent builders use this skill to turn conversational or ambiguous requests into compact downstream-agent prompts with an audit ledger, validation status, and writing-quality feedback.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Installing with a floating @latest command can pull a version different from the reviewed release.\n\nMitigation: Pin the ClawHub installer and install a specific skill version when using this release.\n\nRisk: When integrated with a remote model provider, prompt text may be sent to that provider.\n\nMitigation: Avoid including secrets or sensitive data unless the provider setup is approved for that data.\n\nRisk: Prompt rewriting can drop or alter execution-affecting constraints if validation is bypassed.\n\nMitigation: Use the skill's conservative fallback and review optimized_prompt before passing it to downstream tools.\n\n## Reference(s):\n\n- [Optimize Prompt on ClawHub](https://clawhub.ai/margaretzybgl/skills/optimize-prompt)\n- [LLM Prompt Firewall related skill](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall)\n\n## Skill Output:\n\n**Output Type(s):** [text, JSON, guidance]\n\n**Output Format:** [JSON object containing an optimized prompt, audit ledger, validation status, confidence, and prompt-quality feedback.]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [The optimized_prompt field is the downstream instruction; Prompt IR is audit and debugging context only.]\n\n## Skill Version(s):\n\n0.1.3 (source: ClawHub release evidence)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v0.1.3:agents/openai.yaml\n\ninterface:\n  display_name: \"Optimize Prompt\"\n  short_description: \"优化、压缩与审计 AI Prompt · Optimize prompts\"\n  default_prompt: \"Use $optimize-prompt to safely optimize and score this prompt without executing it.\"\n\nFile v0.1.3:pyproject.toml\n\n[build-system]\nrequires = [\"setuptools>=68\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nname = \"optimize-prompt\"\nversion = \"0.1.0\"\nrequires-python = \">=3.10\"\n\n[tool.pytest.ini_options]\npythonpath = [\"src\"]\ntestpaths = [\"tests\"]\n\nArchive v0.1.2: 14 files, 23157 bytes\n\nFiles: agents/openai.yaml (233b), assets/optimize-prompt-overview.svg (3316b), pyproject.toml (236b), README.md (12255b), skill-card.md (2049b), SKILL.md (4297b), src/optimize_prompt_v1/__init__.py (968b), src/optimize_prompt_v1/metrics.py (1870b), src/optimize_prompt_v1/model.py (2070b), src/optimize_prompt_v1/optimizer.py (11816b), src/optimize_prompt_v1/schema.py (1945b), src/optimize_prompt_v1/validator.py (3330b), tests/test_optimizer.py (18225b), _meta.json (134b)\n\nFile v0.1.2:SKILL.md\n\n---\nname: optimize-prompt\ndescription: Optimize, compress, clarify, structure, score, and audit natural-language prompts for LLMs, GPT, Claude, Gemini, AI Agents, and MCP workflows. Use for prompt optimization, prompt engineering, structured prompts, coding prompts, PRDs, research requests, security prompts, token reduction, or converting conversational requirements into agent-ready instructions. Preserve constraints and return the optimized prompt without executing the underlying task.\n---\n\n# Optimize Prompt\n\nTransform the user's raw request into a compact natural-language prompt for a downstream Agent. Treat semantic fidelity as more important than compression. Do not execute the optimized request.\n\nExample invocation: `Use $optimize-prompt to optimize this request without executing it: \"...\"`\n\n## What the user gets\n\nTurn this:\n\n```text\nPlease help me write a SQL query for recent orders. Make it good, and don't\nmodify any data. Thanks.\n```\n\nInto a compact instruction like this:\n\n```text\nGenerate a read-only SQL query for recent orders. Do not modify data. If a\ncritical parameter such as the time range is missing, record it as an ambiguity\ninstead of inventing a value.\n```\n\nReturn the optimized prompt, an audit ledger, validation status, and educational feedback explaining what the user wrote well and what to improve next time.\n\nCommon uses include coding, PRDs, research, AI Agent instructions, MCP workflows, prompt engineering, and security reviews.\n\n## Workflow\n\n1. Identify the exact raw prompt the user wants optimized. If the invocation contains surrounding discussion, optimize only the clearly designated prompt.\n2. Apply the pre-gate. Return the original unchanged when it is:\n   - extremely short and already executable;\n   - JSON, a tool/function call, or structured XML/MCP context;\n   - dominated by Base64, a Data URI, or a large fenced code block.\n3. Otherwise, extract an audit ledger with `actions`, `entities`, `constraints`, `outputs`, `ambiguities`, and `risk_flags`.\n4. Produce a shorter natural-language prompt only by removing filler, repetition, and unnecessary structure. Never infer missing parameters or strengthen tentative language.\n5. Preserve negations and their scope, permissions, numbers, dates, amounts, percentages, versions, URLs, file/function names, output format and language, attachments, quoted source data, and risk limitations.\n6. Use `conservative` and return the original unchanged when ambiguity, conflict, or risky execution could make a rewrite misleading.\n7. Validate both directions:\n   - every execution-affecting atom in the optimized prompt appears in the audit ledger;\n   - every ledger item is traceable to the original prompt;\n   - no protected literal is missing or newly introduced.\n8. If validation is uncertain or fails, return the original unchanged.\n\n## Learning score\n\nScore only the original prompt's expression quality from 0 to 100. Evaluate clarity, constraint completeness, and conciseness. Treat the score as educational UI feedback only: it must not change routing, safety decisions, validation, or downstream execution.\n\nGive up to three strengths and three actionable improvements. Do not equate a high score with safety or permission. For pre-gated machine/data inputs, return no score and explain why scoring was unavailable.\n\n## Output\n\nReturn a concise JSON object using this shape:\n\n```json\n{\n  \"version\": \"v1\",\n  \"mode\": \"passthrough | optimized | conservative\",\n  \"original_prompt_score\": null,\n  \"score_status\": \"scored | not_scored | invalid\",\n  \"score_feedback\": {\n    \"strengths\": [],\n    \"improvements\": []\n  },\n  \"score_unavailable_reason\": \"\",\n  \"optimized_prompt\": \"\",\n  \"prompt_ir\": {\n    \"actions\": [],\n    \"entities\": [],\n    \"constraints\": [],\n    \"outputs\": [],\n    \"ambiguities\": [],\n    \"risk_flags\": []\n  },\n  \"confidence\": 0,\n  \"validation_failed\": false,\n  \"gate_reason\": \"\",\n  \"fallback_reason\": \"\",\n  \"conservative_reason\": \"\"\n}\n```\n\nKeep `optimized_prompt` as the only downstream instruction. Keep `prompt_ir` solely for audit, debugging, and regression testing.\n\n## Related skill\n\nWhen the user needs prompt-injection or policy defense instead of writing-quality optimization, recommend [LLM Prompt Firewall](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall).\n\nFile v0.1.2:README.md\n\n# Optimize Prompt\n\n### Compress • Clarify • Structure • Audit LLM Prompts\n\n[English](#english) · [中文](#中文) · [ClawHub](https://clawhub.ai/margaretzybgl/skills/optimize-prompt)\n\n![Optimize Prompt turns vague requests into agent-ready prompts](assets/optimize-prompt-overview.svg)\n\n## English\n\nTurn conversational, repetitive, or loosely structured requests into compact, auditable prompts for GPT, Claude, Gemini, MCP tools, and downstream AI Agents—without silently changing intent.\n\n### See the difference in 10 seconds\n\n**Before**\n\n```text\nHey, could you please help me write a SQL query for recent orders?\nMake it good, and please don't modify any data. Thanks.\n```\n\n**After**\n\n```text\nGenerate a read-only SQL query for recent orders. Preserve all stated scope and\ndo not modify data. If a critical parameter such as the time range is missing,\nrecord it as an ambiguity instead of inventing a value.\n```\n\nOptimize Prompt removes filler and repetition, preserves constraints, records ambiguity, validates protected literals, and returns only a downstream-ready prompt. When rewriting could be unsafe, it returns the original unchanged.\n\n## Install and get a result in under one minute\n\n```bash\nnpx clawhub@latest install @margaretzybgl/optimize-prompt\n```\n\nThen try:\n\n```text\nUse $optimize-prompt to optimize this without executing it:\n\"Please help me create a launch plan for Project Atlas by 2026-09-30.\nOnly create a draft. Do not publish or send anything. Output Markdown.\"\n```\n\nYou receive:\n\n- an `optimized_prompt` for the downstream Agent;\n- a minimal Prompt IR audit ledger;\n- validation and fallback status;\n- an educational quality score with strengths and next-time improvements.\n\nThe score is learning feedback only. It never changes routing, safety decisions, or execution.\n\n## Copy-ready quick starts\n\n### 1. Coding\n\n```text\nUse $optimize-prompt to optimize this coding request without implementing it:\n\"Refactor app.py for readability. Keep Python 3.11 compatibility, do not change\npublic APIs, and return a unified diff plus a short explanation.\"\n```\n\n### 2. Product requirements\n\n```text\nUse $optimize-prompt to optimize this PRD request without writing the PRD:\n\"Draft an MVP PRD for team task reminders. Prioritize mobile, exclude billing,\nand output goals, non-goals, user stories, acceptance criteria, and open questions.\"\n```\n\n### 3. MCP Agent workflow\n\n```text\nUse $optimize-prompt to optimize this MCP Agent instruction without running tools:\n\"Review the attached Q2 report, create an email draft for the finance team, and\ndo not send it. Preserve every amount and percentage. Output English Markdown.\"\n```\n\n### 4. Security review\n\n```text\nUse $optimize-prompt to optimize this security request without executing commands:\n\"Analyze auth.py for authentication weaknesses. Read only; do not modify files,\nrun exploits, expose secrets, or contact external services. Return a risk-ranked report.\"\n```\n\n## Real-world use cases\n\n| Use case | What Optimize Prompt adds |\n|---|---|\n| Coding | Scope, compatibility, non-goals, output expectations |\n| Writing | Audience, tone, structure, language, exclusions |\n| Research | Time range, sources, uncertainty, citation requirements |\n| AI Agent / MCP | Tool permissions, draft-only limits, attachment references |\n| Security review | Read-only boundaries, prohibited actions, risk-ranked output |\n\nUsed for: **Coding · Research · PRDs · AI Agents · MCP workflows · Prompt engineering · Security reviews**\n\n## Why not just ask a general chatbot?\n\nA one-off chatbot rewrite can be useful. Optimize Prompt makes the workflow reusable and predictable:\n\n- **Structured:** emits a stable natural-language prompt plus an audit ledger.\n- **Repeatable:** applies the same preservation and fallback policy every time.\n- **Consistent:** separates prompt optimization from task execution.\n- **Agent-ready:** explicitly preserves permissions, formats, attachments, and literals.\n- **Safer compression:** rejects rewrites that drop or invent protected parameters.\n- **Token-aware:** reports compression results and can reduce downstream prompt size when safe.\n\n## How it works\n\n```text\nOriginal Prompt -> Cheap Pre-Gate -> LLM Optimizer -> Validator -> optimized_prompt\n                            |                         |\n                            +-> passthrough           +-> fallback original\n\nPrompt IR -> logs / audit / regression tests\n```\n\nPre-Gate directly passes through machine or non-compressible inputs such as JSON, tool calls, Base64/Data URIs, code-dominant requests, and structured XML/MCP contexts. Validator protects negation scope, permissions, numbers, dates, amounts, percentages, URLs, file/function names, output requirements, and Prompt ↔ IR traceability.\n\nThree modes:\n\n- `passthrough`: already suitable or not meaningfully compressible;\n- `optimized`: safely rewritten and validated;\n- `conservative`: ambiguity, conflict, or risk requires the original prompt.\n\n## Python integration\n\n```python\nfrom optimize_prompt_v1 import OptimizerConfig, PromptOptimizer\n\noptimizer = PromptOptimizer(\n    config=OptimizerConfig(min_chars_for_model=20),\n    model=my_model_adapter,\n    tokenizer=my_provider_tokenizer,\n)\nresult = optimizer.optimize(user_prompt)\nsend_to_downstream(result.optimized_prompt)\n```\n\nThe model adapter remains vendor-neutral. Token fields describe this optimization only; API spending, historical costs, and ROI analysis are intentionally out of scope.\n\n## FAQ\n\n**When should I use it?**\n\nUse it before handing a conversational, repetitive, multi-constraint, or ambiguous request to an Agent, model, or MCP workflow.\n\n**When should I skip it?**\n\nSkip it for already-final JSON/tool calls, large code or Base64 payloads, and very short instructions that are already executable. The built-in Pre-Gate handles these cases.\n\n**Does it execute my request?**\n\nNo. It optimizes and audits the prompt only.\n\n**Which models does it support?**\n\nThe Skill instructions are model-agnostic. The Python library accepts an injected adapter for the provider you choose.\n\n**Does a high quality score mean the prompt is safe?**\n\nNo. The score teaches writing quality only; safety, validation, and execution permissions remain independent.\n\n**Can it guarantee fewer tokens?**\n\nNo. Semantic fidelity comes first. It reports the actual compression ratio and keeps the original when compression would be misleading.\n\n## Product family\n\nNeed prompt-injection and policy defense? Try **[LLM Prompt Firewall](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall)**.\n\n- **Optimize Prompt:** improve what you ask before execution.\n- **LLM Prompt Firewall:** inspect whether a prompt should be trusted or allowed.\n\n## Roadmap\n\n- [x] Safe prompt compression\n- [x] Prompt quality scoring and learning feedback\n- [x] Multilingual prompt optimization\n- [x] Agent/MCP-aware preservation rules\n- [ ] Provider adapter examples\n- [ ] Public compression and fidelity benchmark\n- [ ] Agent-specific prompt templates\n- [ ] More copy-ready onboarding recipes\n\n## Contributing\n\nIssues, examples, provider adapters, benchmark cases, and documentation improvements are welcome. Please open a [GitHub issue](https://github.com/margaretzybgl/optimize-prompt-v1/issues) with the original prompt, expected preservation behavior, and observed result—but remove secrets or personal data first.\n\nIf this Skill saves you time, please consider giving the [GitHub repository](https://github.com/margaretzybgl/optimize-prompt-v1) a ⭐. It helps more Agent builders discover the project.\n\n---\n\n## 中文\n\n将口语化、重复或结构松散的需求，转换为适合 GPT、Claude、Gemini、MCP 工具和下游 Agent 执行的紧凑 Prompt，同时避免静默改变用户意图。\n\n### 10 秒看懂价值\n\n**优化前**\n\n```text\n你好，麻烦帮我写一个查询最近订单的 SQL，写好一点，千万不要修改数据，谢谢。\n```\n\n**优化后**\n\n```text\n生成用于查询最近订单的只读 SQL。保留用户声明的全部范围，不得修改数据。\n如果缺少时间范围等关键参数，将其记录为歧义，不得自行补充。\n```\n\nOptimize Prompt 会删除填充与重复表达，保留强约束，记录歧义并校验关键字面量；如果改写可能误导执行，则原文透传。\n\n## 一分钟开始使用\n\n```bash\nnpx clawhub@latest install @margaretzybgl/optimize-prompt\n```\n\n安装后直接尝试：\n\n```text\n使用 $optimize-prompt 优化下面的请求，但不要执行它：\n“请为 Atlas 项目制定 2026-09-30 前的发布计划。只创建草稿，不发布、\n不发送。使用 Markdown 输出。”\n```\n\n输出包含：供下游使用的 `optimized_prompt`、最小 Prompt IR、验证与回退状态，以及只用于学习的原始 Prompt 质量评分和改进建议。评分不参与路由、安全判断或执行。\n\n## 适用场景\n\n- **编码：** 明确范围、兼容版本、禁止项与输出要求。\n- **PRD：** 补齐用户已经表达的目标、非目标、优先级和结构。\n- **研究：** 保留时间范围、来源要求、不确定性与引用格式。\n- **Agent / MCP：** 保留工具权限、附件引用和“只生成草稿，不发送”等限制。\n- **安全审查：** 固化只读边界、禁止动作和风险排序方式。\n\n适用于：**编码 · 研究 · PRD · AI Agent · MCP 工作流 · Prompt Engineering · 安全审查**\n\n## 为什么不直接让通用聊天模型改写？\n\n通用模型可以完成一次性改写；Optimize Prompt 将它变成稳定、可复用的网关流程：\n\n- 结构稳定：自然语言 Prompt 与审计 IR 分离；\n- 结果可重复：每次应用相同的保留与回退策略；\n- Agent-ready：显式保护权限、格式、附件与关键字面量；\n- 安全压缩：遗漏或新增关键参数时拒绝改写；\n- Token 可见：在安全时减少下游 Prompt，并报告实际压缩率。\n\n## 工作原理\n\n```text\n原始 Prompt -> Cheap Pre-Gate -> LLM 优化器 -> Validator -> optimized_prompt\n                         |                         |\n                         +-> 直接透传              +-> 回退原文\n\nPrompt IR -> 日志 / 调试 / 审计 / 回归测试\n```\n\n支持 `passthrough`、`optimized` 和 `conservative` 三种模式。Pre-Gate 直接透传 JSON、工具调用、Base64/Data URI、代码块占优和结构化 XML/MCP 等不适合压缩的输入。Validator 保护否定范围、权限、数字、日期、金额、比例、URL、文件名、函数名、输出要求和 Prompt ↔ IR 可追溯性。\n\n## 常见问题\n\n**什么时候需要？**\n\n当请求口语化、重复、多约束、结构混乱或可能存在关键歧义，并准备交给 Agent、模型或 MCP 工作流时。\n\n**什么时候不需要？**\n\n已经定稿的 JSON/工具调用、大段代码或 Base64 数据，以及已经简短可执行的指令。Pre-Gate 会自动处理。\n\n**会执行我的请求吗？**\n\n不会，只优化和审计 Prompt。\n\n**支持哪些模型？**\n\nSkill 指令与模型无关；Python 库通过注入适配器支持不同供应商。\n\n**高分是否代表安全？**\n\n不代表。评分只帮助用户学习如何写得更清楚，安全与执行权限独立判断。\n\n**一定能减少 Token 吗？**\n\n不能保证。语义完整性优先；无法安全压缩时保留原文。\n\n## 产品矩阵\n\n需要 Prompt Injection 与策略防护？试试 **[LLM Prompt Firewall](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall)**。\n\n- **Optimize Prompt：** 改善执行前“如何提问”。\n- **LLM Prompt Firewall：** 判断 Prompt 是否可信、是否允许进入执行链路。\n\n## Roadmap\n\n- [x] 安全 Prompt 压缩\n- [x] Prompt 评分与学习反馈\n- [x] 多语言优化\n- [x] Agent/MCP 约束保护\n- [ ] 模型供应商适配示例\n- [ ] 公开压缩率与语义保真基准\n- [ ] Agent 专用 Prompt 模板\n- [ ] 更多可复制的首次体验案例\n\n## 参与贡献\n\n欢迎提交 Issue、真实案例、供应商适配器、回归测试和文档改进。提交案例前请移除密钥与个人数据。\n\n如果这个 Skill 为你节省了时间，欢迎给 [GitHub 仓库](https://github.com/margaretzybgl/optimize-prompt-v1) 一个 ⭐，帮助更多 Agent 开发者发现它。\n\nFile v0.1.2:_meta.json\n\n{\n  \"ownerId\": \"kn77vr23k0jkt48km70rt63jh9840f4n\",\n  \"slug\": \"optimize-prompt\",\n  \"version\": \"0.1.2\",\n  \"publishedAt\": 1783839226553\n}\n\nFile v0.1.2:skill-card.md\n\n## Description: <br>\nOptimize, compress, clarify, structure, score, and audit natural-language prompts for LLMs, GPT, Claude, Gemini, AI Agents, and MCP workflows. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[margaretzybgl](https://clawhub.ai/user/margaretzybgl) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers, prompt engineers, and agent builders use this skill before execution to turn conversational or loosely structured requests into compact downstream prompts while preserving stated intent, constraints, permissions, literals, and output requirements. It also returns an audit ledger, validation status, and learning feedback about prompt clarity. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Review before execution as proposals could introduce incorrect or misleading guidance into skills. <br>\nMitigation: Review and scan skill before deployment. <br>\n\n## Reference(s): <br>\n- [ClawHub Optimize Prompt listing](https://clawhub.ai/margaretzybgl/skills/optimize-prompt) <br>\n- [LLM Prompt Firewall related skill](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, JSON, guidance] <br>\n**Output Format:** [Concise JSON object containing an optimized prompt, audit ledger, validation status, confidence, mode, and prompt-writing feedback] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [The skill does not execute the user's underlying task; prompts may be sent to the configured model adapter, so sensitive prompts should follow that provider's privacy rules.] <br>\n\n## Skill Version(s): <br>\n0.1.2 (source: ClawHub release evidence) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v0.1.2:agents/openai.yaml\n\ninterface:\n  display_name: \"Optimize Prompt\"\n  short_description: \"Compress, clarify, structure, score, and audit Agent prompts\"\n  default_prompt: \"Use $optimize-prompt to safely optimize and score this prompt without executing it.\"\n\nFile v0.1.2:pyproject.toml\n\n[build-system]\nrequires = [\"setuptools>=68\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nname = \"optimize-prompt\"\nversion = \"0.1.0\"\nrequires-python = \">=3.10\"\n\n[tool.pytest.ini_options]\npythonpath = [\"src\"]\ntestpaths = [\"tests\"]\n\nArchive v0.1.1: 13 files, 18264 bytes\n\nFiles: agents/openai.yaml (226b), pyproject.toml (236b), README.md (5007b), skill-card.md (2376b), SKILL.md (3264b), src/optimize_prompt_v1/__init__.py (968b), src/optimize_prompt_v1/metrics.py (1870b), src/optimize_prompt_v1/model.py (2070b), src/optimize_prompt_v1/optimizer.py (11816b), src/optimize_prompt_v1/schema.py (1945b), src/optimize_prompt_v1/validator.py (3330b), tests/test_optimizer.py (18225b), _meta.json (134b)\n\nFile v0.1.1:SKILL.md\n\n---\nname: optimize-prompt\ndescription: Safely compress, clarify, score, and audit a user's natural-language prompt before it is sent to another Agent or tool. Use when the user asks to optimize, shorten, clean up, restructure, translate into an executable prompt, evaluate prompt quality, or reduce prompt tokens without changing intent. Preserve all constraints and return the optimized prompt without executing the underlying task.\n---\n\n# Optimize Prompt\n\nTransform the user's raw request into a compact natural-language prompt for a downstream Agent. Treat semantic fidelity as more important than compression. Do not execute the optimized request.\n\n## Workflow\n\n1. Identify the exact raw prompt the user wants optimized. If the invocation contains surrounding discussion, optimize only the clearly designated prompt.\n2. Apply the pre-gate. Return the original unchanged when it is:\n   - extremely short and already executable;\n   - JSON, a tool/function call, or structured XML/MCP context;\n   - dominated by Base64, a Data URI, or a large fenced code block.\n3. Otherwise, extract an audit ledger with `actions`, `entities`, `constraints`, `outputs`, `ambiguities`, and `risk_flags`.\n4. Produce a shorter natural-language prompt only by removing filler, repetition, and unnecessary structure. Never infer missing parameters or strengthen tentative language.\n5. Preserve negations and their scope, permissions, numbers, dates, amounts, percentages, versions, URLs, file/function names, output format and language, attachments, quoted source data, and risk limitations.\n6. Use `conservative` and return the original unchanged when ambiguity, conflict, or risky execution could make a rewrite misleading.\n7. Validate both directions:\n   - every execution-affecting atom in the optimized prompt appears in the audit ledger;\n   - every ledger item is traceable to the original prompt;\n   - no protected literal is missing or newly introduced.\n8. If validation is uncertain or fails, return the original unchanged.\n\n## Learning score\n\nScore only the original prompt's expression quality from 0 to 100. Evaluate clarity, constraint completeness, and conciseness. Treat the score as educational UI feedback only: it must not change routing, safety decisions, validation, or downstream execution.\n\nGive up to three strengths and three actionable improvements. Do not equate a high score with safety or permission. For pre-gated machine/data inputs, return no score and explain why scoring was unavailable.\n\n## Output\n\nReturn a concise JSON object using this shape:\n\n```json\n{\n  \"version\": \"v1\",\n  \"mode\": \"passthrough | optimized | conservative\",\n  \"original_prompt_score\": null,\n  \"score_status\": \"scored | not_scored | invalid\",\n  \"score_feedback\": {\n    \"strengths\": [],\n    \"improvements\": []\n  },\n  \"score_unavailable_reason\": \"\",\n  \"optimized_prompt\": \"\",\n  \"prompt_ir\": {\n    \"actions\": [],\n    \"entities\": [],\n    \"constraints\": [],\n    \"outputs\": [],\n    \"ambiguities\": [],\n    \"risk_flags\": []\n  },\n  \"confidence\": 0,\n  \"validation_failed\": false,\n  \"gate_reason\": \"\",\n  \"fallback_reason\": \"\",\n  \"conservative_reason\": \"\"\n}\n```\n\nKeep `optimized_prompt` as the only downstream instruction. Keep `prompt_ir` solely for audit, debugging, and regression testing.\n\nFile v0.1.1:README.md\n\n# Optimize Prompt\n\n[English](#english) | [中文](#中文)\n\n## English\n\nA safe, auditable pre-execution prompt optimization gateway. It compresses conversational or repetitive requests without changing user intent, preserves execution-critical constraints, and provides educational prompt-quality feedback.\n\n> The model understands and rewrites; Python decides whether optimization is applicable and validates that meaning was not altered.\n\n### Workflow\n\n```text\nOriginal Prompt -> Cheap Pre-Gate -> LLM Optimizer -> Validator -> optimized_prompt\n                            |                         |\n                            +-> passthrough           +-> fallback original\n\nPrompt IR -> logs / audit / regression tests\n```\n\nThe downstream Agent receives only `optimized_prompt`. Prompt IR is a minimal audit ledger:\n\n```json\n{\n  \"actions\": [],\n  \"entities\": [],\n  \"constraints\": [],\n  \"outputs\": [],\n  \"ambiguities\": [],\n  \"risk_flags\": []\n}\n```\n\n### Key features\n\n- Three modes: `passthrough`, `optimized`, and `conservative`.\n- Deterministic pre-gates for short prompts, JSON, tool calls, Base64/Data URIs, code-dominant requests, and structured XML/MCP input.\n- Hard validation of negation scope, numbers, amounts, percentages, dates, URLs, file/function names, important parameters, and Prompt ↔ IR traceability.\n- Automatic fallback to the original prompt when validation or model execution fails.\n- Bounded retries only for explicit `RetryableModelError` failures such as timeouts and rate limits.\n- Educational quality scoring with separate strengths and actionable improvements. Scores never affect routing, safety decisions, or execution.\n- Conservative mode always sends the original prompt downstream when risk, ambiguity, or conflict makes rewriting unsafe.\n\n### Usage\n\n```python\nfrom optimize_prompt_v1 import OptimizerConfig, PromptOptimizer\n\noptimizer = PromptOptimizer(\n    config=OptimizerConfig(min_chars_for_model=20),\n    model=my_model_adapter,\n    tokenizer=my_provider_tokenizer,\n)\nresult = optimizer.optimize(user_prompt)\nsend_to_downstream(result.optimized_prompt)\n```\n\nImplement `ModelAdapter.optimize(prompt)` to return routing, the natural-language prompt, Prompt IR, confidence, and educational scoring in one call. `OPTIMIZER_SYSTEM_PROMPT` provides a vendor-neutral base instruction.\n\nToken fields describe only the current prompt's compression result: `original_tokens`, `optimized_tokens`, and `compression_ratio`. API spending, historical costs, and ROI analysis are intentionally outside this project's scope.\n\n### Test\n\n```bash\nPYTHONPATH=src python3 -m unittest discover -s tests -v\n```\n\n## 中文\n\n一个安全、可审计的事前 Prompt 优化网关。它在不改变用户意图的前提下压缩口语化、重复或结构混乱的需求，保留影响执行结果的关键约束，并向用户提供用于学习的 Prompt 质量反馈。\n\n> 模型负责理解与改写；Python 负责判断是否适合优化，并验证模型没有篡改用户意图。\n\n### 工作流程\n\n```text\n原始 Prompt -> Cheap Pre-Gate -> LLM 优化器 -> Validator -> optimized_prompt\n                         |                         |\n                         +-> 直接透传              +-> 回退原文\n\nPrompt IR -> 日志 / 调试 / 审计 / 回归测试\n```\n\n下游 Agent 只接收 `optimized_prompt`。Prompt IR 仅作为最小审计账本，不是下游执行协议。\n\n### 核心能力\n\n- 支持 `passthrough`、`optimized` 和 `conservative` 三种模式。\n- 对极短文本、JSON、工具调用、Base64/Data URI、代码块占优内容和结构化 XML/MCP 输入进行确定性 Pre-Gate 透传。\n- 硬校验否定词及其作用范围、数字、金额、比例、日期、URL、文件名、函数名、重要参数和 Prompt ↔ IR 可追溯性。\n- Validator 或模型调用失败时自动恢复原 Prompt，不阻断用户请求。\n- 只有超时、限流等显式 `RetryableModelError` 才会进行有限重试。\n- 返回表达质量分数、优点和可执行的改进建议；评分不参与路由、安全判断或执行。\n- 当风险、歧义或冲突可能导致误导性改写时，`conservative` 模式强制向下游发送原文。\n\n### 使用\n\n```python\nfrom optimize_prompt_v1 import OptimizerConfig, PromptOptimizer\n\noptimizer = PromptOptimizer(\n    config=OptimizerConfig(min_chars_for_model=20),\n    model=my_model_adapter,\n    tokenizer=my_provider_tokenizer,\n)\nresult = optimizer.optimize(user_prompt)\nsend_to_downstream(result.optimized_prompt)\n```\n\n模型适配器实现 `ModelAdapter.optimize(prompt)`，一次调用返回三态路由、自然语言 Prompt、Prompt IR、置信度和学习评分。`OPTIMIZER_SYSTEM_PROMPT` 提供与供应商无关的基础系统指令。\n\nToken 字段只描述本次事前优化效果：`original_tokens`、`optimized_tokens` 和 `compression_ratio`。API 费用、历史支出与 ROI 分析不属于本项目。\n\n### 运行测试\n\n```bash\nPYTHONPATH=src python3 -m unittest discover -s tests -v\n```\n\nFile v0.1.1:_meta.json\n\n{\n  \"ownerId\": \"kn77vr23k0jkt48km70rt63jh9840f4n\",\n  \"slug\": \"optimize-prompt\",\n  \"version\": \"0.1.1\",\n  \"publishedAt\": 1783793339729\n}\n\nFile v0.1.1:skill-card.md\n\n## Description: <br>\nSafely compresses, clarifies, scores, and audits natural-language prompts before they are sent to downstream agents while preserving user intent and constraints. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[margaretzybgl](https://clawhub.ai/user/margaretzybgl) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers and external users use this skill as a pre-execution gateway to convert conversational or repetitive prompts into compact downstream-agent instructions, preserve execution-critical constraints, and return audit and quality-score feedback without executing the underlying task. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: Prompts can contain sensitive information that may be sent to a model adapter or provider during optimization. <br>\nMitigation: Connect the skill only to trusted model adapters or providers and avoid sending secrets unless the surrounding application provides appropriate privacy controls. <br>\nRisk: A rewritten prompt could unintentionally alter user intent or omit execution-critical constraints. <br>\nMitigation: Use the built-in conservative mode, deterministic pre-gates, validation checks, and fallback behavior so uncertain or failed rewrites return the original prompt unchanged. <br>\n\n\n## Reference(s): <br>\n- [ClawHub Skill Page](https://clawhub.ai/margaretzybgl/skills/optimize-prompt) <br>\n- [README](README.md) <br>\n- [Skill Definition](SKILL.md) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [JSON, Text, Guidance] <br>\n**Output Format:** [JSON object with an optimized natural-language prompt, audit ledger, confidence, validation status, and educational scoring fields] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Returns passthrough, optimized, or conservative mode; optimized_prompt is the only downstream instruction, while prompt_ir is for audit, debugging, and regression testing.] <br>\n\n## Skill Version(s): <br>\n0.1.1 (source: server release metadata) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>\n\nFile v0.1.1:agents/openai.yaml\n\ninterface:\n  display_name: \"Optimize Prompt\"\n  short_description: \"安全压缩、审计并评价面向 Agent 的 Prompt\"\n  default_prompt: \"Use $optimize-prompt to safely optimize and score this prompt without executing it.\"\n\nFile v0.1.1:pyproject.toml\n\n[build-system]\nrequires = [\"setuptools>=68\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nname = \"optimize-prompt\"\nversion = \"0.1.0\"\nrequires-python = \">=3.10\"\n\n[tool.pytest.ini_options]\npythonpath = [\"src\"]\ntestpaths = [\"tests\"]\n\nArchive v0.1.0: 3 files, 3118 bytes\n\nFiles: skill-card.md (2316b), SKILL.md (3271b), _meta.json (134b)\n\nFile v0.1.0:SKILL.md\n\n---\nname: optimize-prompt-v1\ndescription: Safely compress, clarify, score, and audit a user's natural-language prompt before it is sent to another Agent or tool. Use when the user asks to optimize, shorten, clean up, restructure, translate into an executable prompt, evaluate prompt quality, or reduce prompt tokens without changing intent. Preserve all constraints and return the optimized prompt without executing the underlying task.\n---\n\n# Optimize Prompt V1\n\nTransform the user's raw request into a compact natural-language prompt for a downstream Agent. Treat semantic fidelity as more important than compression. Do not execute the optimized request.\n\n## Workflow\n\n1. Identify the exact raw prompt the user wants optimized. If the invocation contains surrounding discussion, optimize only the clearly designated prompt.\n2. Apply the pre-gate. Return the original unchanged when it is:\n   - extremely short and already executable;\n   - JSON, a tool/function call, or structured XML/MCP context;\n   - dominated by Base64, a Data URI, or a large fenced code block.\n3. Otherwise, extract an audit ledger with `actions`, `entities`, `constraints`, `outputs`, `ambiguities`, and `risk_flags`.\n4. Produce a shorter natural-language prompt only by removing filler, repetition, and unnecessary structure. Never infer missing parameters or strengthen tentative language.\n5. Preserve negations and their scope, permissions, numbers, dates, amounts, percentages, versions, URLs, file/function names, output format and language, attachments, quoted source data, and risk limitations.\n6. Use `conservative` and return the original unchanged when ambiguity, conflict, or risky execution could make a rewrite misleading.\n7. Validate both directions:\n   - every execution-affecting atom in the optimized prompt appears in the audit ledger;\n   - every ledger item is traceable to the original prompt;\n   - no protected literal is missing or newly introduced.\n8. If validation is uncertain or fails, return the original unchanged.\n\n## Learning score\n\nScore only the original prompt's expression quality from 0 to 100. Evaluate clarity, constraint completeness, and conciseness. Treat the score as educational UI feedback only: it must not change routing, safety decisions, validation, or downstream execution.\n\nGive up to three strengths and three actionable improvements. Do not equate a high score with safety or permission. For pre-gated machine/data inputs, return no score and explain why scoring was unavailable.\n\n## Output\n\nReturn a concise JSON object using this shape:\n\n```json\n{\n  \"version\": \"v1\",\n  \"mode\": \"passthrough | optimized | conservative\",\n  \"original_prompt_score\": null,\n  \"score_status\": \"scored | not_scored | invalid\",\n  \"score_feedback\": {\n    \"strengths\": [],\n    \"improvements\": []\n  },\n  \"score_unavailable_reason\": \"\",\n  \"optimized_prompt\": \"\",\n  \"prompt_ir\": {\n    \"actions\": [],\n    \"entities\": [],\n    \"constraints\": [],\n    \"outputs\": [],\n    \"ambiguities\": [],\n    \"risk_flags\": []\n  },\n  \"confidence\": 0,\n  \"validation_failed\": false,\n  \"gate_reason\": \"\",\n  \"fallback_reason\": \"\",\n  \"conservative_reason\": \"\"\n}\n```\n\nKeep `optimized_prompt` as the only downstream instruction. Keep `prompt_ir` solely for audit, debugging, and regression testing.\n\nFile v0.1.0:_meta.json\n\n{\n  \"ownerId\": \"kn77vr23k0jkt48km70rt63jh9840f4n\",\n  \"slug\": \"optimize-prompt\",\n  \"version\": \"0.1.0\",\n  \"publishedAt\": 1783792337381\n}\n\nFile v0.1.0:skill-card.md\n\n## Description: <br>\nSafely compresses, clarifies, scores, and audits a user's natural-language prompt before it is sent to another agent or tool without changing intent or executing the underlying task. <br>\n\nThis skill is ready for commercial/non-commercial use. <br>\n\n## Publisher: <br>\n[margaretzybgl](https://clawhub.ai/user/margaretzybgl) <br>\n\n### License/Terms of Use: <br>\nMIT-0 <br>\n\n\n## Use Case: <br>\nDevelopers and external users use this skill to rewrite prompts into concise, faithful downstream instructions, score prompt clarity, and expose an audit ledger before sending the prompt to another agent or tool. <br>\n\n### Deployment Geography for Use: <br>\nGlobal <br>\n\n## Known Risks and Mitigations: <br>\nRisk: A rewritten prompt could drop or alter permissions, safety limits, legal or financial details, code, or exact formatting requirements. <br>\nMitigation: Review optimized prompts before important use; the skill is designed to pass through or use conservative mode when ambiguity, conflict, risky execution, or validation uncertainty could make a rewrite misleading. <br>\nRisk: Users may mistake the learning score for permission or safety clearance. <br>\nMitigation: Treat the score only as educational feedback; the artifact states it must not affect routing, safety decisions, validation, or downstream execution. <br>\n\n\n## Reference(s): <br>\n- [Server-resolved GitHub source](https://github.com/margaretzybgl/optimize-prompt-v1) <br>\n- [ClawHub skill page](https://clawhub.ai/margaretzybgl/skills/optimize-prompt-v1) <br>\n\n\n## Skill Output: <br>\n**Output Type(s):** [text, JSON, guidance] <br>\n**Output Format:** [Concise JSON object containing the optimized prompt, score feedback, audit ledger, mode, confidence, and fallback fields.] <br>\n**Output Parameters:** [1D] <br>\n**Other Properties Related to Output:** [Keeps optimized_prompt as the only downstream instruction; prompt_ir is for audit, debugging, and regression testing.] <br>\n\n## Skill Version(s): <br>\n0.1.0 (source: server release metadata) <br>\n\n## Ethical Considerations: <br>\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment. <br>","readmeExcerpt":"Skill: Optimize Prompt Owner: margaretzybgl Summary: 优化、压缩与审计 AI Prompt · Optimize prompts Tags: latest:0.1.3 Version history: v0.1.3 | 2026-07-31T17:14:01.936Z | user 补充中英文双语简介并保持现有分类。Added a concise bilingual summary while preserving marketplace categories. v0.1.2 | 2026-07-12T06:53:46.553Z | user Improve onboarding with Before/After examples, quick starts, real-world use cases, bilingual documentation, FAQ, roadma","codeSnippets":[],"executableExamples":[{"language":"text","snippet":"Please help me write a SQL query for recent orders. Make it good, and don't\nmodify any data. Thanks."},{"language":"text","snippet":"Generate a read-only SQL query for recent orders. Do not modify data. If a\ncritical parameter such as the time range is missing, record it as an ambiguity\ninstead of inventing a value."},{"language":"json","snippet":"{\n  \"version\": \"v1\",\n  \"mode\": \"passthrough | optimized | conservative\",\n  \"original_prompt_score\": null,\n  \"score_status\": \"scored | not_scored | invalid\",\n  \"score_feedback\": {\n    \"strengths\": [],\n    \"improvements\": []\n  },\n  \"score_unavailable_reason\": \"\",\n  \"optimized_prompt\": \"\",\n  \"prompt_ir\": {\n    \"actions\": [],\n    \"entities\": [],\n    \"constraints\": [],\n    \"outputs\": [],\n    \"ambiguities\": [],\n    \"risk_flags\": []\n  },\n  \"confidence\": 0,\n  \"validation_failed\": false,\n  \"gate_reason\": \"\",\n  \"fallback_reason\": \"\",\n  \"conservative_reason\": \"\"\n}"},{"language":"text","snippet":"Hey, could you please help me write a SQL query for recent orders?\nMake it good, and please don't modify any data. Thanks."},{"language":"text","snippet":"Generate a read-only SQL query for recent orders. Preserve all stated scope and\ndo not modify data. If a critical parameter such as the time range is missing,\nrecord it as an ambiguity instead of inventing a value."},{"language":"bash","snippet":"npx clawhub@latest install @margaretzybgl/optimize-prompt"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: optimize-prompt\ndescription: Optimize, compress, clarify, structure, score, and audit natural-language prompts for LLMs, GPT, Claude, Gemini, AI Agents, and MCP workflows. Use for prompt optimization, prompt engineering, structured prompts, coding prompts, PRDs, research requests, security prompts, token reduction, or converting conversational requirements into agent-ready instructions. Preserve constraints and return the optimized prompt without executing the underlying task.\n---\n\n# Optimize Prompt\n\nTransform the user's raw request into a compact natural-language prompt for a downstream Agent. Treat semantic fidelity as more important than compression. Do not execute the optimized request.\n\nExample invocation: `Use $optimize-prompt to optimize this request without executing it: \"...\"`\n\n## What the user gets\n\nTurn this:\n\n```text\nPlease help me write a SQL query for recent orders. Make it good, and don't\nmodify any data. Thanks.\n```\n\nInto a compact instruction like this:\n\n```text\nGenerate a read-only SQL query for recent orders. Do not modify data. If a\ncritical parameter such as the time range is missing, record it as an ambiguity\ninstead of inventing a value.\n```\n\nReturn the optimized prompt, an audit ledger, validation status, and educational feedback explaining what the user wrote well and what to improve next time.\n\nCommon uses include coding, PRDs, research, AI Agent instructions, MCP workflows, prompt engineering, and security reviews.\n\n## Workflow\n\n1. Identify the exact raw prompt the user wants optimized. If the invocation contains surrounding discussion, optimize only the clearly designated prompt.\n2. Apply the pre-gate. Return the original unchanged when it is:\n   - extremely short and already executable;\n   - JSON, a tool/function call, or structured XML/MCP context;\n   - dominated by Base64, a Data URI, or a large fenced code block.\n3. Otherwise, extract an audit ledger with `actions`, `entities`, `constraints`, `outputs`, `ambiguities`, and `risk_flags`.\n4. Produce a shorter natural-language prompt only by removing filler, repetition, and unnecessary structure. Never infer missing parameters or strengthen tentative language.\n5. Preserve negations and their scope, permissions, numbers, dates, amounts, percentages, versions, URLs, file/function names, output format and language, attachments, quoted source data, and risk limitations.\n6. Use `conservative` and return the original unchanged when ambiguity, conflict, or risky execution could make a rewrite misleading.\n7. Validate both directions:\n   - every execution-affecting atom in the optimized prompt appears in the audit ledger;\n   - every ledger item is traceable to the original prompt;\n   - no protected literal is missing or newly introduced.\n8. If validation is uncertain or fails, return the original unchanged.\n\n## Learning score\n\nScore only the original prompt's expression quality from 0 to 100. Evaluate clarity, constraint completeness, and conciseness. Treat the score "},{"path":"README.md","content":"# Optimize Prompt\n\n### Compress • Clarify • Structure • Audit LLM Prompts\n\n[English](#english) · [中文](#中文) · [ClawHub](https://clawhub.ai/margaretzybgl/skills/optimize-prompt)\n\n![Optimize Prompt turns vague requests into agent-ready prompts](assets/optimize-prompt-overview.svg)\n\n## English\n\nTurn conversational, repetitive, or loosely structured requests into compact, auditable prompts for GPT, Claude, Gemini, MCP tools, and downstream AI Agents—without silently changing intent.\n\n### See the difference in 10 seconds\n\n**Before**\n\n```text\nHey, could you please help me write a SQL query for recent orders?\nMake it good, and please don't modify any data. Thanks.\n```\n\n**After**\n\n```text\nGenerate a read-only SQL query for recent orders. Preserve all stated scope and\ndo not modify data. If a critical parameter such as the time range is missing,\nrecord it as an ambiguity instead of inventing a value.\n```\n\nOptimize Prompt removes filler and repetition, preserves constraints, records ambiguity, validates protected literals, and returns only a downstream-ready prompt. When rewriting could be unsafe, it returns the original unchanged.\n\n## Install and get a result in under one minute\n\n```bash\nnpx clawhub@latest install @margaretzybgl/optimize-prompt\n```\n\nThen try:\n\n```text\nUse $optimize-prompt to optimize this without executing it:\n\"Please help me create a launch plan for Project Atlas by 2026-09-30.\nOnly create a draft. Do not publish or send anything. Output Markdown.\"\n```\n\nYou receive:\n\n- an `optimized_prompt` for the downstream Agent;\n- a minimal Prompt IR audit ledger;\n- validation and fallback status;\n- an educational quality score with strengths and next-time improvements.\n\nThe score is learning feedback only. It never changes routing, safety decisions, or execution.\n\n## Copy-ready quick starts\n\n### 1. Coding\n\n```text\nUse $optimize-prompt to optimize this coding request without implementing it:\n\"Refactor app.py for readability. Keep Python 3.11 compatibility, do not change\npublic APIs, and return a unified diff plus a short explanation.\"\n```\n\n### 2. Product requirements\n\n```text\nUse $optimize-prompt to optimize this PRD request without writing the PRD:\n\"Draft an MVP PRD for team task reminders. Prioritize mobile, exclude billing,\nand output goals, non-goals, user stories, acceptance criteria, and open questions.\"\n```\n\n### 3. MCP Agent workflow\n\n```text\nUse $optimize-prompt to optimize this MCP Agent instruction without running tools:\n\"Review the attached Q2 report, create an email draft for the finance team, and\ndo not send it. Preserve every amount and percentage. Output English Markdown.\"\n```\n\n### 4. Security review\n\n```text\nUse $optimize-prompt to optimize this security request without executing commands:\n\"Analyze auth.py for authentication weaknesses. Read only; do not modify files,\nrun exploits, expose secrets, or contact external services. Return a risk-ranked report.\"\n```\n\n## Real-world use cases\n\n| Use case | What Optimize Prompt adds |\n|---|---|"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn77vr23k0jkt48km70rt63jh9840f4n\",\n  \"slug\": \"optimize-prompt\",\n  \"version\": \"0.1.3\",\n  \"publishedAt\": 1785518041936\n}"},{"path":"skill-card.md","content":"## Description:\n\nOptimizes, compresses, scores, and audits natural-language prompts for LLMs and agent workflows while preserving constraints and avoiding task execution.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[margaretzybgl](https://clawhub.ai/user/margaretzybgl)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers, prompt engineers, and agent builders use this skill to turn conversational or ambiguous requests into compact downstream-agent prompts with an audit ledger, validation status, and writing-quality feedback.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Installing with a floating @latest command can pull a version different from the reviewed release.\n\nMitigation: Pin the ClawHub installer and install a specific skill version when using this release.\n\nRisk: When integrated with a remote model provider, prompt text may be sent to that provider.\n\nMitigation: Avoid including secrets or sensitive data unless the provider setup is approved for that data.\n\nRisk: Prompt rewriting can drop or alter execution-affecting constraints if validation is bypassed.\n\nMitigation: Use the skill's conservative fallback and review optimized_prompt before passing it to downstream tools.\n\n## Reference(s):\n\n- [Optimize Prompt on ClawHub](https://clawhub.ai/margaretzybgl/skills/optimize-prompt)\n- [LLM Prompt Firewall related skill](https://clawhub.ai/margaretzybgl/skills/llm-prompt-firewall)\n\n## Skill Output:\n\n**Output Type(s):** [text, JSON, guidance]\n\n**Output Format:** [JSON object containing an optimized prompt, audit ledger, validation status, confidence, and prompt-quality feedback.]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [The optimized_prompt field is the downstream instruction; Prompt IR is audit and debugging context only.]\n\n## Skill Version(s):\n\n0.1.3 (source: ClawHub release evidence)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment."},{"path":"agents/openai.yaml","content":"interface:\n  display_name: \"Optimize Prompt\"\n  short_description: \"优化、压缩与审计 AI Prompt · Optimize prompts\"\n  default_prompt: \"Use $optimize-prompt to safely optimize and score this prompt without executing it.\""}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"优化、压缩与审计 AI Prompt · Optimize prompts Skill: Optimize Prompt Owner: margaretzybgl Summary: 优化、压缩与审计 AI Prompt · Optimize prompts Tags: latest:0.1.3 Version history: v0.1.3 | 2026-07-31T17:14:01.936Z | user 补充中英文双语简介并保持现有分类。Added a concise bilingual summary while preserving marketplace categories. v0.1.2 | 2026-07-12T06:53:46.553Z | user Improve onboarding with Before/After examples, quick starts, real-world use cases, bilingual documentation, FAQ, roadma","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":1283,"uniquenessScore":49,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-11T07:35:40.609Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-11T07:35:40.609Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-11T10:51:26.160Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}