Jay Dev Cancel Loop

Override the Ralph loop mechanism to allow session exit (emergency use only).

jayhjenkins updated 6mo ago
Claude CodeGeneric
View source ↗
# Jay-Dev Cancel Loop Command

Override the Ralph loop mechanism to allow session exit (emergency use only).

## What This Command Does

Forcibly disables the Ralph loop Stop hook to allow immediate session exit:

1. **Updates STATUS.md** - Sets COMPLETION: OVERRIDE
2. **Updates loop state** - Sets override flag in .loop_state.json
3. **Allows exit** - Next stop attempt will succeed
4. **Logs reason** - Documents why override was used

## When to Use This

⚠️ **Emergency use only**

**Valid reasons:**
- Work is blocked by external dependency (API docs missing, access needed, etc.)
- Discovered work is larger than expected and needs re-planning
- Need to context-switch to urgent issue
- Hit a dead-end and need human intervention
- Max iterations reached but work still incomplete (already handled automatically)

**Invalid reasons:**
- Work is complete but STATUS not updated → Update STATUS instead
- Tests failing → Fix tests instead
- Don't want to run QA → Run QA instead (required for quality)
- Impatient → Let the process complete

## Expected Behavior

### Normal Usage

/jay-dev:cancel-loop


**Prompt for reason:**

⚠️ Cancel Ralph Loop

This will override completion criteria and allow exit.

Why are you canceling? (required for STATUS.md documentation)

Examples:

  • "Blocked: Waiting for API credentials from DevOps team"
  • "Need to re-plan: Scope larger than expected"
  • "Urgent: Production incident requires immediate attention"

Reason:


**User provides reason:**

Reason: Blocked waiting for OAuth provider credentials


**Execution:**

🛑 Canceling Ralph loop...

  1. Updating STATUS.md...

    • Set COMPLETION: OVERRIDE
    • Added reason: "Blocked waiting for OAuth provider credentials"
    • Added timestamp: 2026-01-03 16:30:00
  2. Updating loop state...

    • Set override: true in docs/status/.loop_state.json
  3. Ralph loop override active ✅

Next time you try to exit, the Stop hook will allow it.

To resume work later:

  1. Address the blocker: [reason]
  2. Update STATUS.md with current state
  3. Continue working (Ralph loop will reset on next session)

**STATUS.md updated:**
```markdown
## Current State
Goal: Implement user authentication
Active Plan: docs/plans/user-authentication.md
Current Task: Task #12 - OAuth integration (BLOCKED)
Blockers:
- Waiting for OAuth provider credentials from DevOps team
- ETA: Unknown
- Requested: 2026-01-03 15:00

## COMPLETION STATUS
COMPLETION: OVERRIDE
Reason: Blocked waiting for OAuth provider credentials
Timestamp: 2026-01-03 16:30:00
Override by: /jay-dev:cancel-loop

## Next Steps
When blocker resolved:
1. Update STATUS with new status
2. Continue from task #12
3. Run appropriate QA checkpoint

Alternative: Direct Override (No Prompt)

/jay-dev:cancel-loop "Blocked: Waiting for API docs"

Skips prompt, uses provided reason directly.

Session Exit After Cancel

User attempts exit (Ctrl+C or natural completion)...

🔄 Jay-Dev Stop Hook checking...

COMPLETION: OVERRIDE detected ✅
Reason: Blocked waiting for OAuth provider credentials

Allowing exit.

Session ended.

Loop State File

Before cancel:

{
  "iteration": 15,
  "max_iterations": 50,
  "original_goal": "Implement user authentication",
  "override": false
}

After cancel:

{
  "iteration": 15,
  "max_iterations": 50,
  "original_goal": "Implement user authentication",
  "override": true,
  "override_reason": "Blocked waiting for OAuth provider credentials",
  "override_timestamp": "2026-01-03T16:30:00Z"
}

Resuming After Cancel

Next session:

  1. Loop state file still exists with override: true

  2. First session-start hook will detect this

  3. Session-start hook will warn:

    ⚠️  Previous session was canceled with override
    
    Reason: Blocked waiting for OAuth provider credentials
    Timestamp: 2026-01-03 16:30:00
    
    Current STATUS: [shows STATUS.md excerpt]
    
    To continue:
    1. Review STATUS.md
    2. Address blockers if resolved
    3. Continue work or re-plan
    
  4. Loop state resets (override: false) for new session

  5. New work can proceed normally

Audit Trail

Every cancel is recorded:

In STATUS.md:

## History
- 2026-01-03 16:30: Ralph loop canceled (reason: Blocked waiting for OAuth creds)
- 2026-01-03 14:00: Started user auth plan execution

In loop state file:

{
  ...
  "override_history": [
    {
      "timestamp": "2026-01-03T16:30:00Z",
      "reason": "Blocked waiting for OAuth provider credentials",
      "iteration": 15
    }
  ]
}

Safety Checks

Before allowing cancel:

⚠️  Cancel Check

Current state:
- Active plan: docs/plans/user-authentication.md
- Tasks complete: 11/18
- Uncommitted changes: 3 files
- Iteration: 15/50

Are you sure you want to cancel?

Uncommitted changes detected:
- src/auth/oauth.js
- test/auth/oauth.test.js
- docs/ARCHITECTURE.md

Recommended:
1. Commit changes first (git commit)
2. Update STATUS.md with current state
3. Then cancel

Proceed anyway? (y/n)

If user confirms, allow cancel.

Integration with Max Iterations

If max iterations already reached:

/jay-dev:cancel-loop

ℹ️  Max iterations already reached (50/50)

Ralph loop already disabled - no need for manual cancel.

Next exit attempt will succeed automatically.

STATUS.md not updated (already shows iteration limit reached).

No action needed - loop already stopped.

Comparison: Cancel vs Manual Override

Using /jay-dev:cancel-loop (Recommended)

/jay-dev:cancel-loop "Reason here"

✅ Proper audit trail
✅ STATUS.md updated automatically
✅ Loop state managed correctly
✅ Clean exit

Manual override in STATUS.md (Alternative)

User manually edits STATUS.md:

COMPLETION: OVERRIDE
Reason: My reason

✅ Works (Stop hook reads STATUS.md)
⚠️  Doesn't update loop state file
⚠️  No timestamp or audit trail

Both work, but /jay-dev:cancel-loop is cleaner.

Error Handling

If STATUS.md missing:

❌ Cann

Maintain Jay Dev Cancel Loop?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Jay Dev Cancel Loop on getagentictools](https://getagentictools.com/loops/jayhjenkins-jay-dev-cancel-loop-command?ref=badge)
npx agentictools info loops/jayhjenkins-jay-dev-cancel-loop-command

The second line is the CLI lookup for this page — handy in READMEs and docs.