[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-69fc4250-5dda-4e50-8df6-9a02cf3d75b6":3,"$f0lnjhhStzSMipObmjbfdar9SbPghbLlZrM6qo1kFt00":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"69fc4250-5dda-4e50-8df6-9a02cf3d75b6","llm-prompt-optimizer","用于提升任何LLM的提示。应用经过验证的提示工程技术，提高输出质量，减少幻觉，并减少令牌使用。","cat_coding_backend","mod_coding","sickn33,coding","---\nname: llm-prompt-optimizer\ndescription: \"Use when improving prompts for any LLM. Applies proven prompt engineering techniques to boost output quality, reduce hallucinations, and cut token usage.\"\nrisk: safe\nsource: community\ndate_added: \"2026-03-04\"\n---\n\n# LLM Prompt Optimizer\n\n## Overview\n\nThis skill transforms weak, vague, or inconsistent prompts into precision-engineered instructions that reliably produce high-quality outputs from any LLM (Claude, Gemini, GPT-4, Llama, etc.). It applies systematic prompt engineering frameworks — from zero-shot to few-shot, chain-of-thought, and structured output patterns.\n\n## When to Use This Skill\n\n- Use when a prompt returns inconsistent, vague, or hallucinated results\n- Use when you need structured\u002FJSON output from an LLM reliably\n- Use when designing system prompts for AI agents or chatbots\n- Use when you want to reduce token usage without sacrificing quality\n- Use when implementing chain-of-thought reasoning for complex tasks\n- Use when prompts work on one model but fail on another\n\n## Step-by-Step Guide\n\n### 1. Diagnose the Weak Prompt\n\nBefore optimizing, identify which problem pattern applies:\n\n| Problem | Symptom | Fix |\n|---------|---------|-----|\n| Too vague | Generic, unhelpful answers | Add role + context + constraints |\n| No structure | Unformatted, hard-to-parse output | Specify output format explicitly |\n| Hallucination | Confident wrong answers | Add \"say I don't know if unsure\" |\n| Inconsistent | Different answers each run | Add few-shot examples |\n| Too long | Verbose, padded responses | Add length constraints |\n\n### 2. Apply the RSCIT Framework\n\nEvery optimized prompt should have:\n\n- **R** — **Role**: Who is the AI in this interaction?\n- **S** — **Situation**: What context does it need?\n- **C** — **Constraints**: What are the rules and limits?\n- **I** — **Instructions**: What exactly should it do?\n- **T** — **Template**: What should the output look like?\n\n**Before (weak prompt):**\n```\nExplain machine learning.\n```\n\n**After (optimized prompt):**\n```\nYou are a senior ML engineer explaining concepts to a junior developer.\n\nContext: The developer has 1 year of Python experience but no ML background.\n\nTask: Explain supervised machine learning in simple terms.\n\nConstraints:\n- Use an analogy from everyday life\n- Maximum 200 words\n- No mathematical formulas\n- End with one actionable next step\n\nFormat: Plain prose, no bullet points.\n```\n\n### 3. Chain-of-Thought (CoT) Pattern\n\nFor reasoning tasks, instruct the model to think step-by-step:\n\n```\nSolve this problem step by step, showing your work at each stage.\nOnly provide the final answer after completing all reasoning steps.\n\nProblem: [your problem here]\n\nThinking process:\nStep 1: [identify what's given]\nStep 2: [identify what's needed]\nStep 3: [apply logic or formula]\nStep 4: [verify the answer]\n\nFinal Answer:\n```\n\n### 4. Few-Shot Examples Pattern\n\nProvide 2-3 examples to establish the pattern:\n\n```\nClassify the sentiment of customer reviews as POSITIVE, NEGATIVE, or NEUTRAL.\n\nExamples:\nReview: \"This product exceeded my expectations!\" -> POSITIVE\nReview: \"It arrived broken and support was useless.\" -> NEGATIVE  \nReview: \"Product works as described, nothing special.\" -> NEUTRAL\n\nNow classify:\nReview: \"[your review here]\" ->\n```\n\n### 5. Structured JSON Output Pattern\n\n```\nExtract the following information from the text below and return it as valid JSON only.\nDo not include any explanation or markdown — just the raw JSON object.\n\nSchema:\n{\n  \"name\": string,\n  \"email\": string | null,\n  \"company\": string | null,\n  \"role\": string | null\n}\n\nText: [input text here]\n```\n\n### 6. Reduce Hallucination Pattern\n\n```\nAnswer the following question based ONLY on the provided context.\nIf the answer is not contained in the context, respond with exactly: \"I don't have enough information to answer this.\"\nDo not make up or infer information not present in the context.\n\nContext:\n[your context here]\n\nQuestion: [your question here]\n```\n\n### 7. Prompt Compression Techniques\n\nReduce token count without losing effectiveness:\n\n```\n# Verbose (expensive)\n\"Please carefully analyze the following code and provide a detailed explanation of \nwhat it does, how it works, and any potential issues you might find.\"\n\n# Compressed (efficient, same quality)\n\"Analyze this code: explain what it does, how it works, and flag any issues.\"\n```\n\n## Best Practices\n\n- ✅ **Do:** Always specify the output format (JSON, markdown, plain text, bullet list)\n- ✅ **Do:** Use delimiters (```, ---) to separate instructions from content\n- ✅ **Do:** Test prompts with edge cases (empty input, unusual data)\n- ✅ **Do:** Version your system prompts in source control\n- ✅ **Do:** Add \"think step by step\" for math, logic, or multi-step tasks\n- ❌ **Don't:** Use negative-only instructions (\"don't be verbose\") — add positive alternatives\n- ❌ **Don't:** Assume the model knows your codebase context — always include it\n- ❌ **Don't:** Use the same prompt across different models without testing — they behave differently\n\n## Prompt Audit Checklist\n\nBefore using a prompt in production:\n\n- [ ] Does it have a clear role\u002Fpersona?\n- [ ] Is the output format explicitly defined?\n- [ ] Are edge cases handled (empty input, ambiguous data)?\n- [ ] Is the length appropriate (not too long\u002Fshort)?\n- [ ] Has it been tested on 5+ varied inputs?\n- [ ] Is hallucination risk addressed for factual tasks?\n\n## Troubleshooting\n\n**Problem:** Model ignores format instructions\n**Solution:** Move format instructions to the END of the prompt, after examples. Use strong language: \"You MUST return only valid JSON.\"\n\n**Problem:** Inconsistent results between runs\n**Solution:** Lower the temperature setting (0.0-0.3 for factual tasks). Add more few-shot examples.\n\n**Problem:** Prompt works in playground but fails in production\n**Solution:** Check if system prompt is being sent correctly. Verify token limits aren't being exceeded (use a token counter).\n\n**Problem:** Output is too long\n**Solution:** Add explicit word\u002Fsentence limits: \"Respond in exactly 3 bullet points, each under 20 words.\"\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,115,1286,"2026-05-16 13:26:58",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"c1290a41-26fd-4c39-a63c-5b6638b65ab1","1.0.0","llm-prompt-optimizer.zip",3062,"uploads\u002Fskills\u002F69fc4250-5dda-4e50-8df6-9a02cf3d75b6\u002Fllm-prompt-optimizer.zip","7b1550a709e9bc80c65f0117ec0886434a7623c2d18ee40e91ceb611608779f3","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":6449}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]