|
| 1 | +--- |
| 2 | +name: safe-retry |
| 3 | +description: >- |
| 4 | + Guards against infinite retry loops when the agent introduces syntax or |
| 5 | + parse errors during edits. Requires diagnosis before retrying any failing |
| 6 | + command and enforces hard stop thresholds. |
| 7 | +--- |
| 8 | + |
| 9 | +# Safe Retry |
| 10 | + |
| 11 | +When a test, build, or lint command fails after you edited code, the error |
| 12 | +is most likely YOUR fault — not a pre-existing issue or a flaky test. Before |
| 13 | +retrying any failing command, you MUST follow the diagnosis steps below. |
| 14 | + |
| 15 | +**This skill overrides any instinct to "just retry."** |
| 16 | + |
| 17 | +## Diagnosis before retry |
| 18 | + |
| 19 | +After every test/build/lint failure: |
| 20 | + |
| 21 | +1. **Read the full error output.** Identify the failing file and line number. |
| 22 | +2. **Check if the failing file is one you edited.** If yes, the error is |
| 23 | + self-inflicted. Fix the file first — do not retry the command. |
| 24 | +3. **Classify the error.** Syntax errors, parse errors, unexpected token |
| 25 | + errors, and import/export resolution errors are almost always caused by |
| 26 | + incomplete edits (e.g., renaming a symbol in one place but not updating |
| 27 | + its import, or breaking a multi-line statement). |
| 28 | + |
| 29 | +## Hard rules |
| 30 | + |
| 31 | +- **Never retry the same command without changing code first.** If a command |
| 32 | + failed, running it again without edits will produce the same failure. This |
| 33 | + includes variations like `yarn test`, `yarn backstage-cli package test`, |
| 34 | + and `yarn backstage-cli package test --no-cache` — these are the same |
| 35 | + command with different flags, not different fixes. |
| 36 | +- **After 2 consecutive test failures, STOP and diagnose.** Re-read every |
| 37 | + file you edited. Diff your changes against the original. Look for broken |
| 38 | + imports, unclosed brackets, missing commas, and partial renames. Fix the |
| 39 | + root cause before running tests again. |
| 40 | +- **After 3 total test failures across the entire run, produce structured |
| 41 | + output with `tests_passed: false` and stop.** Do not commit broken code. |
| 42 | + The post-script will report the failure and a human can intervene. |
| 43 | + |
| 44 | +## Common self-inflicted errors |
| 45 | + |
| 46 | +| Error pattern | Likely cause | Fix | |
| 47 | +| ----------------------------------------------- | -------------------------------------------------- | --------------------------------------------------- | |
| 48 | +| `SyntaxError: Unexpected token` | Incomplete edit broke the AST | Read the file around the error line; fix the syntax | |
| 49 | +| `Unexpected token, expected "from"` | Broke an `import` statement (e.g., partial rename) | Check all `import`/`export` lines in the file | |
| 50 | +| `Module '"./foo"' has no exported member 'Bar'` | Renamed an export but didn't update imports | Find all files importing `Bar` and update them | |
| 51 | +| `Cannot find module './foo'` | Renamed or moved a file but didn't update imports | Grep for the old path and fix references | |
| 52 | +| `TypeError: X is not a function` | Changed a function signature or export | Check callers | |
0 commit comments