Skip to content
Back to skills

Dhpk Opsx Load Context

ASecurity

Load opsx-apply-resume Resume Phase context via a 3-tier fallback (claude-mem pinned obs → compact JSON → handoff summary), optionally fetching cross-session observations. Use when: opsx-apply-resume enters Resume Phase Steps 1b–1d. Not for: saving observations (use dhpk-opsx-post-observation) or goal generation. Output: CONTEXT_SOURCE + session_goal/completed/in_progress/cross_session_observations fields.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 2, 2026
ai-agentsgobashrails

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned October 6, 2026

npx -y skills add hmj1026/dhpk --skill dhpk-opsx-load-context --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dhpk Opsx Load Context?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dhpk Opsx Load Context
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hmj1026-dhpk-opsx-load-context-dhpk/badge)](https://www.skillsdirectory.com/skills/hmj1026-dhpk-opsx-load-context-dhpk)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: dhpk-opsx-load-context
description: 'Load opsx-apply-resume Resume Phase context via a 3-tier fallback (claude-mem pinned obs → compact JSON → handoff summary), optionally fetching cross-session observations. Use when: opsx-apply-resume enters Resume Phase Steps 1b–1d. Not for: saving observations (use dhpk-opsx-post-observation) or goal generation. Output: CONTEXT_SOURCE + session_goal/completed/in_progress/cross_session_observations fields.'
allowed-tools: Bash
metadata:
  dhpk-invocation-class: implicit-eligible
---

# opsx-load-context

Context loading skill for `opsx-apply-resume` Resume Phase.
Uses a 3-tier fallback; a valid handoff is required for the final tier, and a missing handoff is reported unavailable.
`$SKILL_DIR` denotes the physical directory containing the selected `SKILL.md`; it is path notation,
not an ambient environment variable or repository-root lookup. Keep the consumer's cwd as task context.

## When NOT to Use

- Saving / posting a session observation → use `dhpk-opsx-post-observation`
- Generating a condition for a fresh unattended session.
- Any phase other than `opsx-apply-resume` Resume Phase (Steps 1b–1d)

## Inputs

| Variable | Source | Description |
|----------|--------|-------------|
| `claude_mem_obs_id` | Handoff frontmatter | Integer obs ID, or null / absent |
| `compact_json_path` | Handoff frontmatter | Relative path like `compact-notes/compact-*.json`, or absent |
| `next_action_hint` | First Next Action from handoff | Key terms for cross-session search; may be empty |
| `handoff_path` | Host adapter | Explicit handoff file; defaults to `.claude/artifacts/apply-resume/latest.md` |

## Fallback Chain

Work through tiers in order. Stop at the first successful tier and record `CONTEXT_SOURCE`.

---

### Pre-chain — Hard-rule escalation (highest priority — blocking human decision)

**Condition**: An active change carries a `.hard-rule-escalation.md` written by
a previous unattended session because implementation hit an explicit hard-rule
conflict that could not be resolved without human input. Check this before
routine carry-forward such as `.resume-note.md`.

```bash
ESCALATION=$(ls -t openspec/changes/*/.hard-rule-escalation.md 2>/dev/null | head -1)
```

- File found → read it and surface it as a blocking human decision. Set
  `CONTEXT_SOURCE = ".hard-rule-escalation.md"`. Do not fold it into ordinary
  `session_goal` / `in_progress` resume context, and do not continue the goal
  loop until the human explicitly decides how to resolve the rule conflict.
- No file (the common case) → fall through to the unattended stop resume note.

Best-effort only: a malformed or unreadable escalation still blocks; report its path and ask the human to inspect it.

---

### Pre-chain — Unattended stop resume note (checked after hard-rule escalation)

**Condition**: An active change carries a `.resume-note.md` (written by
a previous unattended session when it hit its turn or wall-clock
limit). Check this before the tiers below — it is the freshest, most specific
carry-forward for a resumed run.

```bash
RESUME=$(ls -t openspec/changes/*/.resume-note.md 2>/dev/null | head -1)
```

- File found → read it; extract the remaining unchecked tasks, any unfixed
  CRITICAL reviewer finding, and the one-line next-focus
  hint. Map them to `in_progress` and
  `session_goal`. Set `CONTEXT_SOURCE = ".resume-note.md"`. Skip Tiers 0–2 (still
  run the optional cross-session step below).
- No file (the common case) → fall through to Tier 0. Behavior unchanged.

Best-effort only: a malformed or unreadable note silently falls through.

---

### Tier 0 — Claude-mem pinned observation

**Condition**: `claude_mem_obs_id` is present and not null.

```
get_observations(ids=[<claude_mem_obs_id>])
```

- Returns observation → extract `session_goal`, `completed`, `in_progress` from the observation body.
  Set `CONTEXT_SOURCE = "claude-mem obs #<id>"`. Skip Tier 1.
- Returns empty or error → fall through to Tier 1.

---

### Tier 1 — Compact JSON

**Condition**: a compact-notes JSON exists — either the explicit
`compact_json_path` from handoff frontmatter, or the newest one on disk.

Read `references/extractor-resolution.md` when Tier 1 is used. Invoke the local
`"$SKILL_DIR/scripts/extract-compact.sh"`; if it is missing, report `BLOCKED_RESOURCE_MISSING` and
continue to Tier 2; never search a plugin root, source checkout, consumer `.claude` directory, or peer Skill.

- Script outputs fields → parse L0, session_goal, completed, in_progress.
  Set `CONTEXT_SOURCE = "compact JSON"` — append `(heuristic)` when `$COMPACT`
  came from the glob fallback rather than the handoff path. Skip Tier 2.
- No compact file, or the script errors → fall through to Tier 2.

---

### Tier 2 — Handoff embedded summary

**Condition**: `handoff_path` exists and is readable. Use its `## Compact Summary`,
`### Completed`, and `### In Progress` sections (already read in Resume Phase Step 1).

Set `CONTEXT_SOURCE = "handoff only"`.

If `handoff_path` is missing or unreadable, set `CONTEXT_SOURCE = "handoff unavailable"`, leave
fields empty or `(未取得)`, and surface `BLOCKED_RESOURCE_MISSING` with the path.

---

## Post-chain: Cross-session context (optional)

**Condition**: fallback chain has completed (any tier set `CONTEXT_SOURCE`) AND `next_action_hint` is non-empty.

```
search(
  query="<next_action_hint — key terms only, 3–6 words>",
  project="<your-project>",
  obs_type="decision,discovery",  # decision/discovery 類型最能反映跨 session 決策脈絡
  limit=5                          # 上限 5 筆避免 context 膨脹
)
```

- Relevant results → `get_observations(ids=[<up to 3 IDs>])` → store as `cross_session_observations`.
- No relevant results or search fails → set `cross_session_observations = []`. Silently skip.
---

## Output

| Variable | Type | Description |
|----------|------|-------------|
| `CONTEXT_SOURCE` | string | One of: ".hard-rule-escalation.md", ".resume-note.md", "claude-mem obs #N", "compact JSON", "compact JSON (heuristic)", "handoff only", "handoff unavailable" |
| `session_goal` | string | Goal from context, or "(未取得)" |
| `completed` | list | Completed items, or empty list |
| `in_progress` | list | In-progress items, or empty list |
| `cross_session_observations` | list | Up to 3 fetched observations, or empty list |

All variables always set — no undefined outputs. The caller (Resume Phase Step 3) uses these fields directly in the restore summary display.

## Verification

- [ ] `CONTEXT_SOURCE` set to exactly one tier label
- [ ] Pre-chain `.hard-rule-escalation.md` checked before `.resume-note.md`; both absent → falls through silently to Tier 0
- [ ] Stopped at the first successful tier (no redundant lower-tier calls)
- [ ] All return fields set — no undefined outputs (missing handoff returns an unavailable diagnostic)
- [ ] Cross-session search failure handled silently (`cross_session_observations = []`)

## Guardrails

- Never throw on partial failure — always complete the chain and return `CONTEXT_SOURCE`
- "compact JSON (heuristic)" is acceptable quality; note in Step 3 display that it is a heuristic path
- Cross-session search failure is silent — the resume can proceed without it
- If all tiers fail, set `CONTEXT_SOURCE = "handoff unavailable"`, use empty strings for context fields, and preserve the blocking diagnostic instead of claiming success

Files in this skill

  • SKILL.md7 KB
  • references/extractor-resolution.md953 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.