[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6NW1WXF433QB992W2S6XETB":3,"skill-same:01M6NW1WXF433QB992W2S6XETB":59},{"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":18,"publishedAt":32,"linkOnly":33,"markdownContent":34,"markdownBody":35,"frontMatter":36,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":14,"repositoryHtmlUrl":40,"repositoryHomepageUrl":6,"ownerHtmlUrl":41,"ownerBlogUrl":42,"ownerDescription":43,"updatedAt":44,"install":45,"resources":58},"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",[],[19,20,21,22,23,24,25,26,27,28,29,30,31],"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":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add rubicanjr\u002FFinCognis --skill prompt-engineering",{"tool":51,"command":52},"bunx","bunx skills add rubicanjr\u002FFinCognis --skill prompt-engineering",{"tool":54,"command":55},"pnpm","pnpm dlx skills add rubicanjr\u002FFinCognis --skill prompt-engineering","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fprompt-engineering\u002Fskill.md",true,[],[60,76,85,102,128,147],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":32},"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",[],[67,68,69,70,71,72,73,74,75],"workflow router","workflow","router","orchestration","goals","goal","user","workflow orchestration","tasks",{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":32},"01M6NWS3RETSC0SHP16HP66E14","wiring","Wiring Verification","https:\u002F\u002Fgithub.com\u002Frubicanjr\u002FFinCognis\u002Fblob\u002Fmain\u002Fskills\u002Fwiring\u002FSKILL.md",[],[78,83,84],"verification","false",{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":32},"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",[],[92,93,94,95,96,97,98,99,100,101],"websocket","patterns","websocket patterns","design","protocol","management","message","strategies","binary","connection",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":32},"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",[],[109,110,111,112,113,114,115,116,117,118,119,120,121,95,122,123,124,125,126,127],"visual","verdict","visual verdict","ui","across","revise","comparison","correctness","implementing","for","fixes","dimensions","frontend","development","qa","screenshot","returns","use","frontend development",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":32},"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",[],[135,136,83,137,138,139,140,141,142,143,144,145,146],"verification loop","loop","lint","review","security","pr","system","diff","build","tests","diff review","types",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":32},"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",[],[154,155,156,157,93,158,159,160,161,99,162,163,164,165,166,118,167,168],"vector db patterns","vector db","db","vector","semantic search","search","embedding strategies","algorithms","chunking","semantic","retrieval","embedding","Hybrid Search","hybrid","rag"]