# Principle encode lessons in structure

> Principle encode lessons in structure is an open-source agent skill for developer tools. Guides the agent to turn repeated corrections into lints, checks or scripts. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/michael-denyer/pstack-claude/tree/main/plugins/pstack/skills/principle-encode-lessons-in-structure
- **Repository:** https://github.com/michael-denyer/pstack-claude
- **GitHub stars:** 5,057
- **License:** MIT
- **Skill name:** principle-encode-lessons-in-structure
- **Collection:** https://github.com/michael-denyer/pstack-claude
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-01

## About

This skill tells the agent to stop answering a recurring correction with another line of instructions. When it notices it is writing the same rule a second time, it should instead move the rule into the project's structure, such as a lint rule, a metadata flag, a runtime check or a script.

The guidance is short and opinionated. If a lesson can be enforced mechanically, the agent should use only the structural fix and treat the written instruction as a symptom. When a lesson depends on judgment and cannot be encoded, the skill says to make the instruction more prominent and include an example of the failure it is meant to prevent.

The skill is a single SKILL.md with a supporting file and no bundled scripts. It is written for the Claude Code plugin marketplace and is not tied to any particular language or toolchain.

## When your agent uses it

> Apply when you catch yourself writing the same instruction a second time, or notice a recurring correction. Encode the rule as a lint, metadata flag, runtime check, or script instead of more text.

## What it can access

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

- [Instructions only, no scripts](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-encode-lessons-in-structure)
- [License: MIT](https://github.com/michael-denyer/pstack-claude/tree/HEAD/plugins/pstack/skills/principle-encode-lessons-in-structure)

## Features

- **Repeated instruction detection:** Triggers when the agent notices it is writing the same guidance again or a correction keeps recurring.
- **Structural enforcement choices:** Points the agent toward lints, metadata flags, runtime checks or scripts instead of more prose.
- **Judgment fallback:** For lessons that cannot be encoded, suggests a more prominent instruction with a failure example.
- **Single-fix rule:** When a structural fix exists, use only that fix rather than layering text on top of it.

## Good for

- Turn a repeated code review comment into a lint rule
- Replace a reminder in project docs with a runtime validation check
- Add a metadata flag so a recurring mistake is caught automatically
- Write a script that enforces a convention the agent keeps forgetting

## Install

### Claude Code

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

```sh
/plugin marketplace add michael-denyer/pstack-claude
/plugin install pstack@pstack-claude
```

Or copy only this skill to `~/.claude/skills/principle-encode-lessons-in-structure`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/principle-encode-lessons-in-structure &&
cp -R "$tmp/plugins/pstack/skills/principle-encode-lessons-in-structure" ~/.claude/skills/principle-encode-lessons-in-structure &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/principle-encode-lessons-in-structure` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/principle-encode-lessons-in-structure` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/principle-encode-lessons-in-structure &&
cp -R "$tmp/plugins/pstack/skills/principle-encode-lessons-in-structure" ~/.agents/skills/principle-encode-lessons-in-structure &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/principle-encode-lessons-in-structure` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/principle-encode-lessons-in-structure` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/principle-encode-lessons-in-structure &&
cp -R "$tmp/plugins/pstack/skills/principle-encode-lessons-in-structure" ~/.cursor/skills/principle-encode-lessons-in-structure &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/principle-encode-lessons-in-structure` 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/michael-denyer/pstack-claude.git --path plugins/pstack/skills/principle-encode-lessons-in-structure
```

Or copy the folder to `~/.gemini/skills/principle-encode-lessons-in-structure` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/principle-encode-lessons-in-structure`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/principle-encode-lessons-in-structure &&
cp -R "$tmp/plugins/pstack/skills/principle-encode-lessons-in-structure" ~/.copilot/skills/principle-encode-lessons-in-structure &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/principle-encode-lessons-in-structure` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/michael-denyer/pstack-claude.git
```

Then copy `pstack-claude/plugins/pstack/skills/principle-encode-lessons-in-structure` into your agent's skills folder as `principle-encode-lessons-in-structure`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Principle encode lessons in structure trigger?

It applies when the agent catches itself writing the same instruction a second time or notices a recurring correction.

### What does Principle encode lessons in structure change in the project?

The skill itself only guides the agent's choice. It asks the agent to encode a repeated rule as a lint, metadata flag, runtime check or script rather than adding more text.

### What if the lesson needs judgment?

The skill says to make the instruction more prominent and add an example of the failure mode, since the rule cannot be encoded.

### How do I install Principle encode lessons in structure in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/principle-encode-lessons-in-structure to use it in all your projects, or to .claude/skills/principle-encode-lessons-in-structure in one project. Or install the pstack plugin, which includes it: /plugin marketplace add michael-denyer/pstack-claude, then /plugin install pstack@pstack-claude.

### Does Principle encode lessons in structure 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 Principle encode lessons in structure?

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 Principle encode lessons in structure?

The closest alternatives to Principle encode lessons in structure are Writing rules, Correct, Principle never block on the human, Rules and Principle fix root causes.

## Where this comes from

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

## Alternatives

- [Writing rules](https://ai-powered.com/skills/writing-rules-xiaolai): Writing rules is an open-source agent skill for developer tools.
- [Correct](https://ai-powered.com/skills/correct): Correct is an open-source agent skill for developer tools.
- [Principle never block on the human](https://ai-powered.com/skills/principle-never-block-on-the-human): Principle never block on the human is an open-source agent skill for developer tools.
- [Rules](https://ai-powered.com/skills/rules-xiaolai): Rules is an open-source agent skill for developer tools.
- [Principle fix root causes](https://ai-powered.com/skills/principle-fix-root-causes): Principle fix root causes is an open-source agent skill for developer tools.
- [Patterns](https://ai-powered.com/skills/patterns-xiaolai): Patterns is an open-source agent skill for developer tools.
- [Principle laziness protocol](https://ai-powered.com/skills/principle-laziness-protocol): Principle laziness protocol is an open-source agent skill for developer tools.
- [Code simplifier](https://ai-powered.com/skills/code-simplifier): Code simplifier is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/principle-encode-lessons-in-structure
