---
name: goal-stop
description: Refuse or rewrite a vague /goal so it has Objective, Scope (in/out), Constraints (especially no prod-destroy), Verification/Done-when (a machine-checkable command), and a turn cap. Use when the user writes /goal, a vague agent objective (optimize, improve UX, make it better, 优化一下), or there is a runaway-loop risk (no stop condition, unbounded scope, subjective done).
---

# Goal Stop

A `/goal` without a stop condition is a blank check. Do **one** job: refuse or rewrite until the prompt can finish.

Reuse the shared contract in `schema/goal/` (Objective, Scope, Constraints, Verification). Do not invent a second schema. Put the **turn cap** under Constraints.

## Detect a bad goal

Refuse to run (ask for a rewrite) if any of these are missing:

| Fail | Signal |
| --- | --- |
| Unverifiable objective | optimize / improve / 更好 / 全部 — no observable outcome |
| No scope | whole repo / whatever needed / no in-out list |
| No done-when | looks good / feels right — no command with an exit code |
| No turn cap | agent can loop forever |

Also refuse production-destroying scope (drop prod DB, rewrite infra, leak secrets) unless the user names the exact target **and** a rollback check.

## Rewrite

Fill every dimension. If a field is unknown, ask — do not guess an unbounded default.

1. **Objective** — one verifiable sentence (maps to a checklist).
2. **Scope** — in-scope paths/modules; explicit out-of-scope.
3. **Constraints** — stack limits, forbidden actions, **no prod-destroy**, **turn cap** (`stop after N turns if verification still fails; report leftovers`).
4. **Verification / Done when** — machine-checkable command (exit code 0) plus observable criteria.

Then output the rewritten `/goal` and wait for the user to confirm before executing.

## Template

```text
/goal <one verifiable sentence>

## Objective
<same sentence or a tighter restatement>

## Scope
In scope:
- <path or module>

Out of scope:
- <do-not-touch>

## Constraints
- Do not destroy production data or infrastructure
- Turn cap: stop after <N> turns if verification still fails; report what is left
- <stack / style / process limits>

## Verification / Done when
Criteria:
- <observable result>

Commands:
- <command that exits 0 when done>

Done when:
All criteria pass and the command exits 0.
```

## Bad vs good (login module)

**Bad** — blank check, cannot stop:

```text
/goal Optimize the login module and improve the UX
```

**Good** — same task, stoppable (from `schema/goal` contrast lessons):

```text
/goal Fix missing error message when invalid email is submitted on the login page

## Objective
When a user submits an invalid email, a clear error message appears under the field and no network request is sent.

## Scope
In scope:
- app/(auth)/login page and related form validation components

Out of scope:
- Signup flow, OAuth, backend auth logic

## Constraints
- Do not introduce a new UI library
- Keep existing i18n key style
- Do not destroy production data or infrastructure
- Turn cap: stop after 8 turns if verification still fails; report what is left

## Verification / Done when
Criteria:
- Invalid email shows an error message
- Valid email can still submit

Commands:
- bun run lint

Done when:
All criteria above pass and lint is clean.
```
