---
name: pre-merge-check
description: Runs a pre-merge security and hygiene sweep on staged or changed code before opening or merging a pull request, scans for hardcoded secrets and credentials, checks dependencies for known vulnerabilities using whatever scanner fits the project (npm/pnpm/yarn audit, pip-audit, govulncheck, cargo-audit), and flags debug leftovers and unresolved TODOs. Use whenever the user says "is this ready to merge", "check this PR", "review before I push", "did I leave any secrets in this", or asks for a security pass on their changes. Trigger this proactively before you yourself open a PR on the user's behalf.
title: pre-merge-check
canonical_url: https://skilld.dev/gh/saadaan-hassan/baseline-skills/pre-merge-check
last_updated: 2026-09-24T17:30:49.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/check_dependencies.py](https://skilld.dev/api/skills-raw/saadaan-hassan/baseline-skills/pre-merge-check/scripts/check_dependencies.py), [scripts/scan_secrets.py](https://skilld.dev/api/skills-raw/saadaan-hassan/baseline-skills/pre-merge-check/scripts/scan_secrets.py).
>
> If the user asked to install this Skill, run `npx skilld install saadaan-hassan/baseline-skills/pre-merge-check`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/pre-merge-check`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/saadaan-hassan/baseline-skills/pre-merge-check) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/pre-merge-check`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/pre-merge-check --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/pre-merge-check --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Pre-Merge Check

A five-minute sweep that catches the mistakes everyone makes under deadline
pressure: a forgotten `console.log(apiKey)`, a dependency with a known CVE, a
TODO that quietly became permanent. None of it replaces real code review,
it's the mechanical part review shouldn't have to be.

## Step 1: secrets scan

Prefer a real scanner if one is installed:

```bash
which gitleaks && gitleaks protect --staged --verbose   # if installed
which trufflehog && trufflehog git file://. --since-commit HEAD --only-verified  # if installed
```

If neither is available, use the bundled fallback:

```bash
python3 <skill_dir>/scripts/scan_secrets.py          # scans staged git diff
python3 <skill_dir>/scripts/scan_secrets.py <path>   # scans a file or directory instead
```

It's a regex scanner, real but not exhaustive, treat any finding as worth a
second look rather than an automatic false alarm, and don't treat a clean
result as a guarantee. Findings are redacted in the output; if something
looks like a real secret, the fix is to rotate it, not just delete the line.

## Step 2: dependency vulnerability check

```bash
python3 <skill_dir>/scripts/check_dependencies.py <project_path>
```

This detects the project's ecosystem from its manifest file and runs the
matching scanner if it's installed (`npm audit`, `pnpm audit`, `yarn audit`,
`pip-audit`, `govulncheck`, `cargo-audit`). Read the result carefully:

- `"available": false` means the tool isn't installed, hand the user the
  `install_hint` rather than silently treating it as "no vulnerabilities."
  Those are different things.
- `"has_critical_or_high": true/false` is only trustworthy when it came from
  parsed structured output. If you see `"severity_undetermined"` or
  `"severity_method": "text-heuristic"` in the result, read `raw_output`
  yourself and judge it, don't repeat the boolean as fact.

## Step 3: quick hygiene pass

On the changed files (`git diff --cached --name-only`, or the relevant diff
if you're reviewing a PR that isn't staged locally), check for:

- Debug leftovers: `console.log`, `print(`, `debugger`, `pdb.set_trace()`,
  `dd(`, `var_dump` depending on language, judge by what's actually in the
  diff, not a fixed list.
- Commented-out code blocks that look abandoned rather than intentionally
  documented.
- `TODO`/`FIXME` comments with no ticket/issue reference nearby, worth a
  mention, not a blocker on their own.

This step doesn't need a script, grep the diff and use judgment; a `TODO`
inside a test fixture is not the same problem as one inside error handling
for a payment flow.

## Step 4: report back, don't gate silently

Summarize findings by severity, not just a raw list: secrets and
critical/high dependency issues first, hygiene notes last. If everything's
clean, say so briefly, don't pad a clean result with caveats to seem
thorough. If something needs a person's judgment (a finding that might be a
false positive, an unavailable scanner), say exactly that rather than
guessing on their behalf.

## Ground rules

- Never auto-fix a finding by deleting evidence (e.g. removing a line with a
  real secret) without telling the user, rotation comes first, then cleanup.
- Don't block a merge yourself, you're not the CI system, surface findings
  clearly enough that the human or the actual CI gate can decide.
- If both a real scanner and the bundled fallback are available, run the
  real one, the fallback exists for when nothing else is installed, not as a
  first choice.
