Version: 1.1.1
Last Updated: 2026-03-13
This document defines the operating protocol for any AI Coding Agent working on this project. Every agent MUST read and follow this document before performing any task. These rules are non-negotiable and take priority over general agent defaults.
| # | Principle | Summary |
|---|---|---|
| 1 | Ask, don’t assume | When instructions are unclear, always ask the user for clarification before starting work. |
| 2 | Docs follow code | Every code change must be accompanied by corresponding documentation updates. |
| 3 | Read before write | Always read existing documentation in the doc/ folder before making any modifications. |
| 4 | UTF-8 end to end on Windows | When work involves Chinese or other non-ASCII text on Windows, the agent must ensure terminal, subprocess, and file I/O all use UTF-8 before trusting the output. |
| 5 | UV only | All Python projects use UV as the sole package and environment manager. Never use pip, conda, or virtualenv directly. |
| 6 | Test first | Strictly follow the TDD cycle. No functional code may be written until a test exists and fails. |
The agent MUST ask the user for clarification before starting any task if any of the following conditions are true:
doc/._config.yml, or altering the build/deploy pipeline.When asking for clarification, the agent must:
USER: "Update the blog styling"
AGENT RESPONSE (correct):
I'd like to clarify before proceeding:
- **Which aspect of styling?**
(a) Blog post content typography (headings, paragraphs, code blocks)
(b) Blog list page layout
(c) Blog navigation or sidebar
(d) All of the above
- **Is there a specific design reference** (screenshot, URL, or description)?
- **Should this affect the main portfolio styling** as well, or only the blog section?
AGENT RESPONSE (incorrect):
[Immediately starts modifying assets/css/style.css without asking]
The agent may proceed without asking if:
Before making ANY modification to the project, the agent MUST:
doc/ folder.A code change without a corresponding doc update is considered INCOMPLETE. The agent must not report a task as “done” unless the documentation has also been updated.
Any modification that alters the project’s behavior, structure, or conventions, including but not limited to:
| Change Type | Documentation Impact |
|---|---|
| New blog post created | Update doc/blog-conventions.md if new patterns are introduced |
| File/folder added or renamed | Update doc/project-structure.md |
_config.yml modified |
Update doc/configuration.md |
| Layout or include file changed | Update doc/layouts-and-includes.md |
| CSS/JS changes | Update doc/frontend-guide.md |
| New feature added | Create or update relevant doc in doc/ |
| Build/deploy process changed | Update doc/deployment.md |
When updating documentation, the agent must:
doc/ folder when appropriate.If a change introduces something that no existing document covers, the agent must:
.md file in doc/ with a descriptive filename (kebab-case, English).doc/README.md (the documentation index).UV is the sole package and environment management tool for all Python projects in this workspace. The agent MUST NOT use pip, conda, virtualenv, venv, or poetry directly. All dependency and environment operations must go through uv.
| Task | Command | Notes |
|---|---|---|
| Initialize a new project | uv init |
Creates pyproject.toml and project scaffolding |
| Create virtual environment | uv venv |
Creates .venv/ in the project root |
| Activate virtual environment | .venv\Scripts\activate (Windows) |
Activate before running project code |
| Add a dependency | uv add <package> |
Adds to pyproject.toml and installs |
| Add a dev dependency | uv add --dev <package> |
For test/lint/dev-only packages |
| Remove a dependency | uv remove <package> |
Removes from pyproject.toml and uninstalls |
| Install all dependencies | uv sync |
Installs everything from lock file |
| Update lock file | uv lock |
Regenerates uv.lock from pyproject.toml |
| Run a command in the env | uv run <command> |
Runs within the managed environment without manual activation |
| Show installed packages | uv pip list |
Lists packages in the current environment |
| File | Purpose | Version Control |
|---|---|---|
pyproject.toml |
Project metadata and dependency declarations | Must be committed |
uv.lock |
Deterministic lock file with exact resolved versions | Must be committed |
.venv/ |
Local virtual environment directory | Must be in .gitignore |
.python-version |
Pinned Python version for the project (optional) | Commit if present |
pip install directly. Always use uv add or uv sync.uv.lock manually. It is auto-generated by uv lock or uv add.pyproject.toml and uv.lock when dependencies change.uv run to execute scripts and tools to ensure the correct environment is used.pyproject.toml, run uv init before adding dependencies.The agent MUST strictly follow the TDD cycle. No functional code may be written until a test exists and fails. This is the core mechanism to prevent “hallucination coding” — producing code that looks correct but does not actually run.
Every feature must be developed following these steps strictly:
tests/ that asserts the expected behavior.uv run pytest. It MUST fail (proving the feature is not yet implemented).Skipping steps 2–3 (writing functional code before tests) is strictly prohibited.
The agent must write tests at different levels depending on the scope of the change:
pytesttests/unit/pytest fixtures to set up temporary environments (e.g., creating a dummy CSV file) and clean them up after the test.tests/integration/subprocess or shell commands within the test.stdout/stderr for specific output stringstests/e2e/unittest.mock or pytest-mock MUST be used to simulate external responses.
tests/
├── conftest.py # Shared fixtures and test configuration
├── unit/ # Unit tests
│ ├── test_parser.py
│ └── test_models.py
├── integration/ # Integration tests
│ ├── test_pipeline.py
│ └── test_database.py
└── e2e/ # End-to-end / system tests
└── test_cli.py
Before marking a task as “complete”, the agent MUST run the full test suite:
uv run pytest tests/ -v
uv run pytest --cov=src tests/Core awareness: Tests themselves are AI-generated and may contain errors.
When a test fails, there are two possible causes. The agent must diagnose before fixing:
| Cause | Description | Action |
|---|---|---|
| A. Functional code does not meet requirements | The code has a bug or does not implement the expected behavior | Fix the functional code, re-run tests |
| B. The test itself does not correctly reflect requirements | The test’s assertions, assumptions, or mock setup are wrong and do not match the original design intent | Fix the test case, re-run tests |
Diagnosis process:
No blind fixes: The agent must NOT simply modify code to make a test pass, or modify a test to make it stop failing, without understanding the root cause. Every fix must be grounded in a correct understanding of the requirements.
| Scenario | Requirement |
|---|---|
| New feature | Must write tests first (TDD) |
| Bug fix | Must write a test that reproduces the bug first, then fix |
| Code refactoring | Ensure existing tests pass; add tests if needed |
| Config/doc changes | No tests required |
These notes apply to routine agent work even when another section does not mention them explicitly.
cmd), if the task involves reading, writing, displaying, copying, or comparing Chinese or other non-ASCII text, the agent MUST first ensure terminal and subprocess I/O use UTF-8 end to end before trusting the output.[Console]::InputEncoding = [System.Text.UTF8Encoding]::new($false)
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
$OutputEncoding = [Console]::OutputEncoding
Get-Content -Encoding utf8 ./notes.md
Set-Content -Encoding utf8 ./notes.md '中文示例'
python -X utf8 ./script.py
If the agent realizes it has violated any rule in this document (e.g., started work without asking for clarification, or made a code change without updating docs), it must: