Instruction file imported from ivanjovicic/MathLearning (
.cursor/rules/agent-execution-efficiency.mdc). Copyright stays with the author.
Cursor execution efficiency
Follow AGENTS.md, .ai/README.md, and .ai/TOKEN_BUDGETS.md. This rule narrows execution topology; it does not replace repository ownership, validation, queue, or delivery policy.
Direct-by-default
The current/main agent owns normal execution. Complete bounded work directly through:
interpret -> inspect exact owners -> patch -> focused proof -> fix if needed -> verify -> deliver
Do not spawn a subagent for routine repository search, exact file reads, shell commands, queue selection/claim, implementation, formatting, focused tests, git status/diff, documentation updates, or a known-fix investigation that fits the selected budget.
Do not delegate merely because Auto/router mode offers a subagent or because the task is non-trivial.
When one subagent is justified
Use at most one subagent at a time by default, and only when its work is genuinely independent and one of these is true:
- finite exploration would create large intermediate output and isolating that output materially protects the parent context;
- an independent verifier can check completed work without redoing the implementation research;
- a finite audit has a clearly separated read set/question and the parent has other independent work it can continue.
More than one concurrent subagent is allowed only when the assigned prompt explicitly authorizes parallel, non-overlapping workstreams and the parent records why the extra token/context cost is justified.
Never use nested or recursively delegated subagents.
Delegation gate
Before spawning a subagent, the parent must be able to state in one compact note:
Delegated question:
Exact scope/read set:
Expected result/artifact:
Why direct execution is worse:
Stop condition:
If those fields are not clear, do the work directly.
A subagent does not expand the repository time/read/search/edit budget. Its reads, searches, command output, elapsed time, and returned context count against the same run budget.
No duplicated research
The parent must not repeat the subagent's repository exploration after it returns unless the result conflicts with current code/test evidence. Consume the concise result and continue from it.
Do not start a second agent to redo research already performed by the parent or another agent.
Waiting and progress visibility
Use a foreground subagent only when its answer blocks the next safe step. Otherwise prefer direct execution or bounded background delegation and continue independent parent work.
Do not remain in Waiting for subagent while the parent can safely inspect, edit, validate, document, or prepare delivery independently.
After each major phase or material tool result, emit one concise progress update stating what was proven/completed and what the next action is. Avoid narrating every command.
Stop conditions
Stop delegation and return to direct work or split/handoff when:
- a subagent exceeds its exact scope;
- the same question/research is being repeated;
- a second subsystem/owner appears;
- delegation would breach the selected budget;
- a subagent fails without producing new evidence;
- the parent already has enough evidence to patch and prove the task.
Subagents are a context-isolation tool for exceptional bounded work, not the default execution engine.
Main delivery without waiting for CI
When bounded work is ready, deliver to origin/main in the same run:
focused proof -> commit -> push/merge to origin/main -> record SHA -> close
Do not block closure on GitHub Actions, PR checks, or Database Validation. CI is follow-up verification; record it as pending/pass/fail in evidence, but never defer push/merge merely because checks are running.