Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .codex/skills/use-patchslim/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: use-patchslim
description: Inspect and minimize committed Git branch diffs with the PatchSlim CLI while preserving protected tests and configured checks. Use when a user asks to shrink a large pull request, remove unnecessary branch changes, test whether diff hunks are required, or review a PatchSlim report.
---

# Use PatchSlim

Verify the installation and repository before minimizing:

```bash
command -v patchslim
patchslim --json doctor
patchslim --json inspect --base main
```

Do not start minimization until the user has identified a feature-specific
oracle. Prefer a targeted check that fails at the base revision and passes at
the branch head.

Run the reducer with layered checks:

```bash
patchslim --json minimize \
--base main \
--oracle "pnpm vitest run path/to/regression.test.ts" \
--quick "pnpm typecheck" \
--gate "pnpm test"
```

After completion:

1. Read the generated JSON report.
2. Inspect the candidate patch.
3. Run `git apply --check <apply.patch>` against the original head.
4. Explain that the result is oracle-backed evidence, not proof of equivalence.

Follow these rules:

- Prefer `--json` for stable output.
- Keep tests, fixtures, migrations, lockfiles, and CI configuration protected
unless the user explicitly changes that boundary.
- Do not apply, commit, push, or open a pull request unless the user asks.
- Do not run PatchSlim against untrusted repository content.
- Stop when the oracle is weak, unstable, or produces an unexpected baseline
result.
4 changes: 4 additions & 0 deletions .codex/skills/use-patchslim/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface:
display_name: "Use PatchSlim"
short_description: "Minimize Git diffs with test-guided checks"
default_prompt: "Use $use-patchslim to inspect and safely minimize this branch diff."
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
check:
name: Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 20
- 22
- 24
steps:
- uses: actions/checkout@v7.0.1
- uses: pnpm/action-setup@v6.0.9
with:
version: 10.34.5
- uses: actions/setup-node@v7.0.0
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm check
3 changes: 3 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"MD013": false
}
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
pnpm-lock.yaml
.patchslim
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Changelog

All notable changes to PatchSlim are documented here.

## 0.1.0 — 2026-07-29

Initial preview release.

### Added

- File-level and hunk-level delta debugging for committed Git branch diffs.
- `doctor`, `init`, `inspect`, `minimize`, and `report` commands with stable
JSON output.
- Merge-base discovery, isolated temporary worktrees, candidate caching, and
bounded command execution.
- Conservative protection for tests, fixtures, snapshots, migrations,
documentation, CI, manifests, lockfiles, PatchSlim configuration, and Git
control files.
- Head-pass/protected-base-fail preflight with repeated instability checks.
- Quick candidate gates, repeated final oracles, and full validation gates.
- `apply.patch`, `candidate.patch`, JSON reports, and Markdown reports.

### Safety

- Rejects weak or unstable oracles, red head gates, dirty setup output,
candidate materialization failures, timeouts, and interruptions.
- Reconstructs every command stage from the merge base and clears ignored
side effects between stages.
- Never applies a candidate to the current checkout automatically.

### Verified

- JavaScript and Python fixtures.
- Text hunks, added files, binary diffs, renames, mode changes, paths with
spaces, and Unicode paths.
- Exact application of `apply.patch` to the original head.
- Node.js 20, 22, and 24, package linting, clean production dependency audit,
and GitHub Actions.
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contributing

Thanks for taking the time to improve PatchSlim.

## Development setup

PatchSlim requires Node.js 20 or newer and pnpm.

```bash
pnpm install
pnpm check
```

Keep pull requests focused. Include tests for behavior changes and explain any
change to candidate construction, protection rules, or command execution.

## Safety invariants

Changes to the reducer must preserve these guarantees:

- the user's current checkout is never reset or cleaned;
- candidate evaluation happens in a temporary worktree;
- protected changes remain in every candidate;
- minimization stops when the full branch fails or the protected-only baseline
passes;
- a candidate is never applied automatically;
- command output remains bounded and machine-readable output remains stable.

Use temporary repositories in tests for Git behavior. Tests must not rely on a
developer's global Git configuration or modify repositories outside their own
temporary directory.

## Commit and pull request style

Write short, imperative commit subjects. In the pull request, describe the
observable behavior, the checks you ran, and any known limitation.
Loading