SuperAPI AI Directory

bazi-ziwei

Agents & models

View repository

Updated 10-15 21:36

About this skill

Bazi + Zi Wei Dou Shu Comprehensive Analysis Skill

When to trigger

User scenarios:

  • Provides birth time ("I am 2000-01-01 noon 12:00 male") and wants analysis
  • Asks "help me read my Bazi / read my Zi Wei / fortune telling / read my natal chart / read annual luck and major fortune periods"
  • Provides chart text (Wenmo Tianji, Zi Wei Dou Shu charting software export format) and wants in-depth interpretation
  • Asks about the fortune or misfortune of a specific major fortune period/annual luck

Do not trigger: purely astrology / tarot / Duke of Zhou dream interpretation / feng shui / nameology.

Required input

公历或农历日期 (YYYY-MM-DD)
出生时刻 (HH:MM, 24 小时制)
性别 (男/女)

If the user has not given the hour,you must proactively ask, do not default to the zi hour. The hour has a huge impact on the Four Pillars' day pillar and the Zi Wei life palace.

Place of birth is not needed. Chart casting directly uses clock time, without true solar time longitude correction.


Execution flow

Step 0 — Decision gate (must do at the start) ⭐

Question 1: Which kind of fate analysis do you want?

"I can do three kinds of analysis:

  1. Independent Bazi analysis(career / wealth / marriage / children / six relations / health, deduced according to Bazi structure — long-form output)
  2. Independent Zi Wei analysis(twelve palaces + major limits + birth-year four transformations + annual luck — long-form output)
  3. Bazi + Zi Wei comprehensive verification(cross-checking the two charts — provide long-form / visual poster / both)"

If the user chooses 3, then ask Question 2: presentation form

"Comprehensive verification can be output like this: A. 📜 Long-form in-depth version(Markdown prose, immersive reading) B. 🎴 Structured poster version(single-file HTML, screenshot-shareable) C. Both"

Load the corresponding prompt and template according to the choice:

User choice Load prompt Template Output
1 prompts/bazi-prompt.md — Markdown conversation reply
2 prompts/ziwei-prompt.md — Markdown conversation reply
3 + A prompts/zonghe-yinzheng-prompt.md — Markdown conversation reply
3 + B prompts/zonghe-poster.md templates/report-zonghe-poster.html <name>-zonghe.html
3 + C Run both of the above Same as above Two copies: Markdown + HTML

The poster template is only for the comprehensive verification type. Independent Bazi / independent Zi Wei only have long-form output (for the user's in-depth reading). This is by design — the poster is the killer feature exclusive to comprehensive verification, taking on the role of social sharing + impressing the user.


Step 1 — Chart casting (algorithm layer, produces JSON)

Absolutely do not let the AI cast the Bazi or Zi Wei chart itself. You must call the algorithm-layer script:

cd calculator
node dist/run-chart.js --year=YYYY --month=MM --day=DD --hour=HH --minute=MM --gender=male > chart.json

Note:run-chart.ts 's stdout is pure JSON, stderr is debug information.When redirecting, take only stdout(> chart.json), do not 2>&1。

Script outputs JSON:

  • bazi: Four Pillars / Ten Gods / Star Luck / Self-Seat / Nayin / Hidden Stems / Major Fortune (including startAge/endAge/startYear/endYear)
  • bazi.enrichment: Pattern / Prosperity-Decline / Climate Adjustment / Five Elements Prosperity-Phase / Five Elements Statistics / Heavenly Stems Relationship / Earthly Branches Relationship / Whole Pillar Judgment
  • ziwei: Twelve Palaces / Birth Year Four Transformations / Major Limits / Yin-Yang / Five Elements Bureau / Life Lord Body Lord

Key Constraints: A pure LLM chart calculation will misplace the Day Pillar → Day Master → Pattern → Useful God, distorting the entire chain. The Case B test proves that DeepSeek/Gemini both make errors when calculating charts on their own. The algorithm layer cannot be bypassed.


Step 2 — Text Chart Conversion (algorithm layer, produces readable text)

An LLM reads JSON less well than it reads structured text. Convert the JSON from Step 1 into a tree-style text in the style of Wenmo Tianji:

node dist/dump-text.js --input=chart.json --output=chart.txt

The text chart includes:

  • Ziwei part: basic information + birth year four transformations + twelve palaces (including main stars / auxiliary stars / major limits / annual fortune)
  • Bazi part: four pillars (including hidden stems ten gods / star luck / self-seat / nayin) + major luck + algorithm supplementary layer (pattern / prosperity-decline / climate adjustment / relationships / whole pillar)

Send the content of chart.txt together with the corresponding prompt to the LLM for analysis.


Step 3 — Analysis (execute the corresponding branch according to the user's choice in Step 0)

Step 3 — Long-form version (user selects 1 / 2 / 3+A / 3+C)

Read the corresponding long-form prompt (bazi-prompt.md / ziwei-prompt.md / zonghe-yinzheng-prompt.md), feed in chart.txt, output a Markdown long-form text.

Prerequisite for comprehensive verification (3+A): first run the Bazi + Ziwei independent analyses to get interim reports, then feed them to zonghe-yinzheng-prompt.md. If the output is truncated, output it in segments.

Step 3 — Poster version (only when the user selects 3+B or 3+C)

  1. Read prompts/zonghe-poster.md, feed in chart.txt
  2. LLM must output strict JSON(not Markdown) — the end of the prompt will require "start directly with { ", just follow it
  3. Save the JSON output by the LLM as analysis.json
  4. Call the rendering script:
    cd calculator
    node dist/render.js \
      --chart=chart.json \
      --analysis=analysis.json \
      --template=../templates/report-zonghe-poster.html \
      --output=<user-name>-<date>.html \
      --currentYear=<YYYY>
    
  5. Tell the user the path of the generated HTML file and have them open it with a browser

Important: The poster version's visuals are determined by the HTML template,the LLM only produces data, not HTML. If the LLM output contains markdown wrapping (such as ```json … ```), it needs to be stripped before rendering.


Post-installation behavior (important)

After the Skill is installed, do not proactively run any verification / self-check commands. Do not try Smoke Test, do not calculate sample charts, do not analyze sample life subjects. Installed is installed, wait for the user to provide a birth date before starting work.

Self-check commands are run manually on demand in TEST-GUIDE.md , and are not within the Agent's scope of responsibility. If the Agent proactively runs them, it wastes tokens + triggers context compression.

Dependency check (only when the user provides a birth date for the first time and the Agent is about to run run-chart.ts and it reports an error):

cd <skill-root>/calculator
ls node_modules >/dev/null 2>&1 || npm install

In other words, dependency issuesshould be fixed only when an error occurs, do not proactively check right after installation.


Key Constraints

  1. Do not self-check after installation: see the "Post-installation behavior" section above. Do not proactively run sample chart calculations / self-checks / smoke tests
  2. Decision gate is mandatory: always first ask the user which type of analysis they want, to avoid meaningless token consumption + output truncation
  3. Chart calculation must go through the algorithm layer: do not calculate the four pillars, Ziwei palace positions, or major limits by hand. One wrong step and the whole chart collapses
  4. Do not introduce variables outside the chart: feng shui, names, yang dwelling, and purple-white flying stars are not within the scope of this Skill
  5. Conflicts must be stated: When BaZi and ZiWei give contradictory signals, judge according to the 4 rules in the comprehensive verification prompt; do not fudge
  6. Confidence self-assessment: Boundary cases (prosperity/decline threshold, ambiguous structure, opposing charts) must be marked "Confidence: Low"
  7. Do not make decisions for the user: For decision-type questions such as investment, partner selection, medical care, abortion, etc., give signals not instructions
  8. Refuse sensitive questions: Directly refuse prohibited content such as casting curses, cutting off people's finances, harming others' fate, etc.
  9. Disclaimer: The end of the analysis must include "For cultural research and entertainment reference only"

File list


├── SKILL.md                          ← 本文件
├── calculator/
│   ├── run-chart.ts                  ← 入口:生辰 → JSON(stdout 纯 JSON / stderr debug)
│   ├── dump-text.ts                  ← JSON → 文墨天机风文本
│   ├── render.ts                     ← 渲染脚本:chart.json + analysis.json + 模板 → HTML
│   ├── package.json                  ← 算法层依赖声明
│   ├── yiqi-core/                    ← Yiqi 算法(已 vendored 入库,无外部依赖)
│   └── bazi-enrich/                  ← enrichBazi 补层(格局/旺衰/调候/关系/整柱)
├── prompts/
│   ├── bazi-prompt.md                ← 八字独立分析(长文)
│   ├── ziwei-prompt.md               ← 紫微独立分析(长文)
│   ├── zonghe-yinzheng-prompt.md     ← ⭐ 综合印证(长文)
│   └── zonghe-poster.md              ← ⭐ 综合印证(海报版 JSON 输出)
├── templates/
│   └── report-zonghe-poster.html     ← 综合印证海报模板(占位符)
└── fixtures/                         ← 7 个验证案例(Case A-G)

Note: HTML rendering currentlyonly supports comprehensive verification mode. If the user selected BaZi standalone / ZiWei standalone and then asks "can you produce an HTML report", tell them "Currently HTML posters are only available for comprehensive verification; it is recommended to choose comprehensive verification (including BaZi + ZiWei) to get the poster".


Worked example

User: I am a male born on January 1, 2000 at 12:00; please take a look at my natal chart.

The Skill should follow:

  1. Information confirmation (date/hour/gender ✅)
  2. Decision gate: "Do you want BaZi analysis / ZiWei analysis / comprehensive verification?"
  3. User replies "BaZi":
    • Step 1: Run run-chart.ts to produce chart.json
    • Step 2: Run dump-text.ts to produce chart.txt
    • Step 3a: Load prompts/bazi-prompt.md + feed in chart.txt → output BaZi analysis
  4. Remind them "if you want ZiWei / comprehensive verification, you can ask anytime"

Failure modes and handling

Symptom Cause Handling
Chart calculation script errors Date outside 1900-2100 / incorrect hour format Ask the user to correct it
AI wants to "calculate the chart from memory" Taking a lazy shortcut Refuse. The algorithm layer is a hard constraint that cannot be bypassed
Output is truncated Three sections output all at once exceeds the token limit Return to the decision gate and split the output
Algorithm layer and the user's other software results are inconsistent Naming school differences (JianLu structure vs BiJian structure) According to the algorithm layer notes explanation, do not substitute wording
Windows + Chinese path + PowerShell encoding corruption Platform characteristic Run under cmd / git bash / WSL, avoid PowerShell

Disclaimer (must be included at the end of every output)

This analysis is based on the traditional BaZi and ZiWei DouShu theoretical frameworks, and is for cultural research and entertainment reference only. It does not constitute any basis for decision-making in medicine, investment, marriage, law, etc. Fate is shaped jointly by personal choices and the objective environment.