Xpersona
D

damage-control

CLAWHUB · Unverified

Recovers broken agent state via crash recovery, context overflow, and merge conflict protocols

62
Rank
84
Safety
1.6k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.6K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17emme0e2m3cpf7k2jvp3a84984b8z9:nm-leyline-damage-control
  1. Install using `clawhub skill install s17emme0e2m3cpf7k2jvp3a84984b8z9:nm-leyline-damage-control` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/athola/nm-leyline-damage-control before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-athola-nm-leyline-damage-control/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

145,661 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: damage-control
description: |
  Recovers broken agent state via crash recovery, context overflow, and merge conflict protocols
version: 1.9.8
triggers:
  - recovery
  - resilience
  - crash
  - context
  - conflicts
  - state
  - an agent session fails or a worktree is corrupted
metadata: {"openclaw": {"homepage": "https://github.com/athola/claude-night-market/tree/master/plugins/leyline", "emoji": "\ud83e\udd9e", "requires": {"config": ["night-market.error-patterns"]}}}
source: claude-night-market
source_plugin: leyline
---

> **Night Market Skill** — ported from [claude-night-market/leyline](https://github.com/athola/claude-night-market/tree/master/plugins/leyline). For the full experience with agents, hooks, and commands, install the Claude Code plugin.


## Table of Contents

- [Overview](#overview)
- [When To Use](#when-to-use)
- [When NOT To Use](#when-not-to-use)
- [Damage Triage](#damage-triage)
- [Module Reference](#module-reference)
- [Integration Pattern](#integration-pattern)
- [Exit Criteria](#exit-criteria)


# Damage Control

## Overview

Provides recovery protocols for agents that encounter broken
state mid-session. Damage control covers four failure classes:
agent crashes with partial work on disk, context window overflow
that causes state loss, merge conflicts blocking forward progress,
and general session state corruption requiring reconciliation.

The skill does not prevent failures. It defines what to do after
one has already happened, so recovery is consistent, auditable,
and does not silently discard work.

## When To Use

- An agent process crashed and left files in an unknown state
- A session hit the context limit and cannot load prior decisions
- `git merge` or `git rebase` produced conflicts the agent cannot
  resolve automatically
- Observed state (files on disk, task list, git index) disagrees
  with expected state
- A downstream agent reports missing artifacts that should have
  been produced upstream

## When NOT to Use

- Proactive risk assessment before work starts (use
  `Skill(leyline:risk-classification)` instead)
- Strategic architectural decisions after a failure (use
  `Skill(attune:war-room)` instead)
- Routine error handling within a single tool call (use
  `Skill(leyline:error-patterns)` instead)

## Damage Triage

Use this decision tree to route to the correct module:

```mermaid
flowchart TD
    A[Failure detected] --> B{Agent process crashed\nor exited unexpectedly?}
    B -->|Yes| C[modules/crash-recovery.md]
    B -->|No| D{Context limit hit or\nprior decisions unavailable?}
    D -->|Yes| E[modules/context-overflow.md]
    D -->|No| F{git merge / rebase /\ncherry-pick conflicts?}
    F -->|Yes| G[modules/merge-conflict-resolution.md]
    F -->|No| H{State internally inconsistent?\ntask list vs disk vs git index}
    H -->|Yes| I[modules/state-reconciliation.md]
    H -->|No| J[No damage-control needed]
```

When multiple failure types overlap, start with
`state-reconciliation.md` to estab

_meta.json

{
  "ownerId": "kn7d107jg9jv602h9ytsegydq184a42s",
  "slug": "nm-leyline-damage-control",
  "version": "1.9.19",
  "publishedAt": 1787750057687
}

modules/context-overflow.md

---
name: context-overflow
description: >
  Procedures for reconstructing decision context when the
  agent context window is exhausted mid-session. Covers
  handoff summaries, task list as ground truth, and safe
  continuation without replaying lost context.
parent_skill: leyline:damage-control
category: infrastructure
estimated_tokens: 260
---

# Context Overflow

## When This Module Applies

Use this module when the context window is near or at its limit
and the agent can no longer reliably recall earlier decisions,
completed steps, or the rationale behind current state.
Symptoms:

- Agent references a decision it cannot locate in the current
  window
- Agent re-does work already done in the same session
- Earlier tool call results are no longer visible
- The session produces contradictory outputs (second half
  disagrees with first half)

## Why Context Overflow Is Dangerous

Unlike a crash, context overflow produces no error. The agent
continues running but loses access to prior context. It may:

- Re-implement work already completed, creating duplicates
- Make decisions that contradict earlier reasoning
- Omit dependencies established in the now-invisible portion
- Silently discard constraints agreed on with the user

## Recovery Protocol

### Step 1: Stop and checkpoint

Before taking any further actions, write the current known
state to a durable anchor. The task list is the primary
anchor: it is outside the context window and survives session
boundaries.

For each task currently `in_progress`:

1. Record the last completed step in the task description
2. List any decisions made that affect downstream tasks
3. List any constraints or agreed deviations from the plan

### Step 2: Establish ground truth from durable sources

Context is gone. Recover state from sources that are not
inside the window:

| Source | What it tells you |
|---|---|
| Task list | Which tasks are done, in progress, or pending |
| `git log --oneline -20` | What was committed and when |
| `git diff HEAD` | Uncommitted work in progress |
| `git status` | Staged vs. unstaged state |
| Test results | Whether the last committed state is valid |

Do not trust the agent's recall of anything not confirmed by
one of these sources.

### Step 3: Summarize for continuation

Before ending the session or handing off to a new agent,
write a handoff summary. Place it as a comment in the task
description or in a temporary scratch note that the next
agent can read at session start:

```
## Handoff Summary — [timestamp]

### Completed this session
- [task IDs and one-line description of what was done]

### Decisions made (not yet committed anywhere)
- [decision: rationale]

### In-progress state
- Task T042: completed steps 1-3; step 4 (write tests) not yet started
- Files modified but not committed: src/auth/token.py

### Constraints to carry forward
- [any deviations agreed with human, constraints on implementation]

### Recommended next action
- Resume T042 at step 4
```

### Step 4: 

modules/crash-recovery.md

---
name: crash-recovery
description: >
  Triage, checkpoint inspection, and safe resume or rollback
  after an agent process crash. Covers partial writes, unknown
  git index state, and re-entry into an interrupted task.
parent_skill: leyline:damage-control
category: infrastructure
estimated_tokens: 280
---

# Crash Recovery

## When This Module Applies

Use this module when an agent process exited unexpectedly
mid-task: the shell died, a timeout fired, or an unhandled
exception terminated the agent before it could report status.
Signs of a crash:

- A task is marked `in_progress` but no agent is running
- Files on disk differ from the last known checkpoint
- The git index contains staged changes with no corresponding
  commit or stash

Do not use this module for context limit exhaustion (see
`context-overflow.md`) or for git conflicts introduced during a
merge (see `merge-conflict-resolution.md`).

## Triage Steps

### Step 1: Identify the scope

```
git status          # staged vs unstaged changes
git diff HEAD       # total delta from last commit
git stash list      # any stashes from prior sessions
```

Classify what you find:

| Observation | Action |
|---|---|
| Clean index, no changes | Task never started — restart normally |
| Only unstaged changes | Safe to inspect and resume |
| Staged and unstaged mix | Stash before any further work |
| Merge in progress | Switch to merge-conflict-resolution.md |

### Step 2: Inspect the task list

Check the task list for the crashed task:

- If `in_progress`: the task was running at crash time.
  Determine its last known completed step before deciding to
  resume or restart.
- If `pending`: the task had not yet started. No recovery
  needed; assign normally.
- If `completed`: the task completed before the crash. No
  action required.

### Step 3: Verify artifact integrity

For each file the task was supposed to produce or modify:

```
git diff HEAD -- <file>        # what changed since last commit
git show HEAD:<file>           # last committed version
```

If the current version of the file is internally consistent
(parses, tests pass for that file), the partial write is safe
to keep and the task can resume from the last completed step.

If the file is corrupt or partially written, recover from
git history rather than using destructive restore commands:

```
git show HEAD:<file> > <file>.recovered   # extract last committed version
git diff HEAD -- <file>                   # review what changed
# Compare <file> with <file>.recovered to salvage valid work
# Then replace <file> with the corrected version
rm <file>.recovered
```

Never use `git checkout -- <file>` as it discards work
irreversibly. Always inspect the diff first so partial
progress can be preserved.

### Step 4: Decide: resume or restart

Resume when:

- The crashed task has a clear last completed step
- All files the task touched are internally consistent
- No downstream tasks have already consumed the partial output

Restart when:

- T

modules/merge-conflict-resolution.md

---
name: merge-conflict-resolution
description: >
  Classification and resolution strategies for git merge,
  rebase, and cherry-pick conflicts. Covers auto-resolvable
  patterns, agent-resolvable patterns, and escalation to
  human review for conflicts that require judgment.
parent_skill: leyline:damage-control
category: infrastructure
estimated_tokens: 300
---

# Merge Conflict Resolution

## When This Module Applies

Use this module when a `git merge`, `git rebase`, or
`git cherry-pick` produces conflicts (conflict markers appear
in files, `git status` shows `UU` or `AA` entries). Also use
it when an agent detects that two in-progress tasks have
modified the same file and their changes cannot be trivially
combined.

## Conflict Classification

Before attempting resolution, classify the conflict:

### Class A: Formatting or whitespace only

Both sides changed the same lines for non-semantic reasons
(whitespace, import sort order, trailing comma). The
conflict is safe to resolve by applying the later change.

**Resolution**: Take the current branch version or apply a
formatter and accept all.

### Class B: Independent additions to the same region

Both sides added new content to the same location (e.g., two
agents added separate functions to the same file, or two
migrations added separate fields). The changes do not
overlap semantically.

**Resolution**: Manually interleave both additions, preserving
both sets of content. Verify no naming collisions.

### Class C: Competing modifications to the same logic

Both sides changed the same lines with different semantics.
One or both changes must be partially discarded or combined
by someone who understands the intent of each.

**Resolution**: Escalate to human review. Do not guess at
intent. See the Escalation Protocol below.

### Class D: Deleted vs. modified

One side deleted a file or function; the other modified it.

**Resolution**: Escalate to human review. The delete may be
intentional (the other branch's modification is stale) or
erroneous (the file should not have been deleted).

## Resolution Procedure

### Step 1: List all conflicted files

```
git status | grep -E "^(UU|AA|DD|DU|UD|AU|UA)"
```

Or use the short form:

```
git diff --name-only --diff-filter=U
```

### Step 2: Classify each conflict

For each conflicted file, identify which class applies.
Record the classification before touching the file.

### Step 3: Resolve Class A and Class B conflicts

Class A:

```
# Accept current branch (ours)
git restore --ours <file> && git add <file>

# Or accept incoming (theirs)
git restore --theirs <file> && git add <file>

# Or run formatter and accept
<formatter> <file> && git add <file>
```

Use `git restore` instead of `git checkout` for file-level
operations. The `restore` command is scoped to working tree
changes and cannot accidentally switch branches.

Class B: Edit the file manually to include both additions,
then:

```
git add <file>
```

After resolving, run the test suite for the af

Sponsored

Ads related to damage-control and adjacent AI workflows.