Feature Loop
Use when session_mode == feature_loop and the project is past the Initializer phase (system prompt will say "Coding 阶段").
Iron rules
- One feature per session. Multiple
in_progressfeatures are forbidden by the store; do not bypass. - Always verify before commit.
feature_completerejects features that have not been promoted toverifiedviaverify_run. - Keep the branch mergeable. Each commit must compile, pass
verify.yaml, and not depend on uncommitted local state.
Loop
- Sync from disk. Call
project_statusfirst thing every session — it readsfeature_list.json/status.json/progress.mdand reseeds your understanding from the single source of truth. - Pick a feature.
- If
status.active_feature_idis already set, resume that one (the prompt block will tell you). - Otherwise call
feature_selectwith no arguments to auto-pick the highest-priority pending feature with satisfied dependencies, or passfeature_idwhen the user names one.
- If
- Implement using code_dev phases (Explore → Read → Author):
- Explore with
code_outline,grep, optionalcode_search. - Read with
file_readslices (start/end line). Track files you have read in scratchpad. - Author with
file_writeskeletons first, then section-by-section appends.
- Explore with
- Run the gate. Call
verify_run feature_id=<id>. If any step fails:- Do not call
feature_complete. - Log a
progress_appendwith the failing step name and root cause. - Decide: fix and rerun
verify_run, or escalate to the user with the specific failure.
- Do not call
- Commit via shell.
Capture the resulting sha (git add -A git commit -m "feat(<feature_id>): <one-line summary>"git rev-parse HEAD). - Promote to committed. Call
feature_complete feature_id=<id> commit_sha=<sha>. The store writes an immutable archive snapshot under.agx/project/archive/feature_<id>.json. - Decide next step. Either call
feature_selectfor the next feature in the same session, or stop and tell the user the loop closed cleanly.
Failure modes
- verify_run timeouts: do not retry blindly. Inspect the log under
.agx/project/archive/, fix the root cause, then rerun. - Dependency missed:
feature_selectwill reject features whosedepends_onisn'tcommitted. Either pick a different feature or finish the prerequisite first. - Lost context after window compaction: re-call
project_status. Disk is the source of truth. - Cold start (new machine, fresh session):
project_status+feature_selectis enough to resume. No memory of previous turns is required.
Forbidden
- Editing files inside
.agx/project/archive/(immutable). - Calling
project_initoutside the Initializer phase. - Skipping
verify_runbecause "tests are too slow".