[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6NW1WXF433QB992W2S6XETB":3,"skill-same:01M6NW1WXF433QB992W2S6XETB":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":14,"repositoryHtmlUrl":45,"repositoryHomepageUrl":6,"ownerHtmlUrl":46,"ownerBlogUrl":47,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6NW1WXF433QB992W2S6XETB","prompt-engineering",null,"Prompt templates, few-shot examples, chain-of-thought, structured output, evals","rubicanjr\u002FFinCognis","rubicanjr","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F234912519?v=4","01M6NT156NND8J474G34SB3923","Rubi","01M6NT15B70RWXE1N3YV0BZY8A",0,"MIT","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fprompt-engineering\u002Fskill.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36],"prompt engineering","engineering","prompt","prompt templates","examples","templates","evals","structured","structured output","chain","chain-of-thought","few-shot","output","2026-11-10 10:12:30",false,"---\nname: prompt-engineering\ndescription: Prompt templates, few-shot examples, chain-of-thought, structured output, evals\n---\n\n# Prompt Engineering\n\n## Prompt Templates\n\n### System Prompt Structure\n\n```python\nSYSTEM_PROMPT = \"\"\"You are a {role} specialized in {domain}.\n\n## Task\n{task_description}\n\n## Rules\n{numbered_rules}\n\n## Output Format\n{format_spec}\n\n## Examples\n{few_shot_examples}\n\"\"\"\n```\n\n### Few-Shot Template\n\n```python\ndef build_few_shot_prompt(task: str, examples: list[dict], query: str) -> str:\n    prompt = f\"Task: {task}\\n\\n\"\n    for i, ex in enumerate(examples, 1):\n        prompt += f\"Example {i}:\\nInput: {ex['input']}\\nOutput: {ex['output']}\\n\\n\"\n    prompt += f\"Now process:\\nInput: {query}\\nOutput:\"\n    return prompt\n\n# Usage\nexamples = [\n    {\"input\": \"The food was great\", \"output\": '{\"sentiment\": \"positive\", \"confidence\": 0.95}'},\n    {\"input\": \"Terrible service\", \"output\": '{\"sentiment\": \"negative\", \"confidence\": 0.90}'},\n    {\"input\": \"It was okay\", \"output\": '{\"sentiment\": \"neutral\", \"confidence\": 0.70}'},\n]\nprompt = build_few_shot_prompt(\"Classify sentiment as JSON\", examples, \"Really loved it!\")\n```\n\n## Chain-of-Thought Patterns\n\n### Explicit CoT\n\n```\nAnalyze this code for security vulnerabilities.\n\nThink step by step:\n1. Identify all user inputs\n2. Trace each input through the code\n3. Check if any input reaches a sensitive operation without sanitization\n4. For each vulnerability found, classify severity (critical\u002Fhigh\u002Fmedium\u002Flow)\n5. Suggest a fix for each vulnerability\n\nCode:\n{code}\n```\n\n### Self-Consistency (Multiple CoT paths)\n\n```python\nimport json\nfrom collections import Counter\n\nasync def self_consistent_answer(question: str, n_paths: int = 5) -> str:\n    answers = []\n    for _ in range(n_paths):\n        response = await llm.generate(\n            f\"Think step by step and answer: {question}\\n\\nFinal answer:\",\n            temperature=0.7,  # Higher temp for diversity\n        )\n        final = extract_final_answer(response)\n        answers.append(final)\n\n    # Majority vote\n    most_common = Counter(answers).most_common(1)[0][0]\n    return most_common\n```\n\n## Structured Output\n\n### JSON Mode with Schema\n\n```python\nfrom pydantic import BaseModel, Field\nfrom openai import OpenAI\n\nclass CodeReview(BaseModel):\n    issues: list[dict] = Field(description=\"List of issues found\")\n    severity: str = Field(description=\"Overall severity: low|medium|high|critical\")\n    summary: str = Field(description=\"One-line summary\")\n    suggestions: list[str] = Field(description=\"Improvement suggestions\")\n\nclient = OpenAI()\n\nresponse = client.beta.chat.completions.parse(\n    model=\"gpt-4o\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"Review code and output structured analysis.\"},\n        {\"role\": \"user\", \"content\": f\"Review this code:\\n```\\n{code}\\n```\"},\n    ],\n    response_format=CodeReview,\n)\n\nreview = response.choices[0].message.parsed\n```\n\n### XML Tags for Claude\n\n```\n\u003Ctask>Analyze the following error log and extract structured information.\u003C\u002Ftask>\n\n\u003Crules>\n- Extract timestamp, severity, service name, and error message\n- Classify root cause category\n- Output in the specified XML format\n\u003C\u002Frules>\n\n\u003Cinput>\n{error_log}\n\u003C\u002Finput>\n\n\u003Coutput_format>\n\u003Canalysis>\n  \u003Ctimestamp>ISO 8601\u003C\u002Ftimestamp>\n  \u003Cseverity>ERROR|WARN|FATAL\u003C\u002Fseverity>\n  \u003Cservice>service name\u003C\u002Fservice>\n  \u003Cmessage>error message\u003C\u002Fmessage>\n  \u003Croot_cause>category\u003C\u002Froot_cause>\n  \u003Csuggested_fix>actionable fix\u003C\u002Fsuggested_fix>\n\u003C\u002Fanalysis>\n\u003C\u002Foutput_format>\n```\n\n## Prompt Evaluation Framework\n\n```python\nclass PromptEvaluator:\n    def __init__(self, test_cases: list[dict]):\n        self.test_cases = test_cases  # [{\"input\": ..., \"expected\": ..., \"criteria\": ...}]\n\n    async def evaluate(self, prompt_template: str) -> dict:\n        results = []\n        for case in self.test_cases:\n            prompt = prompt_template.format(**case[\"input\"])\n            output = await llm.generate(prompt)\n            score = self._score(output, case[\"expected\"], case.get(\"criteria\", {}))\n            results.append({\"input\": case[\"input\"], \"output\": output, \"score\": score})\n\n        return {\n            \"avg_score\": sum(r[\"score\"] for r in results) \u002F len(results),\n            \"pass_rate\": sum(1 for r in results if r[\"score\"] >= 0.8) \u002F len(results),\n            \"failures\": [r for r in results if r[\"score\"] \u003C 0.8],\n        }\n\n    def _score(self, output: str, expected: str, criteria: dict) -> float:\n        scores = []\n        if \"contains\" in criteria:\n            scores.append(1.0 if criteria[\"contains\"] in output else 0.0)\n        if \"format\" in criteria:\n            scores.append(1.0 if self._check_format(output, criteria[\"format\"]) else 0.0)\n        if \"max_length\" in criteria:\n            scores.append(1.0 if len(output) \u003C= criteria[\"max_length\"] else 0.0)\n        return sum(scores) \u002F len(scores) if scores else 0.5\n```\n\n## Checklist\n\n- [ ] System prompt defines role, task, rules, and output format\n- [ ] Few-shot examples cover edge cases (not just happy path)\n- [ ] Chain-of-thought used for reasoning-heavy tasks\n- [ ] Structured output enforced via JSON mode or XML tags\n- [ ] Prompts tested with evaluation suite (10+ test cases)\n- [ ] Temperature set appropriately (0 for deterministic, 0.7+ for creative)\n- [ ] Prompt versioned and tracked alongside code\n- [ ] Negative examples included (\"Do NOT do X\")\n\n## Anti-Patterns\n\n- Vague instructions without concrete examples\n- Asking for multiple unrelated tasks in one prompt\n- Not specifying output format (getting unparseable responses)\n- Using temperature=0 for tasks needing diversity\n- Prompt injection vulnerable (no input sanitization)\n- Testing with only 1-2 examples (not statistically meaningful)\n- Hardcoding prompts in application code (not configurable)\n- Ignoring token limits (prompt + expected output exceeds context)\n","# Prompt Engineering\n\n## Prompt Templates\n\n### System Prompt Structure\n\n```python\nSYSTEM_PROMPT = \"\"\"You are a {role} specialized in {domain}.\n\n## Task\n{task_description}\n\n## Rules\n{numbered_rules}\n\n## Output Format\n{format_spec}\n\n## Examples\n{few_shot_examples}\n\"\"\"\n```\n\n### Few-Shot Template\n\n```python\ndef build_few_shot_prompt(task: str, examples: list[dict], query: str) -> str:\n    prompt = f\"Task: {task}\\n\\n\"\n    for i, ex in enumerate(examples, 1):\n        prompt += f\"Example {i}:\\nInput: {ex['input']}\\nOutput: {ex['output']}\\n\\n\"\n    prompt += f\"Now process:\\nInput: {query}\\nOutput:\"\n    return prompt\n\n# Usage\nexamples = [\n    {\"input\": \"The food was great\", \"output\": '{\"sentiment\": \"positive\", \"confidence\": 0.95}'},\n    {\"input\": \"Terrible service\", \"output\": '{\"sentiment\": \"negative\", \"confidence\": 0.90}'},\n    {\"input\": \"It was okay\", \"output\": '{\"sentiment\": \"neutral\", \"confidence\": 0.70}'},\n]\nprompt = build_few_shot_prompt(\"Classify sentiment as JSON\", examples, \"Really loved it!\")\n```\n\n## Chain-of-Thought Patterns\n\n### Explicit CoT\n\n```\nAnalyze this code for security vulnerabilities.\n\nThink step by step:\n1. Identify all user inputs\n2. Trace each input through the code\n3. Check if any input reaches a sensitive operation without sanitization\n4. For each vulnerability found, classify severity (critical\u002Fhigh\u002Fmedium\u002Flow)\n5. Suggest a fix for each vulnerability\n\nCode:\n{code}\n```\n\n### Self-Consistency (Multiple CoT paths)\n\n```python\nimport json\nfrom collections import Counter\n\nasync def self_consistent_answer(question: str, n_paths: int = 5) -> str:\n    answers = []\n    for _ in range(n_paths):\n        response = await llm.generate(\n            f\"Think step by step and answer: {question}\\n\\nFinal answer:\",\n            temperature=0.7,  # Higher temp for diversity\n        )\n        final = extract_final_answer(response)\n        answers.append(final)\n\n    # Majority vote\n    most_common = Counter(answers).most_common(1)[0][0]\n    return most_common\n```\n\n## Structured Output\n\n### JSON Mode with Schema\n\n```python\nfrom pydantic import BaseModel, Field\nfrom openai import OpenAI\n\nclass CodeReview(BaseModel):\n    issues: list[dict] = Field(description=\"List of issues found\")\n    severity: str = Field(description=\"Overall severity: low|medium|high|critical\")\n    summary: str = Field(description=\"One-line summary\")\n    suggestions: list[str] = Field(description=\"Improvement suggestions\")\n\nclient = OpenAI()\n\nresponse = client.beta.chat.completions.parse(\n    model=\"gpt-4o\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"Review code and output structured analysis.\"},\n        {\"role\": \"user\", \"content\": f\"Review this code:\\n```\\n{code}\\n```\"},\n    ],\n    response_format=CodeReview,\n)\n\nreview = response.choices[0].message.parsed\n```\n\n### XML Tags for Claude\n\n```\n\u003Ctask>Analyze the following error log and extract structured information.\u003C\u002Ftask>\n\n\u003Crules>\n- Extract timestamp, severity, service name, and error message\n- Classify root cause category\n- Output in the specified XML format\n\u003C\u002Frules>\n\n\u003Cinput>\n{error_log}\n\u003C\u002Finput>\n\n\u003Coutput_format>\n\u003Canalysis>\n  \u003Ctimestamp>ISO 8601\u003C\u002Ftimestamp>\n  \u003Cseverity>ERROR|WARN|FATAL\u003C\u002Fseverity>\n  \u003Cservice>service name\u003C\u002Fservice>\n  \u003Cmessage>error message\u003C\u002Fmessage>\n  \u003Croot_cause>category\u003C\u002Froot_cause>\n  \u003Csuggested_fix>actionable fix\u003C\u002Fsuggested_fix>\n\u003C\u002Fanalysis>\n\u003C\u002Foutput_format>\n```\n\n## Prompt Evaluation Framework\n\n```python\nclass PromptEvaluator:\n    def __init__(self, test_cases: list[dict]):\n        self.test_cases = test_cases  # [{\"input\": ..., \"expected\": ..., \"criteria\": ...}]\n\n    async def evaluate(self, prompt_template: str) -> dict:\n        results = []\n        for case in self.test_cases:\n            prompt = prompt_template.format(**case[\"input\"])\n            output = await llm.generate(prompt)\n            score = self._score(output, case[\"expected\"], case.get(\"criteria\", {}))\n            results.append({\"input\": case[\"input\"], \"output\": output, \"score\": score})\n\n        return {\n            \"avg_score\": sum(r[\"score\"] for r in results) \u002F len(results),\n            \"pass_rate\": sum(1 for r in results if r[\"score\"] >= 0.8) \u002F len(results),\n            \"failures\": [r for r in results if r[\"score\"] \u003C 0.8],\n        }\n\n    def _score(self, output: str, expected: str, criteria: dict) -> float:\n        scores = []\n        if \"contains\" in criteria:\n            scores.append(1.0 if criteria[\"contains\"] in output else 0.0)\n        if \"format\" in criteria:\n            scores.append(1.0 if self._check_format(output, criteria[\"format\"]) else 0.0)\n        if \"max_length\" in criteria:\n            scores.append(1.0 if len(output) \u003C= criteria[\"max_length\"] else 0.0)\n        return sum(scores) \u002F len(scores) if scores else 0.5\n```\n\n## Checklist\n\n- [ ] System prompt defines role, task, rules, and output format\n- [ ] Few-shot examples cover edge cases (not just happy path)\n- [ ] Chain-of-thought used for reasoning-heavy tasks\n- [ ] Structured output enforced via JSON mode or XML tags\n- [ ] Prompts tested with evaluation suite (10+ test cases)\n- [ ] Temperature set appropriately (0 for deterministic, 0.7+ for creative)\n- [ ] Prompt versioned and tracked alongside code\n- [ ] Negative examples included (\"Do NOT do X\")\n\n## Anti-Patterns\n\n- Vague instructions without concrete examples\n- Asking for multiple unrelated tasks in one prompt\n- Not specifying output format (getting unparseable responses)\n- Using temperature=0 for tasks needing diversity\n- Prompt injection vulnerable (no input sanitization)\n- Testing with only 1-2 examples (not statistically meaningful)\n- Hardcoding prompts in application code (not configurable)\n- Ignoring token limits (prompt + expected output exceeds context)\n",{"name":5,"description":7},"main","70e1c350500ee750987420bbae48837afa906b7e","skills\u002Fprompt-engineering","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis","https:\u002F\u002Fgithub.com\u002Frubicanjr","linktr.ee\u002Ffinanskodu","Industrial Engineer & CIO @FinansKodu. Architecting AI-driven financial agents and autonomous workflows. 🏗️ Building systems, not just prompts.","2026-06-09 13:50:15",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add rubicanjr\u002FFinCognis --skill prompt-engineering",{"tool":56,"command":57},"bunx","bunx skills add rubicanjr\u002FFinCognis --skill prompt-engineering",{"tool":59,"command":60},"pnpm","pnpm dlx skills add rubicanjr\u002FFinCognis --skill prompt-engineering","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fprompt-engineering\u002Fskill.md",true,[],[65,82,91,111,141,160],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":72,"publishedAt":37},"01M6NWS9DAXJTADT4T5MB49X8W","workflow-router","Goal-based workflow orchestration - routes tasks to specialist agents based on user goals","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow-router\u002FSKILL.md",[71],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[73,74,75,76,77,78,79,80,81],"workflow router","workflow","router","orchestration","goals","goal","user","workflow orchestration","tasks",{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":37},"01M6NWS3RETSC0SHP16HP66E14","wiring","Wiring Verification","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fwiring\u002FSKILL.md",[],[84,89,90],"verification","false",{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":100,"publishedAt":37},"01M6NWS0XW9CVQZBDA1EGW0TWC","websocket-patterns","Connection management, room patterns, reconnection strategies, message buffering, and binary protocol design.","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fwebsocket-patterns\u002Fskill.md",[97],{"categoryNo":98,"categoryName":99,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",[101,102,103,104,105,106,107,108,109,110],"websocket","patterns","websocket patterns","design","protocol","management","message","strategies","binary","connection",{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":121,"publishedAt":37},"01M6NWRDQDX9ZNETAWRRMQWV52","visual-verdict","Screenshot comparison QA for frontend development. Takes a screenshot of the current implementation, scores it across multiple visual dimensions, and returns a structured PASS\u002FREVISE\u002FFAIL verdict with concrete fixes. Use when implementing UI from a design reference or verifying visual correctness.","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fvisual-verdict\u002FSKILL.md",[117,120],{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[122,123,124,125,126,127,128,129,130,131,132,133,134,104,135,136,137,138,139,140],"visual","verdict","visual verdict","ui","across","revise","comparison","correctness","implementing","for","fixes","dimensions","frontend","development","qa","screenshot","returns","use","frontend development",{"skillNo":142,"name":143,"nameZh":6,"description":144,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":145,"categories":146,"keywords":147,"publishedAt":37},"01M6NWR8HSNRS7MNDK2J02QYMN","verification-loop","Comprehensive verification system covering build, types, lint, tests, security, and diff review before a PR.","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[148,149,89,150,151,152,153,154,155,156,157,158,159],"verification loop","loop","lint","review","security","pr","system","diff","build","tests","diff review","types",{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":164,"categories":165,"keywords":166,"publishedAt":37},"01M6NWR4HHSFR0VR5EXFRWA747","vector-db-patterns","Embedding strategies, ANN algorithms, hybrid search, RAG chunking strategies, and reranking for semantic search and retrieval.","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fvector-db-patterns\u002Fskill.md",[],[167,168,169,170,102,171,172,173,174,108,175,176,177,178,179,131,180,181],"vector db patterns","vector db","db","vector","semantic search","search","embedding strategies","algorithms","chunking","semantic","retrieval","embedding","Hybrid Search","hybrid","rag"]