# Session hardening

> Session hardening is an open-source agent skill for developer tools. Guards agent sessions with pretool blocks, periodic test runs and startup context. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/0xNyk/lacp/tree/main/plugin/skills/session-hardening
- **Repository:** https://github.com/0xnyk/lacp
- **GitHub stars:** 311
- **License:** MIT
- **Skill name:** session-hardening
- **Collection:** https://github.com/0xNyk/lacp
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-02

## About

This skill adds a set of safety and quality hooks to an AI coding agent session. A pretool guard inspects commands before they run and blocks or redirects risky ones, such as recursive deletes, unapproved package publishing, piping downloads straight into an interpreter, broad file permissions, hard git resets and uploading local env files. A continuous QA hook detects the project's test command from common manifest files like package.json, Makefile, Cargo.toml or pyproject.toml and runs it every N file writes, feeding failures back to the agent without stopping it.

At session start, a context hook gathers the current git branch, recent commits and modified files, along with a focus brief and any handoff notes left by a previous session. Behaviour is tuned through environment variables: continuous QA is off by default and is enabled with a flag, the write interval defaults to 10, and a context mode can be set for workflows such as TDD or debugging.

The skill is delivered as a Claude Code plugin from the lacp-plugins marketplace and relies on Claude Code hooks to activate automatically, so it is not a manual instruction file. The folder ships a single SKILL.md with no scripts listed in the facts provided.

## When your agent uses it

> Production hardening for agent sessions. Includes pretool guards (blocks rm -rf, co-author injection, publishing without approval, data exfiltration), continuous QA (runs tests every N file writes), and session context injection (git state, focus brief, handoff artifacts). Activates automatically via hooks.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/0xNyk/lacp/tree/HEAD/plugin/skills/session-hardening)
- [License: MIT](https://github.com/0xNyk/lacp/tree/HEAD/plugin/skills/session-hardening)

## Features

- **Pretool command guard:** Blocks or redirects destructive shell commands, unapproved publishing and suspicious data transfers before they execute.
- **Continuous test runs:** Runs the detected project test command every set number of file writes and reports failures back to the agent.
- **Session context injection:** Adds git state, recent commits, modified files and a focus brief when a session starts.
- **Handoff artifact loading:** Brings in handoff notes from the previous session so work can resume with prior context.
- **Configurable via environment variables:** Lets users toggle continuous QA, set the test interval and choose a context mode.

## Good for

- Stop the agent from running rm -rf or chmod 777 on project files
- Run the test suite automatically every few edits during a feature build
- Resume yesterday's work with git state and a handoff summary at session start
- Prevent accidental pushes to main on a public repository

## Install

### Claude Code

This skill ships in the `lacp-hardening` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add 0xNyk/lacp
/plugin install lacp-hardening@lacp-plugins
```

Or copy only this skill to `~/.claude/skills/session-hardening`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/0xNyk/lacp.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/session-hardening &&
cp -R "$tmp/plugin/skills/session-hardening" ~/.claude/skills/session-hardening &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/session-hardening` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/session-hardening` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/0xNyk/lacp.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/session-hardening &&
cp -R "$tmp/plugin/skills/session-hardening" ~/.agents/skills/session-hardening &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/session-hardening` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/session-hardening` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/0xNyk/lacp.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/session-hardening &&
cp -R "$tmp/plugin/skills/session-hardening" ~/.cursor/skills/session-hardening &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/session-hardening` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/0xNyk/lacp.git --path plugin/skills/session-hardening
```

Or copy the folder to `~/.gemini/skills/session-hardening` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/session-hardening`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/0xNyk/lacp.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/session-hardening &&
cp -R "$tmp/plugin/skills/session-hardening" ~/.copilot/skills/session-hardening &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/session-hardening` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/0xNyk/lacp.git
```

Then copy `lacp/plugin/skills/session-hardening` into your agent's skills folder as `session-hardening`. Agents that support SKILL.md read one folder per skill.

## FAQ

### How does Session hardening activate?

It activates automatically through hooks in the Claude Code plugin, rather than when a task matches a description.

### Are continuous tests on by default?

No. The LACP_EVAL_CHECKPOINT_ENABLED variable defaults to 0 and must be set to enable continuous QA; the interval defaults to every 10 writes.

### Which test runners does Session hardening detect?

It looks for the test command in package.json, Makefile, Cargo.toml and pyproject.toml.

### Does a failing test block the agent?

No. According to the content, failure feedback is injected without blocking the agent.

### How do I install Session hardening in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/session-hardening to use it in all your projects, or to .claude/skills/session-hardening in one project. Or install the lacp-hardening plugin, which includes it: /plugin marketplace add 0xNyk/lacp, then /plugin install lacp-hardening@lacp-plugins.

### Does Session hardening run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Session hardening?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Session hardening?

The closest alternatives to Session hardening are Safe execution edho ferdian, Guardrail tester, Scan sessions and learn, Autonomous agent harness and Vibe pre commit audit.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Safe execution edho ferdian](https://ai-powered.com/skills/safe-execution-edho-ferdian): Safe execution edho ferdian is an open-source agent skill for developer tools.
- [Guardrail tester](https://ai-powered.com/skills/guardrail-tester): Guardrail tester is an open-source agent skill for security.
- [Scan sessions and learn](https://ai-powered.com/skills/scan-sessions-and-learn): Scan sessions and learn is an open-source agent skill for developer tools.
- [Autonomous agent harness](https://ai-powered.com/skills/autonomous-agent-harness): Autonomous agent harness is an open-source agent skill for developer tools.
- [Vibe pre commit audit](https://ai-powered.com/skills/vibe-pre-commit-audit): Vibe pre commit audit is an open-source agent skill for security.
- [Quality gate](https://ai-powered.com/skills/quality-gate): Quality gate is an open-source agent skill for developer tools.
- [Speclock guardrails](https://ai-powered.com/skills/speclock-guardrails-sgroy10): Speclock guardrails is an open-source agent skill for security.
- [Agentic os](https://ai-powered.com/skills/agentic-os-smartworldarafath): Agentic os is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/session-hardening
