LidGuard: Skill for Claude Code

.codex/skills/lidguard-session-runtime/SKILL.md

lidguard-session-runtime is a skill for Claude Code, Codex from airtaxi/LidGuard. It costs 50 tokens per session (2,789 once invoked), scanned A, original, MIT.

A reference for managing the runtime life cycle of LidGuard sessions, including inactivity rules, transcript monitoring, process exits, cleanup, and session-end notifications. LidGuard is a utility for managing local AI coding-agent sessions.

In plain words
What is it for?
Use it when implementing or checking session timeouts, soft locks, process watchers, transcript activity tracking, cleanup, watchdogs, or session-end webhooks.
Why use it?
It explains how to handle missed stop events, inactive sessions, watched agent processes, and leftover processes or data.

Skill for Claude CodeCodex

Written for Claude Code and Codex: UserPromptSubmit hook event, but also agents/openai.yaml present. Also seen: reads .claude/ paths; mentions Claude Code; mentions Codex.

This is airtaxi/LidGuard's own configuration. It tells Claude Code and Codex how to work on LidGuard itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything LidGuard configures →

Reuse

Borrowing it

Nothing to install: this file belongs to airtaxi/LidGuard. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/airtaxi/LidGuard/master/.codex/skills/lidguard-session-runtime/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/airtaxi/LidGuard

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for lidguard-session-runtime

README.md
[![agentmods](https://agentmods.dev/badge/skills/airtaxi/lidguard/lidguard-session-runtime/github.svg)](https://agentmods.dev/skills/airtaxi/lidguard/lidguard-session-runtime)
Your own site
<a href="https://agentmods.dev/skills/airtaxi/lidguard/lidguard-session-runtime"><img src="https://agentmods.dev/badge/skills/airtaxi/lidguard/lidguard-session-runtime/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for lidguard-session-runtime

Your own site · 80×15
<a href="https://agentmods.dev/skills/airtaxi/lidguard/lidguard-session-runtime"><img src="https://agentmods.dev/badge/skills/airtaxi/lidguard/lidguard-session-runtime.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,789 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00050 $0.02789
Opus 5 $0.00025 $0.01394
Sonnet 5 $0.00010 $0.00558
Haiku 4.5 $0.00005 $0.00279

Measured 6d ago against content hash 387ecc0ade94, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

lidguard-session-runtime scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.codex/skills/lidguard-session-runtime/SKILL.md · 86 lines

How it starts

The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LidGuard Session Runtime

Process Exit Watcher

Hook stop events may be missed, so LidGuard also watches the agent process.

  • Prefer a provided parent process id when hooks can supply one.
  • Managed Codex, Claude Code, GitHub Copilot CLI, and OpenCode hooks should resolve a watched process id from the hook process ancestry on their start events when WatchParentProcess is enabled.
  • Working directory must not be used to auto-resolve watched processes. Keep it only for status, logs, transcript fallback, and webhook payload metadata.
  • If neither an explicit parent process id nor a hook ancestry owner process id is available, start or update the session with process=none.
  • On Windows, open the target process with synchronize/query rights and wait with WaitForSingleObject.
  • On Windows, read hook process ancestry with CsWin32/WDK NtQueryInformationProcess(ProcessBasicInformation).
  • On Linux, read hook process ancestry with /proc/<pid>/stat, /proc/<pid>/comm, and /proc/<pid>/cmdline.
  • On macOS, read hook process ancestry from ps -axo pid=,ppid=,comm=,command=.
  • On Linux and macOS, use Process.GetProcessById().WaitForExitAsync() for process exit watching.
  • Treat the first cleanup signal as authoritative; later stop/watchdog events for the same session should be harmless.
  • If a provider launches a short-lived wrapper that exits before the real agent, prefer provider-specific process selection rather than broadening the generic resolver.
  • Watched parent process exit and orphan cleanup are cancel cleanup paths, not provider-reported normal session ends. They must suppress PostSessionEnd and any new PreSuspend webhook they would otherwise schedule, while preserving any pending suspend that was already scheduled or running.

Active Session Policy

  • Keep session state ref-counted by active session.
  • Attach provider name to AgentProvider.Mcp sessions so multiple MCP-backed providers can reuse the same session identifier without colliding.
  • Track last activity timestamp, soft-lock state, soft-lock reason, and soft-lock timestamp per session.
  • Keep shared platform keep-awake protection alive only while at least one active session is not soft-locked.
  • When all remaining active sessions are soft-locked, treat the runtime as suspend-eligible even before those sessions emit stop events.
  • Refresh a session's last activity timestamp on start/update and provider activity such as new tool execution.
  • Clear that session's current soft-lock state on provider activity.
  • Do not refresh last activity when setting a soft-lock; soft-locking represents waiting rather than autonomous work.
  • Closed-lid PermissionRequest decision Ask marks the current provider session soft-locked with reason closed_lid_permission_request_ask; it is cleared by the same provider activity, transcript activity, start/update, stop/remove, or cleanup paths as other soft-locks.
  • When a session reaches the configured inactive session timeout, transition it to soft-locked with reason metadata and apply the same suspend-eligibility handling as other soft-locked sessions.
  • Pending provider work is not an unconditional exemption from the inactive session timeout. Deferred stops refresh the session's last activity, so still-live background work keeps renewing the timeout window. A session whose pending work shows no provider activity for the configured timeout is treated as abandoned: clear the pending work flag, log session-pending-provider-work-abandoned, and route the session through the same timeout soft-locking path. A soft-locked session with pending work must also stay in the timeout timer so a lost completion notification can be abandoned the same way. Later provider activity from work that was abandoned in error resumes the session through the normal activity paths. Turning the inactive session timeout off (SessionTimeoutMinutes = off) disables this abandonment entirely, since no timeout monitor runs.
  • Do not auto-resolve watched processes from the working directory for any provider.
  • Preserve an existing watched process for the same active session when a later start/update does not provide a new watched process id and WatchParentProcess is still enabled.
  • Provider hook ancestry owner detection should accept Codex CLI, Codex App app-server, Claude Code CLI/wrappers, GitHub Copilot CLI, gh ... copilot, OpenCode CLI, and provider-specific bun/node/npm/npx wrappers.
  • Back up optional lid action changes once to pending JSON, preserve any existing pending JSON, and restore only from that JSON after the last active session stops.
  • While shared protection remains applied and the lid is closed, keep the Emergency Hibernation thermal monitor polling every 10 seconds and stop it automatically once protection is restored or disabled.
  • Keep multiple stop signals for the same session from causing repeated cleanup side effects.
  • Ask-before-sleep reply waiting reuses the pending suspend path: keep blocking-capable Stop hooks blocked only while the pending suspend cancellation token remains active. Wait through postStopSuspendDelaySeconds before sending the follow-up webhook so immediately-following prompts can arrive first, then wait up to closedLidStopFollowUpDelaySeconds for the initial reply deadline. The notification dashboard may extend that deadline up to 5 minutes beyond the initial deadline, and managed provider hook timeout must be postStopSuspendDelaySeconds + closedLidStopFollowUpDelaySeconds + 5 minutes so blocking-capable provider hooks remain alive for the whole supported extension window. Poll responses include the current expiresAtUtc; the runtime must trust that value and continue waiting up to it. When a reply arrives, restore the session as active instead of treating the provider stop as final cleanup. With RepeatClosedLidStopFollowUp=true, later Stop hooks from the continued work may ask again without a fixed repeat limit. With RepeatClosedLidStopFollowUp=false, the continued Stop must not wait through postStopSuspendDelaySeconds again; it should proceed as an immediate suspend attempt. When the notification server returns Canceled, stop waiting and reschedule the existing stop/suspend path with a 0 second delay.
  • OpenCode differs from blocking-capable Stop hooks: the managed plugin waits after session.idle, consumes the continuation stdout, and sends the reply back into the same session with client.session.prompt(). This simulates the same user experience but depends on OpenCode still having the session available.
  • If closedLidStopFollowUpSound is configured, play it once after the follow-up webhook start succeeds and the poll URL is valid, before polling starts. Log playback or volume override failures and keep waiting for replies.

Read the full file on GitHub · 86 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago Changed · +1 lines 387ecc0ade94
  2. 10d ago First seen · 85 lines · 50 tokens per session scan A dba7fa412888

Subscribe to this mod's changes

lidguard-session-runtime is a skill published in the GitHub repository airtaxi/LidGuard (11 stars, last pushed 2d ago), licensed MIT. It adds 50 tokens to every session and 2,789 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories