When to Trigger
User scenarios:
- Provides birth time ("I am male, born 2000-01-01 at noon 12:00") and wants an analysis
- Asks "read my BaZi / read my Zi Wei / tell my fortune / read my natal chart / read annual fortune and major periods"
- Provides natal 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 period/annual fortune
Do not trigger: pure astrology / tarot / Duke of Zhou dream interpretation / feng shui / name study.
Required Input
公历或农历日期 (YYYY-MM-DD)
出生时刻 (HH:MM, 24 小时制)
性别 (男/女)
If the user does not provide the hour,you must proactively ask, do not default to the zi hour. The hour has an enormous impact on the day pillar of the Four Pillars and the Zi Wei life palace.
Birthplace is not needed. Chart calculation directly uses clock time, with no true solar time longitude correction.
Execution Flow
Step 0 — Decision Gate (mandatory at the start, no exceptions) ⭐
This step cannot be skipped, and you cannot judge the intent on your own based on the user's wording and then execute directly. Even if the user says something like "generate a report for a XXX male's fate" or "show me XXX's natal chart" that sounds like a specific deliverable is already being specified, you must first finish asking the questions below and wait for the user's clear reply before entering Step 1.
❌ Wrong example: the user says "generate a 1990 male fate", and the Agent directly defaults to the comprehensive corroboration + poster mode and starts calculating the chart. ✅ Correct approach: no matter how the user asks, first reply with Question 1 (which type of analysis), and only after the user chooses 3 reply with Question 2 (which presentation form), and only after getting a clear answer start working.
Question 1: Which type of fortune-telling do you want?
"I can do three types of analysis:
- Independent BaZi analysis(career / wealth / marriage and romance / children / six relations / health, deduced according to BaZi structure — long-form output)
- Independent Zi Wei analysis(twelve palaces + major limits + birth-year four transformations + annual fortune — long-form output)
- BaZi + Zi Wei comprehensive corroboration(cross-checking the two charts — provides long-form / visualized poster / both)"
If the user chooses 3, then ask Question 2: presentation form
"Comprehensive corroboration can be output like this: A. 📜 Long-form in-depth version(Markdown prose, immersive reading) B. 🎴 Structured poster version(single-file HTML, can be screenshotted and shared) C. Both"
Load the corresponding prompts and templates according to the choice:
| User chooses | 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 corroboration type. BaZi standalone / Zi Wei standalone only output long-form text (for users' in-depth reading). This is by design—the poster is the exclusive killer feature of comprehensive corroboration, taking on the role of social sharing + user wow factor.
Step 1 — Chart Calculation (algorithm layer, produces JSON)
Absolutely never let the AI calculate BaZi or Zi Wei on its own. Must call the algorithm layer script:
cd calculator
npx tsx run-chart.ts --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, only take stdout(> chart.json), do not 2>&1。
Script output JSON:
bazi: Four Pillars / Ten Gods / Star Luck / Self-Seat / Na Yin / Hidden Stems / Major Luck (including startAge/endAge/startYear/endYear)bazi.enrichment: Pattern / Prosperity-Decline / Temperature Adjustment / Five Elements Prosperity-Phase / Five Elements Statistics / Heavenly Stems Relationships / Earthly Branches Relationships / Whole Pillar Determinationziwei: Twelve Palaces / Birth Year Four Transformations / Major Limits / Yin-Yang / Five Elements Bureau / Life Master and Body Master
Key Constraint: Pure LLM chart calculation will misplace the day pillar → day master → pattern → useful god, causing the entire chain to be distorted. 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 Wenmo Tianji-style tree text:
npx tsx dump-text.ts --input=chart.json --output=chart.txt
The text chart includes:
- Zi Wei portion: basic information + birth year four transformations + twelve palaces (including main stars / auxiliary stars / major limits / annual fortunes)
- BaZi portion: four pillars (including hidden stems ten gods / star luck / self-seat / na yin) + major luck + algorithm supplementary layer (pattern / prosperity-decline / temperature adjustment / relationships / whole pillar)
Send the chart.txt content 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 chose 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 corroboration (3+A): first run BaZi + Zi Wei standalone analysis to obtain intermediate reports, then feed to
zonghe-yinzheng-prompt.md. If the output is truncated, output in segments.
Step 3 — Poster Version (only if user chose 3+B or 3+C)
- Read
prompts/zonghe-poster.md, feed inchart.txt - LLM Must output strict JSON(not Markdown)—the end of the prompt will require "directly start with
{", just follow it - Save the JSON output by the LLM as
analysis.json - Call the rendering script:
cd calculator npx tsx render.ts \ --chart=chart.json \ --analysis=analysis.json \ --template=../templates/report-zonghe-poster.html \ --output=<user-name>-<date>.html \ --currentYear=<YYYY> - Tell the user the path of the generated HTML file and have them open it in 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 must 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 example charts, do not analyze example life masters. Once installed, it is installed; wait for the user to provide a birth date and time before starting work.
Self-check commands are run manually as needed and are not within the Agent's scope of responsibility. If the Agent proactively runs them, it wastes tokens and triggers context compression.
Dependency Check (only when the user provides a birth date and time for the first time and the Agent is about to run run-chart.ts and encounters an error):
cd <skill-root>/calculator
ls node_modules >/dev/null 2>&1 || npm install
In other words, dependency issuesare fixed only when an error occurs, do not proactively check after installation.
Key Constraints
- No self-check after installation: see the previous section "Post-Installation Behavior". Do not proactively run example chart casting / self-check / smoke test
- Decision gate is mandatory, wording cannot be used as an excuse: always first ask the user which type of analysis they want, even if the user says "generate one / give me a copy" or similar phrasing that sounds like the output has already been specified, you cannot skip it and go directly to the poster mode by default. Avoid meaningless token consumption + output truncation
- Chart casting must go through the algorithm layer: do not calculate the Four Pillars, Zi Wei palace positions, or major limits by hand. One wrong step and the whole chart collapses
- Do not introduce variables outside the birth chart: feng shui, names, yang dwelling, purple-white flying stars are not within the scope of this Skill
- Conflicts must be stated: when Bazi and Zi Wei show contradictory signals, judge according to the 4 rules of the comprehensive verification prompt, do not fudge it
- Confidence self-assessment: boundary cases (critical strength/weakness, ambiguous pattern, two charts in opposition) must be marked "Confidence: Low"
- Do not make decisions for the user: for decision-type questions such as investment, partner selection, medical treatment, abortion, etc., give signals not instructions
- Refuse sensitive questions: directly refuse prohibited content such as casting curses, cutting off someone's source of wealth, harming someone's fate, etc.
- 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 ← 算法层依赖声明
│ ├── engine/ ← 排盘引擎:对接 mingpan(八字,Apache-2.0) + iztro(紫微,MIT)
│ └── bazi-enrich/ ← enrichBazi 补层(格局/旺衰/调候/关系/整柱)
├── prompts/
│ ├── bazi-prompt.md ← 八字独立分析(长文)
│ ├── ziwei-prompt.md ← 紫微独立分析(长文)
│ ├── zonghe-yinzheng-prompt.md ← ⭐ 综合印证(长文)
│ └── zonghe-poster.md ← ⭐ 综合印证(海报版 JSON 输出)
└── templates/
├── report-zonghe-poster.html ← 综合印证海报模板(占位符)
├── UI-DESIGN.md ← 视觉设计文档
└── OUTPUT-SCHEMA.md ← 输出结构规范
Note: HTML rendering currentlyonly supports comprehensive verification mode. If the user chose Bazi standalone / Zi Wei standalone and also asks "can you produce an HTML report", tell them "currently the HTML poster is only open for comprehensive verification, it is recommended to choose comprehensive verification (including Bazi + Zi Wei) to get the poster".
Worked Example
User: I am a male born on January 1, 2000 at 12:00, help me look at my birth chart.
The Skill should follow:
- Information confirmation (date/hour/gender ✅)
- Decision gate: "Do you want Bazi analysis / Zi Wei analysis / comprehensive verification?"
- User replies "Bazi":
- Step 1: run
run-chart.tsto producechart.json - Step 2: run
dump-text.tsto producechart.txt - Step 3a: load
prompts/bazi-prompt.md+ feed inchart.txt→ output Bazi analysis
- Step 1: run
- Remind them "if you want Zi Wei / comprehensive verification you can ask anytime"
Failure Modes and Handling
| Symptom | Cause | Handling |
|---|---|---|
| Chart casting script reports an error | date outside 1900-2100 / hour format wrong | Ask the user to correct it |
| AI wants to "cast 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 in one go exceeds the token limit | Go back to the decision gate, split the output |
| The algorithm layer's results are inconsistent with the user's other software | naming/school differences (Jian Lu pattern vs Bi Jian pattern) | Explain according to the algorithm layer notes , do not substitute the wording |
| Windows + Chinese path + PowerShell encoding corruption | Platform features | Run under cmd / git bash / WSL; avoid PowerShell |
Open Source Acknowledgments
The chart calculation algorithm layer is based on the following independent open-source projects (all are real, verifiable LICENSE files, not badge claims):
Disclaimer (must be included at the end of every output)
This analysis is based on the traditional theoretical framework of Bazi and Zi Wei Dou Shu, and is for cultural research and entertainment reference only. It does not constitute any basis for decision-making in medicine, investment, marriage, law, etc. Destiny is shaped jointly by personal choices and the objective environment.