Skip to content

Commit b7d6eea

Browse files
committed
docs: document scientific debugging and TCR branching workflows
1 parent d53d2cc commit b7d6eea

File tree

4 files changed

+64
-28
lines changed

4 files changed

+64
-28
lines changed

docs/design.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,30 @@ Commands define structured, multi-phase workflows that automate the development
2828

2929
- **`/plan`:** An interactive workflow that transitions between clarification, analysis, and strategy generation.
3030
- **`/research`:** A deep-dive exploration that produces exhaustive reports in the `research/` directory.
31-
- **`/debug`:** Activates a forensic investigation mode for root-cause analysis.
31+
- **`/debug`:** Activates a **forensic investigation mode** using a scientific, hypothesis-driven workflow.
3232
- **`/document`:** Analyzes the codebase and project state to update the documentation suite.
33-
- **`/task`:** The primary execution engine, managing `TASKS.md` and enforcing the strict TCR (Test-Commit-Revert) loop and feature branch isolation.
33+
- **`/task`:** The primary execution engine, managing `TASKS.md` and enforcing the **strict TCR (Test-Commit-Revert) loop** and feature branch isolation.
34+
35+
### 🔍 Deep Dive: Scientific Debugging
36+
37+
The `/debug` command implements a principled approach to problem-solving, moving through four distinct phases:
38+
39+
1. **Status & Context Analysis:** The agent gathers all relevant error logs, stack traces, and recent changes.
40+
2. **Hypothesis Formulation:** Instead of guessing, the agent must propose a specific hypothesis for the root cause and obtain user approval.
41+
3. **Isolated Hypothesis Testing:** The agent creates a temporary **diagnostic branch** (`debug/hyp-*`) and is granted restricted `write_file` access *only* for diagnostic code (logs, reproduction scripts).
42+
4. **Synthesis & RCA Report:** Once verified, the agent synthesizes the findings into a structured Root Cause Analysis (RCA) report, ensuring the "fix" is understood before it is implemented.
43+
44+
### 🔍 Deep Dive: TCR (Test-Commit-Revert) Protocol
45+
46+
The `/task work` command enforces a high-discipline development lifecycle through a strict TCR loop:
47+
48+
1. **Pre-flight Verification:** Ensures a clean `main` branch and passing tests.
49+
2. **Isolation:** All work occurs on an auto-generated, kebab-case feature branch.
50+
3. **The Loop (Red-Green-Verify):**
51+
- **Red:** A failing test is written to define the step's goal.
52+
- **Green:** Minimal code is written to pass the test.
53+
- **Verify:** If the test fails, the agent is allowed **one quick fix**. If it fails again, the change is **automatically reverted** (`git checkout .`), preserving the last known stable state.
54+
4. **Integration:** Upon completion, the feature branch is merged, the roadmap is updated, and the branch is deleted.
3455

3556
### 🔍 Deep Dive: Timestamp-Based Validation
3657

docs/develop.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,37 @@ Before proposing a change, use the `/research` command to gather context, analyz
1414

1515
A feature is not considered "active" until a persistent Markdown plan has been created in the `plans/` directory. Use the `/plan` command to generate this strategy and synchronize it with `TASKS.md`.
1616

17-
### 3. Execution & Validation (TCR Protocol)
17+
### 3. Execution & Validation (The TCR Protocol)
1818

19-
The `/task work on ...` command implements a strict **TCR (Test-Commit-Revert)** protocol to ensure high-velocity, high-quality code.
19+
The `/task` command is the primary tool for repository execution. It supports multiple actions to manage the project roadmap:
2020

21-
#### **Phase 1: Pre-flight Verification**
21+
- **`/task create`**: Adds a new task to `TASKS.md`.
22+
- **`/task work on ...`**: Implements a strict **TCR (Test-Commit-Revert)** protocol to ensure high-velocity, high-quality code.
23+
- **`/task report`**: Provides a summary of the roadmap and current priorities.
24+
- **`/task update`**: Updates the status of an existing task.
2225

23-
The agent verifies that the working tree is clean, the current branch is `main`, and `make test` passes as a baseline.
26+
#### **The TCR Loop (Work Action)**
2427

25-
#### **Phase 2: Task Isolation**
28+
1. **Phase 1 (Pre-flight Verification):** The agent verifies that the working tree is clean, the current branch is `main`, and `make test` passes as a baseline.
29+
2. **Phase 2 (Task Isolation):** A dedicated feature branch (e.g., `feature/task-name`) is auto-generated and checked out. All work occurs on this isolated branch.
30+
3. **Phase 3 (The Red-Green-Verify Loop):** For every granular step of the implementation:
31+
- **Red:** Write a failing test and verify failure with `make test`.
32+
- **Green:** Implement the minimal code to pass the test.
33+
- **Verify:** Run `make test`.
34+
- **Pass:** `git commit` the step.
35+
- **Fail:** Attempt **one quick fix**. If it fails again, the change is **automatically reverted** (`git checkout .`).
36+
4. **Phase 4 (Integration):** Once all steps are complete, the agent performs a final test run. Upon approval, the branch is merged into `main` and deleted.
2637

27-
A dedicated feature branch (e.g., `feature/task-name`) is auto-generated and checked out. All subsequent work for this task occurs here.
38+
### 4. Forensic Investigation (The Scientific Debugging Discipline)
2839

29-
#### **Phase 3: The Red-Green-Verify Loop**
40+
When a bug is detected, the `/debug` command enforces a structured, scientific investigation:
3041

31-
For every granular step of the implementation:
42+
1. **Phase 1 (Status & Context):** Analyze the current environment and gather reproduction information.
43+
2. **Phase 2 (Hypothesis Formulation):** Formulate a specific hypothesis for the root cause.
44+
3. **Phase 3 (Isolated Testing):** Test the hypothesis on a temporary diagnostic branch (`debug/hyp-*`). Diagnostic code should be minimal and focused.
45+
4. **Phase 4 (Synthesis & RCA):** Summarize the investigation into a **Root Cause Analysis (RCA)** report. This report serves as the documentation for the subsequent fix.
3246

33-
1. **Red:** Write a failing test and verify failure with `make test`.
34-
2. **Green:** Implement the minimal code to pass.
35-
3. **Verify:** Run `make test`.
36-
- **Pass:** `git commit` the step.
37-
- **Fail:** Attempt one quick fix; if it still fails, **revert** to the last green state (`git checkout .`).
38-
39-
#### **Phase 4: Integration**
40-
41-
Once all steps are complete, a final test run is performed. Upon user approval, the branch is merged back to `main` and the roadmap in `TASKS.md` is updated.
42-
43-
### 4. Audit & Documentation (NEW)
47+
### 5. Audit & Documentation (NEW)
4448

4549
Before merging or committing any final change, the work **must** be documented in the daily journal. This is enforced by a **timestamp-based git hook**. Use the following tool to satisfy the requirement:
4650

docs/user-guide.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ This framework solves this problem by enforcing three core principles:
2222

2323
The most critical phase of any project occurs before you write a single line of code. This framework moves away from impulsive execution toward a deliberate, architected approach.
2424

25-
### `/research`
25+
### `/debug`
2626

27-
Your primary tool for gathering external knowledge.
27+
Your primary tool for forensic, scientific investigation.
2828

29-
- **How it works:** When triggered, the `researcher` subagent scours the web for technical documentation, APIs, or case studies. It synthesizes this data into granular summaries saved in the `research/` directory.
30-
- **When to use:** Use this when you need to understand a new library, a technical specification, or gather data for an article.
29+
- **How it works:** When a bug is detected, the `/debug` command implements a principled approach to problem-solving. It moves through four distinct phases: Context Analysis, Hypothesis Formulation, Isolated Testing on a temporary branch (`debug/hyp-*`), and finally a Synthesis of the findings into a **Root Cause Analysis (RCA)** report.
30+
- **Why it works:** It forces the agent to identify the root cause *before* attempting a fix, preventing "guess-and-check" coding that can lead to regressions.
3131

3232
### `/plan`
3333

@@ -53,7 +53,7 @@ Your gateway to GitHub.
5353

5454
Your roadmap manager.
5555

56-
- **How it works:** Manages a living `TASKS.md` document. Use it to `create` new tasks, `work` on existing ones, or `report` on the project's current status.
56+
- **How it works:** Manages a living `TASKS.md` document. Use it to `create` new tasks, `work` on existing ones, `report` on priorities, or `update` statuses.
5757

5858
### `/commit`
5959

@@ -90,10 +90,11 @@ The approved plan is linked to a task. You trigger the execution:
9090
- **Pre-flight:** The agent verifies the tree is clean on `main`.
9191
- **Isolation:** A `feature/auth-integration` branch is created.
9292
- **Loop (Red-Green-Verify):**
93-
1. Agent writes a failing `test_auth_logic.py`.
93+
1. Agent writes a failing `test_auth_logic.py` based on the plan.
9494
2. Agent implements the minimal logic to pass.
9595
3. Agent runs `make test`. If successful, the step is committed.
96-
4. The loop repeats for every granular step.
96+
4. If it fails, the agent tries **one quick fix**. If it fails again, the change is **automatically reverted**, preserving the last stable state.
97+
5. The loop repeats for every granular step defined in the plan.
9798

9899
### **Step 4: Review & Integrate**
99100

@@ -103,6 +104,15 @@ After all steps pass, the agent presents the final work. Upon your approval, it
103104

104105
Finally, use `/docs` to update the technical documentation and `/release` to publish the new version.
105106

107+
## 🔍 Walkthrough: Solving a Bug with `/debug`
108+
109+
When a bug is detected, the `/debug` command ensures a scientific resolution:
110+
111+
1. **Analyze Context:** The agent gathers all relevant logs and context.
112+
2. **Formulate Hypothesis:** The agent proposes a root cause hypothesis (e.g., "The auth token is not being correctly passed to the header").
113+
3. **Isolate & Test:** The agent creates a temporary branch `debug/hyp-auth-token`. It implements a minimal reproduction script or logging.
114+
4. **RCA Synthesis:** Once confirmed, the agent generates a **Root Cause Analysis (RCA)** report. This report is used as the basis for the subsequent `/task work` to implement the fix on a feature branch.
115+
106116
## ✍️ Maintaining your Journal
107117

108118
The framework's most powerful feature is its automated audit trail. This is enforced by a **timestamp-based pre-commit hook** that ensures your code never gets ahead of your documentation.

journal/2026-03-20.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
[2026-03-20T08:45:12] - refactor(docs): simplify journal entry logic in install.sh
1212
[2026-03-20T08:46:18] - chore(release): version 0.17.1
1313
[2026-03-20T09:54:08] - docs: update comprehensive documentation suite (index, deploy, design, develop, user-guide) with latest framework improvements
14+
[2026-03-20T10:01:39] - docs: update /debug and /task workflows with scientific investigation and TCR details

0 commit comments

Comments
 (0)