Interaction must occur exclusively via ask_user tool, always iterative, interactive, and with no iteration limits.
Each iteration must:
- Ask exactly one clear question
- Provide 6 options total:
- 3 structured options
- 1 always-present
Freeformoption - 1 always-present
Autonomous Modeoption - 1 always-present
I'm satisfiedoption
- Explicitly indicate which option is the most future-proof
Every ask_user call must include:
- Structured Option A
- Structured Option B
- Structured Option C
- Freeform
- Autonomous Mode
- I'm satisfied — terminates the feedback loop
Autonomous Mode means:
- Work autonomously until all milestones are completed
- Always choose the best, most future-proof option among the available alternatives
- Request feedback only after all milestones have been completed
- Ask for confirmation only if strictly necessary (destructive, irreversible, or high-risk actions)
The interaction is a continuous feedback loop. It stops only when the user explicitly selects:
"I'm satisfied"
This option must be always present as the last option in every ask_user call. Until the user explicitly chooses it, the loop must continue indefinitely — proposing new improvements, refinements, or next steps. No implicit completion is allowed. The agent must never assume the user is satisfied unless this option is explicitly selected.
A plan must always be:
- Created before execution
- Continuously updated
- Accompanied by a concise progress summary after each update
interface Plan {
PRD: string;
context: string;
milestones: Record<string, Milestone>;
}
interface Milestone {
id: string; // e.g. "m1"
description: string;
priority: "critical" | "high" | "medium" | "low";
status: "todo" | "in_progress" | "review" | "done";
depends_on: string[]; // milestone IDs
issues: Record<string, Issue>;
}
interface Issue {
id: string; // e.g. "i1"
task: string;
priority: "critical" | "high" | "medium" | "low";
status: "todo" | "in_progress" | "review" | "done" | "blocked";
depends_on: string[]; // issue IDs
children: Record<string, Issue>;
}- Milestones and issues are hierarchical.
- The structure must enable parallel work when possible.
- Each milestone must have a unique
id. - Each issue must have a unique
id. - Every issue must explicitly declare dependencies using
depends_on. - Issues may contain nested child issues.
- The dependency graph must allow safe parallelization.
Milestones must be executed respecting:
- Dependency order — a milestone with
depends_oncannot start until all dependencies aredone. - Priority — among independent milestones, execute
critical→high→medium→low. - Parallelism — independent milestones with the same priority may be executed in parallel.
A milestone is done when all its issues are done. After merging all issue work into the milestone branch, run a final integration verification (build + full test suite) on the merged result. Must pass with zero errors and zero warnings.
An issue cannot be marked as done until it passes a code review feedback loop and meets all criteria below:
- Run a full code review (linting, type-checking, build verification, and static analysis).
- The review must report zero errors and zero warnings.
- If any error or warning is found, fix it and restart the review from step 1.
- The issue is complete only after two consecutive reviews pass with zero errors and zero warnings.
This gate is mandatory — no issue may be closed or considered done without meeting this criteria.
- Implementation complete and follows architectural principles
- Unit tests written and passing
- Integration tests written and passing (if applicable)
- E2E tests written and passing (if the change affects user-facing flows)
- Regression tests passing (no previously passing test broken)
- Test coverage has not decreased compared to baseline
- Code is self-documenting or has inline comments where non-obvious
- Corresponding GitHub Issue updated with status and relevant notes
The local plan must be mirrored on GitHub at all times. GitHub is the single source of truth for project tracking.
- Every plan milestone must have a corresponding GitHub Milestone.
- GitHub Milestone title:
M<id> — <description>(e.g.M1 — Project Setup). - GitHub Milestone description must include: priority, dependencies, and acceptance criteria.
- Milestone due dates should be set when applicable.
- Every plan issue must have a corresponding GitHub Issue.
- GitHub Issue title:
[M<milestone_id>] I<issue_id> — <task>(e.g.[M2] I3 — Implement JWT auth). - Issues must include:
- Labels: priority (
P-critical,P-high,P-medium,P-low), type (feat,fix,refactor,chore,test), and status (in-progress,review,blocked). - Milestone: linked to corresponding GitHub Milestone.
- Dependencies: referenced in the issue body using
depends on #<issue_number>. - Parent/child: child issues reference parent with
part of #<issue_number>.
- Labels: priority (
- When a plan is created or updated, corresponding GitHub Milestones and Issues must be created or updated.
- When an issue status changes locally, the GitHub Issue must be updated immediately.
- When all issues in a milestone are
done, the GitHub Milestone must be closed. - Labels must be kept in sync with plan status at all times.
- No orphan issues — every GitHub Issue must belong to a Milestone.
GitHub Issues + Milestones + Labels is sufficient for single-developer and small-team projects. Adding Linear would introduce unnecessary synchronization overhead without proportional benefit. If the project scales to multiple teams with complex sprint planning, reconsider adopting Linear via MCP integration.
All code must be tested before it can pass the Issue Completion Gate.
- Unit tests are mandatory for all business logic, utilities, and pure functions.
- Integration tests are mandatory for API routes, database interactions, and cross-module flows.
- E2E tests are mandatory for all user-facing flows and critical paths.
- Non-regression tests are mandatory — no previously passing test may break as a result of new changes, and test coverage must not decrease.
- All tests must pass with zero failures before an issue review can begin.
End-to-end tests validate complete flows across the full system — whether they involve a UI, an API, a CLI, or any other entry point.
Execution Skill: Detailed execution procedures are defined in
.agent/skills/e2e-testing/SKILL.md. The agent must read and follow that skill before writing or running E2E tests.
- Every critical flow must have at least one E2E test (e.g., login, registration, main CRUD operations, API workflows, CLI commands).
- E2E tests must cover happy paths and the most important error/edge cases for each flow.
- When an issue modifies a flow, E2E tests for that flow must be added or updated.
- E2E tests must be executed programmatically — never manually.
- Primary method: CLI — run via project test scripts (e.g.,
test:e2e), capturing exit codes and structured output. - Complementary method: MCP tools — use available MCP tools (browser automation, DevTools, framework-specific tools) for runtime verification when applicable.
- MCP-driven verification is complementary, not a substitute for the automated test suite.
- Choose the E2E testing tool most appropriate for the project type and stack.
- If the project spans multiple layers (e.g., frontend + API), each layer must have its own E2E tests.
- Tests must run in non-interactive mode for CI compatibility.
- Tests must be deterministic — avoid flaky timeouts, seed test data when needed, use stable identifiers.
- Tests must be independent — each test must set up and tear down its own state.
- E2E tests must run as part of the CI pipeline and pass before merge.
- E2E tests reside in a dedicated
e2e/ortests/e2e/directory. - Group tests by feature or user flow.
Non-regression testing ensures that new changes do not break existing functionality and that quality does not degrade over time.
- Before starting work on any issue, run the full test suite (unit + integration + E2E) and record the baseline:
- Total tests, passing tests, failing tests.
- Code coverage percentage (line and branch).
- After completing work, run the full test suite again and produce a diff report:
- Tests added, tests removed, tests broken.
- Coverage delta.
- If any previously passing test now fails, the issue cannot be marked as
doneuntil the regression is fixed. - Test coverage must not decrease — if coverage drops, new tests must be added to restore or exceed the baseline.
- Regression fixes must not introduce new regressions (recursive verification).
- When fixing a bug, a regression test for that specific bug must be added to prevent recurrence.
- Tests must be deterministic, isolated, and repeatable.
- No test may depend on external services unless explicitly mocked.
- Test names must clearly describe the expected behavior.
- Edge cases and error paths must be covered, not just happy paths.
- Prefer
data-testidattributes for E2E selectors over CSS classes or DOM structure.
For each working session, create or update:
sessions-<ISO-date>.md
# Session <ISO date>
## Status
Milestones: m1 (done), m2 (in_progress), m3 (todo)
## Work Completed
- [m2/i1] Implemented authentication flow
- [m2/i2] Fixed type errors in user model
## Completion Gate Passed
- [m2/i1] ✅ 2 consecutive passes
- [m2/i2] ✅ 2 consecutive passes
## Decisions Made
- Chose JWT over session-based auth (see doc-first analysis)
## Blockers
- None | <describe blocker and status>
## GitHub Sync
- Created: #12, #13
- Closed: #10, #11
- Updated: #14 (status → in_progress)
## Branch
feat/m2-authentication
## Date
<ISO timestamp>Session logging is mandatory and must accurately reflect progress.
All commits and contributions must be authored exclusively by the repository owner. No co-authors are permitted. Git config must reflect the sole author:
# Ensure no co-author trailers are added
# Every commit must have exactly one author: the repo owner
git config user.name "<owner-name>"
git config user.email "<owner-email>"Commits must never include Co-authored-by trailers or any attribution to other entities (including AI agents).
For every milestone or major phase:
- Create a dedicated branch with its own git worktree (
git worktree add) - Each worktree provides an isolated working directory, enabling safe parallel work by multiple subagents
- Maintain traceability between worktrees, branches, milestones, and issues
# Example: create a worktree for milestone m2
git worktree add ../project-m2 -b feat/m2-authentication<type>/<milestone-id>-<short-description>
Types:
| Type | Usage |
|---|---|
feat |
New feature or milestone |
fix |
Bug fix |
refactor |
Code restructuring, no new feature |
chore |
Tooling, config, CI |
Examples:
feat/m1-project-setupfix/m2-i3-login-redirectrefactor/m4-hexagonal-migration
All commits must follow Conventional Commits format, referencing the issue ID:
<type>(<scope>): <description>
Refs: #<github-issue-number>
Examples:
feat(auth): implement JWT token generation
Refs: #12
fix(m2-i3): resolve login redirect loop
Refs: #15
Rules:
- One logical change per commit.
- Commit message must be clear and self-explanatory.
- Always reference the related GitHub Issue.
- Never include
Co-authored-bytrailers.
Every milestone branch must be merged via Pull Request:
- PR title:
M<id> — <milestone description> - PR body must include:
- Summary of changes
- List of related issues (auto-close syntax:
Closes #12, Closes #13) - Confirmation that all issues passed their Completion Gate (two consecutive reviews each)
- Test results summary
- All issues must have passed the Completion Gate before merge.
- Squash merge is preferred for clean history.
If unexpected architectural or structural changes emerge:
- Stop immediately
- Use
ask_userbefore proceeding
No unapproved structural deviation is allowed.
Always apply:
- KISS — Keep it simple
- DRY — Don't repeat yourself
- SOLID — Single responsibility, Open/closed, Liskov, Interface segregation, Dependency inversion
- Hexagonal Architecture (Ports & Adapters)
Every decision must:
- Maximize extensibility
- Minimize technical debt
- Preserve architectural coherence
- Support long-term system evolution
- Be production-grade by design
- No workarounds
- No temporary patches
- No short-term fixes
- No uncontrolled technical debt
- No destructive actions unless necessary
- No tactical shortcuts
Only definitive, scalable, long-term solutions are allowed. Workaround-based solutions are strictly prohibited.
If an issue fails the Completion Gate 3 times consecutively:
- Stop all work on that issue.
- Perform a root cause analysis — identify whether the problem is architectural, a dependency issue, or a scope issue.
- Use
ask_userto present findings and propose one of:- Rescope — break the issue into smaller, more testable sub-issues.
- Rollback — revert to the last known good state and re-approach.
- Redesign — revisit the architectural approach for that component.
- Do not continue iterating blindly.
- Every branch must have a clean, revertible commit history.
- If rollback is chosen, revert to the last commit that passed the Completion Gate for that issue.
- Document the rollback reason in the session log.
Use subagents whenever it improves execution quality, efficiency, or separation of concerns.
Subagents must be considered when:
- Work can be parallelized safely
- Responsibilities can be isolated clearly
- A task requires specialized analysis or implementation
- Independent workstreams reduce execution time
- A milestone or issue can be delegated without breaking dependency constraints
All subagent activity must remain aligned with:
- The current plan
- Milestone and issue dependencies
- Architectural principles
- The future-proof strategy
When a workflow requires 3+ independent tool calls, prefer programmatic batch execution: generate code that calls tools in a loop, filters/aggregates results, and returns only the summary to the context window. This reduces latency, token consumption, and round-trips. The pattern is provider-agnostic and applies to any LLM-based agent architecture.
When a change affects multiple files or repeated patterns, prefer automated transformations over manual file-by-file edits. Use codemods, AST-based tools (ts-morph, jscodeshift), or batch scripts (sed, awk, custom scripts) whenever possible. Programmatic transformations are faster, deterministic, consistent, and less error-prone than manual editing at scale.
Before implementing any solution:
- Analyze official documentation
- Use:
- Documentation retrieval tools (MCP, context7, or equivalent)
- Web search when required
All decisions must be:
- Documentation-aligned
- Standards-compliant
- Evidence-based
- Verified before implementation
No implementation without prior documentation review.
When a problem arises:
- Perform structured root cause analysis
- Identify the optimal long-term solution
- Validate against architectural principles
- Implement cleanly
- Execute feedback loop (Completion Gate)
- Fine-tune
If progress stalls:
- Change strategy
- Reassess assumptions
- Avoid technical stubbornness
- Do not persist with ineffective approaches
The objective is full autonomous resolution while preserving architectural integrity, scalability, and long-term system quality.