[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71SC615BQ4SFYFWSF8DRK1B":3,"skill-same:01M71SC615BQ4SFYFWSF8DRK1B":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":43,"repositoryHtmlUrl":44,"repositoryHomepageUrl":45,"ownerHtmlUrl":46,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":47,"install":48,"resources":61},"01M71SC615BQ4SFYFWSF8DRK1B","bayes",null,"Build and query Bayesian networks as a structured reasoning tool. Use when the task involves thinking over multiple related variables, diagnosis under uncertainty, or updating beliefs as new evidence arrives.","miketung\u002Fbayes","miketung","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F622398?v=4","01M71SC3K6VW9VCQJVMG6505XN","01M71SC3KZJB29A1DZA621CCYN",6,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmiketung\u002Fbayes\u002Fblob\u002Fmain\u002Fskill\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"when","structured","reasoning","diagnosis","build","task","Variables","query","Bayesian","use","uncertainty","new","tool","networks","evidence","thinking","as","2026-11-10 13:02:02",false,"---\nname: bayes\ndescription: Build and query Bayesian networks as a structured reasoning tool. Use when the task involves thinking over multiple related variables, diagnosis under uncertainty, or updating beliefs as new evidence arrives.\n---\n\n# bayes — Bayesian networks as a reasoning tool\n\nYou have access to the `bayes` CLI (run as `node \u003Crepo>\u002Fcli\u002Fbayes.js`).\nIt builds discrete Bayesian networks, runs exact or approximate inference,\nand can persist networks as JSON files on disk.\n\nUse this when modelling probabilistic relationships between multiple variables\n— especially when you need to reason about uncertainty, update beliefs given\nevidence, or compare hypotheses that share latent causes.\n\nIf the task is a single-variable prior or a calculation that doesn't benefit\nfrom structure, just do the math directly — don't force a network.\n\n## Grounding priors\n\nIf the CPTs depend on real-world rates — prevalence, prices, base rates,\nhistorical frequencies — web-search them before filling numbers and cite\nthe source next to each value in your response. Skip this when the network is illustrative,\nthe numbers come from the user or problem statement, or it's a toy example.\nIf the harness has no web search, flag estimates as such and widen the\ndistributions to reflect the added uncertainty.\n\n## Two workflows\n\n### One-shot: build the JSON, query inline\n\nWhen you know the full structure up front, construct the network JSON and pass\nit directly via `--net`. Set evidence with `--evidence` flags. One bash call,\nno file needed.\n\n```\nbayes query --net '{\n  \"version\": 1, \"name\": \"Whodunit\",\n  \"nodes\": [\n    { \"id\": \"culprit\", \"states\": [\"scarlett\",\"plum\",\"mustard\",\"green\"], \"parents\": [],\n      \"cpt\": [0.30, 0.20, 0.30, 0.20] },\n    { \"id\": \"weapon_found\", \"states\": [\"knife\",\"rope\",\"wrench\",\"revolver\"], \"parents\": [\"culprit\"],\n      \"cpt\": [0.40,0.20,0.10,0.30, 0.10,0.20,0.50,0.20, 0.10,0.10,0.20,0.60, 0.20,0.40,0.30,0.10] },\n    { \"id\": \"time_of_death\", \"states\": [\"6pm-8pm\",\"8pm-10pm\",\"10pm-12am\",\"after_12am\"], \"parents\": [\"culprit\"],\n      \"cpt\": [0.10,0.20,0.40,0.30, 0.20,0.30,0.30,0.20, 0.40,0.40,0.15,0.05, 0.30,0.40,0.20,0.10] },\n    { \"id\": \"fingerprint_match\", \"states\": [\"no\",\"yes\"], \"parents\": [\"culprit\"],\n      \"cpt\": [0.70,0.30, 0.40,0.60, 0.50,0.50, 0.20,0.80] }\n  ]\n}' --id culprit --evidence weapon_found=wrench --evidence time_of_death=10pm-12am --evidence fingerprint_match=yes\n```\n\nThe output variable (`culprit`) has named entities as states — that's the\ndefault whenever the question asks \"which one?\". The other nodes demonstrate\nthe two remaining common kinds: numeric ranges (`time_of_death`) and binary\n(`fingerprint_match`). Single-quote evidence values that contain shell\nmetacharacters like `\u003C`, `>`, or `≥`.\n\nResult: `{ \"marginal\": { \"scarlett\": 0.101, \"plum\": 0.504, \"mustard\": 0.126, \"green\": 0.269 }, ... }`\n\nUse `--format text` for human-readable output. Use `list` instead of `query`\nto see all marginals at once.\n\n### Iterative: build on disk, update as you learn\n\nWhen the model evolves over the conversation — start simple, query, add\nvariables, re-query — use mutation commands on a file.\n\n```\nbayes new \u002Ftmp\u002Fwhodunit.json --name \"Whodunit\"\n\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id culprit           --states scarlett,plum,mustard,green\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id weapon_found      --states knife,rope,wrench,revolver --parents culprit\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id time_of_death     --states '6pm-8pm,8pm-10pm,10pm-12am,after_12am' --parents culprit\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id fingerprint_match --states no,yes --parents culprit\n\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id culprit           --probs 0.30,0.20,0.30,0.20\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id weapon_found      --probs 0.40,0.20,0.10,0.30, 0.10,0.20,0.50,0.20, 0.10,0.10,0.20,0.60, 0.20,0.40,0.30,0.10\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id time_of_death     --probs 0.10,0.20,0.40,0.30, 0.20,0.30,0.30,0.20, 0.40,0.40,0.15,0.05, 0.30,0.40,0.20,0.10\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id fingerprint_match --probs 0.70,0.30, 0.40,0.60, 0.50,0.50, 0.20,0.80\n\nbayes query \u002Ftmp\u002Fwhodunit.json --id culprit --evidence weapon_found=wrench --evidence time_of_death=10pm-12am --evidence fingerprint_match=yes --format text\n# → plum ~50%, green ~27%, mustard ~13%, scarlett ~10%\n\n# `list` shows all marginals at once — useful for sanity-checking priors:\nbayes list \u002Ftmp\u002Fwhodunit.json --format text\n\n# Later: a strong motive surfaces — add it as a new node\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id motive_strength --states none,weak,strong --parents culprit\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id motive_strength --probs 0.20,0.30,0.50, 0.50,0.30,0.20, 0.40,0.40,0.20, 0.20,0.30,0.50\n\n# Re-query — Green (strong-motive profile) overtakes Plum (weak-motive profile)\nbayes query \u002Ftmp\u002Fwhodunit.json --id culprit --evidence weapon_found=wrench --evidence time_of_death=10pm-12am --evidence fingerprint_match=yes --evidence motive_strength=strong --format text\n# → green ~43%, plum ~32%, scarlett ~16%, mustard ~8%\n```\n\nYou can also write the JSON file directly (with the Write tool) and use the\nCLI only for queries — the parser validates structure on load.\n\n## CPT layout\n\nFor a node with parents `[P1, ..., Pk]` (cardinalities `[c1, ..., ck]`) and\n`m` own states, the CPT is a flat array of length `c1 * c2 * ... * ck * m`.\n\nEach row of `m` values is a distribution summing to 1. Rows iterate parent\ncombinations with **P1 most significant**, Pk least significant.\n\nExample: `X` with states `[no, yes]`, parents `[A, B]` each `[no, yes]`:\n\n```\nA=no,  B=no   → [P(X=no|...), P(X=yes|...)]\nA=no,  B=yes  → [P(X=no|...), P(X=yes|...)]\nA=yes, B=no   → [P(X=no|...), P(X=yes|...)]\nA=yes, B=yes  → [P(X=no|...), P(X=yes|...)]\n```\n\nPass `--normalize` on `set-cpt` to auto-normalize rows.\n\n## Command reference\n\n```\nInference\n  query \u003Cfile|--net JSON> --id ID [--evidence k=v ...] [--algorithm ve|lw] [--samples N]\n  list  \u003Cfile|--net JSON> [--evidence k=v ...] [--algorithm ve|lw] [--samples N]\n\nBuilding \u002F updating\n  new \u003Cfile> [--name NAME]\n  add-node \u003Cfile> --id ID --states a,b,c [--parents P1,P2]\n  remove-node \u003Cfile> --id ID\n  add-edge \u003Cfile> --from PARENT --to CHILD\n  remove-edge \u003Cfile> --from PARENT --to CHILD\n  set-cpt \u003Cfile> --id ID --probs p,p,... [--normalize]\n  set-evidence \u003Cfile> --id ID --state STATE\n  clear-evidence \u003Cfile> [--id ID]\n```\n\nAll commands accept `--format text` for human output. Mutation commands accept\n`--out FILE` to write to a different file. Pass `-` as `\u003Cfile>` to read from\nstdin.\n\n## JSON format\n\n```json\n{\n  \"version\": 1,\n  \"name\": \"My Network\",\n  \"nodes\": [\n    { \"id\": \"X\", \"states\": [\"no\", \"yes\"], \"parents\": [], \"cpt\": [0.9, 0.1] },\n    { \"id\": \"Y\", \"states\": [\"no\", \"yes\"], \"parents\": [\"X\"], \"cpt\": [0.7, 0.3, 0.2, 0.8] }\n  ],\n  \"evidence\": { \"X\": \"yes\" }\n}\n```\n\n## Inference algorithms\n\n- `ve` (default) — exact variable elimination. Use for networks up to a few\n  dozen nodes.\n- `lw` — likelihood weighting (approximate). Use when `ve` is slow or for\n  quick sample-based estimates. Pass `--samples N` (default 10000).\n\n## Guidance\n\n- **State the DAG before filling numbers.** Verify edges are causal\n  (parents cause children).\n- **Pick states at the granularity the question needs** — yes\u002Fno, named\n  categories (candidates, diagnoses), or bucketed ranges for quantities.\n- **Avoid 0 or 1 in CPTs** unless truly deterministic — zeros can make\n  evidence combinations impossible.\n- **Re-query after new evidence** to watch beliefs shift.\n- **Prefer `ve` for final answers**, `lw` for quick checks on large networks.\n","# bayes — Bayesian networks as a reasoning tool\n\nYou have access to the `bayes` CLI (run as `node \u003Crepo>\u002Fcli\u002Fbayes.js`).\nIt builds discrete Bayesian networks, runs exact or approximate inference,\nand can persist networks as JSON files on disk.\n\nUse this when modelling probabilistic relationships between multiple variables\n— especially when you need to reason about uncertainty, update beliefs given\nevidence, or compare hypotheses that share latent causes.\n\nIf the task is a single-variable prior or a calculation that doesn't benefit\nfrom structure, just do the math directly — don't force a network.\n\n## Grounding priors\n\nIf the CPTs depend on real-world rates — prevalence, prices, base rates,\nhistorical frequencies — web-search them before filling numbers and cite\nthe source next to each value in your response. Skip this when the network is illustrative,\nthe numbers come from the user or problem statement, or it's a toy example.\nIf the harness has no web search, flag estimates as such and widen the\ndistributions to reflect the added uncertainty.\n\n## Two workflows\n\n### One-shot: build the JSON, query inline\n\nWhen you know the full structure up front, construct the network JSON and pass\nit directly via `--net`. Set evidence with `--evidence` flags. One bash call,\nno file needed.\n\n```\nbayes query --net '{\n  \"version\": 1, \"name\": \"Whodunit\",\n  \"nodes\": [\n    { \"id\": \"culprit\", \"states\": [\"scarlett\",\"plum\",\"mustard\",\"green\"], \"parents\": [],\n      \"cpt\": [0.30, 0.20, 0.30, 0.20] },\n    { \"id\": \"weapon_found\", \"states\": [\"knife\",\"rope\",\"wrench\",\"revolver\"], \"parents\": [\"culprit\"],\n      \"cpt\": [0.40,0.20,0.10,0.30, 0.10,0.20,0.50,0.20, 0.10,0.10,0.20,0.60, 0.20,0.40,0.30,0.10] },\n    { \"id\": \"time_of_death\", \"states\": [\"6pm-8pm\",\"8pm-10pm\",\"10pm-12am\",\"after_12am\"], \"parents\": [\"culprit\"],\n      \"cpt\": [0.10,0.20,0.40,0.30, 0.20,0.30,0.30,0.20, 0.40,0.40,0.15,0.05, 0.30,0.40,0.20,0.10] },\n    { \"id\": \"fingerprint_match\", \"states\": [\"no\",\"yes\"], \"parents\": [\"culprit\"],\n      \"cpt\": [0.70,0.30, 0.40,0.60, 0.50,0.50, 0.20,0.80] }\n  ]\n}' --id culprit --evidence weapon_found=wrench --evidence time_of_death=10pm-12am --evidence fingerprint_match=yes\n```\n\nThe output variable (`culprit`) has named entities as states — that's the\ndefault whenever the question asks \"which one?\". The other nodes demonstrate\nthe two remaining common kinds: numeric ranges (`time_of_death`) and binary\n(`fingerprint_match`). Single-quote evidence values that contain shell\nmetacharacters like `\u003C`, `>`, or `≥`.\n\nResult: `{ \"marginal\": { \"scarlett\": 0.101, \"plum\": 0.504, \"mustard\": 0.126, \"green\": 0.269 }, ... }`\n\nUse `--format text` for human-readable output. Use `list` instead of `query`\nto see all marginals at once.\n\n### Iterative: build on disk, update as you learn\n\nWhen the model evolves over the conversation — start simple, query, add\nvariables, re-query — use mutation commands on a file.\n\n```\nbayes new \u002Ftmp\u002Fwhodunit.json --name \"Whodunit\"\n\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id culprit           --states scarlett,plum,mustard,green\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id weapon_found      --states knife,rope,wrench,revolver --parents culprit\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id time_of_death     --states '6pm-8pm,8pm-10pm,10pm-12am,after_12am' --parents culprit\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id fingerprint_match --states no,yes --parents culprit\n\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id culprit           --probs 0.30,0.20,0.30,0.20\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id weapon_found      --probs 0.40,0.20,0.10,0.30, 0.10,0.20,0.50,0.20, 0.10,0.10,0.20,0.60, 0.20,0.40,0.30,0.10\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id time_of_death     --probs 0.10,0.20,0.40,0.30, 0.20,0.30,0.30,0.20, 0.40,0.40,0.15,0.05, 0.30,0.40,0.20,0.10\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id fingerprint_match --probs 0.70,0.30, 0.40,0.60, 0.50,0.50, 0.20,0.80\n\nbayes query \u002Ftmp\u002Fwhodunit.json --id culprit --evidence weapon_found=wrench --evidence time_of_death=10pm-12am --evidence fingerprint_match=yes --format text\n# → plum ~50%, green ~27%, mustard ~13%, scarlett ~10%\n\n# `list` shows all marginals at once — useful for sanity-checking priors:\nbayes list \u002Ftmp\u002Fwhodunit.json --format text\n\n# Later: a strong motive surfaces — add it as a new node\nbayes add-node \u002Ftmp\u002Fwhodunit.json --id motive_strength --states none,weak,strong --parents culprit\nbayes set-cpt \u002Ftmp\u002Fwhodunit.json --id motive_strength --probs 0.20,0.30,0.50, 0.50,0.30,0.20, 0.40,0.40,0.20, 0.20,0.30,0.50\n\n# Re-query — Green (strong-motive profile) overtakes Plum (weak-motive profile)\nbayes query \u002Ftmp\u002Fwhodunit.json --id culprit --evidence weapon_found=wrench --evidence time_of_death=10pm-12am --evidence fingerprint_match=yes --evidence motive_strength=strong --format text\n# → green ~43%, plum ~32%, scarlett ~16%, mustard ~8%\n```\n\nYou can also write the JSON file directly (with the Write tool) and use the\nCLI only for queries — the parser validates structure on load.\n\n## CPT layout\n\nFor a node with parents `[P1, ..., Pk]` (cardinalities `[c1, ..., ck]`) and\n`m` own states, the CPT is a flat array of length `c1 * c2 * ... * ck * m`.\n\nEach row of `m` values is a distribution summing to 1. Rows iterate parent\ncombinations with **P1 most significant**, Pk least significant.\n\nExample: `X` with states `[no, yes]`, parents `[A, B]` each `[no, yes]`:\n\n```\nA=no,  B=no   → [P(X=no|...), P(X=yes|...)]\nA=no,  B=yes  → [P(X=no|...), P(X=yes|...)]\nA=yes, B=no   → [P(X=no|...), P(X=yes|...)]\nA=yes, B=yes  → [P(X=no|...), P(X=yes|...)]\n```\n\nPass `--normalize` on `set-cpt` to auto-normalize rows.\n\n## Command reference\n\n```\nInference\n  query \u003Cfile|--net JSON> --id ID [--evidence k=v ...] [--algorithm ve|lw] [--samples N]\n  list  \u003Cfile|--net JSON> [--evidence k=v ...] [--algorithm ve|lw] [--samples N]\n\nBuilding \u002F updating\n  new \u003Cfile> [--name NAME]\n  add-node \u003Cfile> --id ID --states a,b,c [--parents P1,P2]\n  remove-node \u003Cfile> --id ID\n  add-edge \u003Cfile> --from PARENT --to CHILD\n  remove-edge \u003Cfile> --from PARENT --to CHILD\n  set-cpt \u003Cfile> --id ID --probs p,p,... [--normalize]\n  set-evidence \u003Cfile> --id ID --state STATE\n  clear-evidence \u003Cfile> [--id ID]\n```\n\nAll commands accept `--format text` for human output. Mutation commands accept\n`--out FILE` to write to a different file. Pass `-` as `\u003Cfile>` to read from\nstdin.\n\n## JSON format\n\n```json\n{\n  \"version\": 1,\n  \"name\": \"My Network\",\n  \"nodes\": [\n    { \"id\": \"X\", \"states\": [\"no\", \"yes\"], \"parents\": [], \"cpt\": [0.9, 0.1] },\n    { \"id\": \"Y\", \"states\": [\"no\", \"yes\"], \"parents\": [\"X\"], \"cpt\": [0.7, 0.3, 0.2, 0.8] }\n  ],\n  \"evidence\": { \"X\": \"yes\" }\n}\n```\n\n## Inference algorithms\n\n- `ve` (default) — exact variable elimination. Use for networks up to a few\n  dozen nodes.\n- `lw` — likelihood weighting (approximate). Use when `ve` is slow or for\n  quick sample-based estimates. Pass `--samples N` (default 10000).\n\n## Guidance\n\n- **State the DAG before filling numbers.** Verify edges are causal\n  (parents cause children).\n- **Pick states at the granularity the question needs** — yes\u002Fno, named\n  categories (candidates, diagnoses), or bucketed ranges for quantities.\n- **Avoid 0 or 1 in CPTs** unless truly deterministic — zeros can make\n  evidence combinations impossible.\n- **Re-query after new evidence** to watch beliefs shift.\n- **Prefer `ve` for final answers**, `lw` for quick checks on large networks.\n",{"name":5,"description":7},"main","46906d55333be92a342df151e2c7582b67e380ee","skill",1,"https:\u002F\u002Fgithub.com\u002Fmiketung\u002Fbayes","https:\u002F\u002Fmiketung.com\u002Fbayes","https:\u002F\u002Fgithub.com\u002Fmiketung","2026-06-09 06:32:10",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":60},[50,53,56],{"tool":51,"command":52},"npx","npx skills add miketung\u002Fbayes --skill bayes",{"tool":54,"command":55},"bunx","bunx skills add miketung\u002Fbayes --skill bayes",{"tool":57,"command":58},"pnpm","pnpm dlx skills add miketung\u002Fbayes --skill bayes","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmiketung\u002Fbayes\u002Fblob\u002Fmain\u002Fskill\u002FSKILL.md",true,[],[63],{"skillNo":64,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":35},"01M71SC53SYZDQH36MKS3P3CV0","https:\u002F\u002Fgithub.com\u002Fmiketung\u002Fbayes\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fbayes\u002FSKILL.md",[],[5]]