WeChat Mini Program Collaboration Rules
Source: The generic specification part of the 'Parent-Child Growth Diary' construction kit
AGENTS.md, stripped of the project-specific MVP scope / document index, becoming a reusable collaboration baseline.
What Is This
AI code writing can easily become 'out of control': unauthorized refactoring, hardcoded keys, skipping phases. This skill gives the AI a set of mandatory rules at the start of each new conversation to preemptively block such pitfalls; it can also generate a project-level AGENTS.md that the AI must read before starting work each time. It can also scan an existing project for violations using --check.
The script includes --self-test: after generating the rules, it reads them back and verifies that the '5 Principles + Security Boundaries' are all present, proving usability.
When to Use
- User says: 'Start WeChat Mini Program development' / 'Help me set up AI collaboration rules' / 'Set work rules for AI'
- Starting any new project needing AI-assisted coding and wanting to solidify collaboration rules
- Wanting to generate an
AGENTS.mdfile to place in the project root - Wanting to check if an existing project crosses security red lines (hardcoded keys /
.envin repo)
Mandatory Rules (AI Must Follow)
1. Security First
- Prohibit plaintext passwords, tokens, API keys in code / logs / commit records
- Sensitive info allowed only in config files or environment variables, and never display specific values in conversation
- Irreversible operations (deletion, reset, overwrite) must be confirmed with the user first
2. Stability Priority
- Prefer small, verifiable changes; avoid large-scale refactoring
- Explain the scope of impact before modification, and verification results after modification
- Do not break already-working functionality
3. Communication Rules
- Communicate throughout in Simplified Chinese
- Do not actively show code details unless the user requests
- Each completion report: what was done / why / what change the user will notice
4. Minimal Change Principle
- Only modify code directly related to the current task
- Do not refactor / optimize / add features on the side
- Report any extra findings first and let the user decide
5. Reference Sync Mandatory Rule (P0, same level as Security)
- Whenever changes involve file additions/deletions/renames, module/function/interface path changes, immediately globally search for old names and update all references
- At daily close-out, re-check that all such changes from the day have been synchronized
Security Boundaries (Highest Priority, No Role May Violate)
- [Prohibited] Cannot directly delete files — must list paths and wait for user confirmation before deletion
- [Prohibited] Cannot modify
.envand other config files — sensitive config is off-limits for automatic changes - [Prohibited] Cannot write plaintext passwords / keys in code — security red line; must point out and refuse if found
- [Prohibited] Cannot auto-commit Git — must show commit message and wait for confirmation before committing
- [Prohibited] Payment-related changes — must be fully tested; production direct testing is not allowed
- [Prohibited] Personal information protection — user data must not be stored in plaintext; comply with privacy regulations
Code Quality / Sensitive Info / Progress Management (General Conventions)
- Documentation language: Chinese; error handling retains full logs, do not silently swallow exceptions
.envcontent must never be sent to AI; secrets stored only in.env; when discussing config, only mention field names- Each close-out updates
progress.md(what was done today / plan for tomorrow / pending decisions); new conversations first readprogress.mdand recap status
Subpackage Independent Development Enhancement (Practical Practice from Teaching Aid Tool Modules)
The following are enhancements fed back from the real collaboration rules of the 'Teaching Aid Tool' mini-program tool modules, layered on top of the baseline above, specifically designed to control subpackage/multi-section/Canvas type projects.
1. Naming Isolation Hard Rule (Dual-Section / Multi-Subpackage Scenario)
- Physical + Naming Double Isolation: After copying an independent subpackage from the source directory, add a uniform prefix (e.g.,
zt-/ZT_) to all identifiers; do not modify the source files. - Identifier Mapping: Global constant
ZT_, variablezt, top-level functionsztXxx, HTML idztXxx, localStorage keyzitie_. - Non-affected Items: Canvas internal dimensions, A4 specs, color maps, drawing engine core logic (generic, no prefix needed).
- AI Self-Check: Which section/subpackage am I currently working on? Did I accidentally use names, files, variables, or functions from another section?
2. Six Template P0 Lock (Highest Priority)
- Approved core templates (e.g., 6 assignment paper templates) any modification must first obtain explicit user consent; violators will be immediately rolled back.
- Lock Scope: Template preview master files, school/institution version element config JSON, grid parameter config, related JS/CSS/HTML, page number detection and generation logic.
- Prohibited: Add/delete/modify elements, adjust style parameters (position/color/font/size), modify page number/drawing/switching logic, add or remove features — unless explicitly authorized by the user ('you can change' / 'confirmed').
3. Three-Layer Documentation Traceability (Close-Out Summary Mandatory)
- At each close-out, ask: Are today's code changes reflected in the 'Product Specification Document' and 'Technical Solution Document'? If missing, update immediately.
- Document Authority Level: When multiple documents conflict, defer to the authoritative document; do not make silent decisions after resolving conflicts; report any contradictions to the user immediately.
- Document Non-Change Principle: Only the established document set is allowed; the AI is prohibited from automatically creating additional documents (temporary information should be written into the corresponding sections).
4. Canvas Specific Constraints (WeChat Mini Program Canvas Development)
- Pre-Development Checks: Internal dimensions fixed at
1240×1754(A4 150dpi); CSS scaling usescanvas.style.width/height, notcanvas.width/height; drawing functions must be directly copy-pasteable betweenpreview.htmland the mini program.js. - Common Pitfalls: Blurry text → first
ctx.font='48px serif'andcanvas.width=cssW*dpr; non-straight lines → evenlineWidth+ integer coordinates; blank export → setcanvas.width/heightbefore drawing; text offset → manuallyctx.textBaseline='middle'. - Drawing Order (Non-negotiable): Background → Header → Grid → Text (topmost layer) → Export.
- Missing Fonts: Use system fallback
serifto continue development, don't stall progress; replace with specified font when available.
Script Usage
# 0) First verify the generated rules are complete (recommended to run once before first use)
python gen_agents.py --self-test
# 1) Generate a project-level AGENTS.md
python gen_agents.py \
--project "Parent-Child Growth Diary" \
--type "WeChat Mini Program" \
--role partner \
--out AGENTS.md
# 2) Check existing project for violations (hardcoded keys / .env in repo / AGENTS coverage)
python gen_agents.py --check <project directory>
The script renders the above general rules + your project info into a standard AGENTS.md, ready to be placed in the project root for the AI to read each time.
Notes
- This skill provides a generic baseline. Project-specific MVP scope, API list, document index should be placed in separate
How AI Should Do.md/AI Development Path.mdfiles, not in AGENTS.md (to avoid contaminating rules with requirements). - The tech stack defaults to WeChat Mini Program + FastAPI + database conventions; update the 'Tech Stack Specific Conventions' section when changing stacks.
- Even with good rules, human oversight is needed — pair with the
ai-work-acceptanceskill for inspection after each delivery.