Skip to main content
← Back to open source

Set up your repos like ours

This is the security setup we run on our own repositories, written so you can copy it. Each step tells you what it does, what it costs, where it works, and how to back it out. None of it is required. Do step 1, stop there if you want, and you're still ahead.

Works on: Linux, WSL, and Git Bash on Windows. We haven't tested macOS, so we're not going to claim it.

1. Start from the template, or copy the files

The quickest route is our template repo. Open it and click Use this template:

https://github.com/Chameleon-Labs-LLC/secure-repo-template

Already have a repo? Copy these files from the template repo (not from ours) into yours and commit them:

  • .github/workflows/security.yml
  • .github/dependabot.yml
  • .coderabbit.yaml
  • .greptile/config.json
  • .npmrc and .nvmrc
  • .gitignore, plus an empty .gitleaksignore
  • .gitattributes, which forces LF line endings. Without it, Git for Windows with core.autocrlf=true checks the hooks out with CRLF and sh fails on them
  • the hook scripts from Scripts/githooks
  • SECURITY.md and CONTRIBUTING.md
  • optional: .github/workflows/githooks.yml, which runs the hook tests and shellcheck in CI

Cost: free. Undo: delete the files you copied.

2. Pre-commit hook: catch secrets before they leave your machine

The hook runs gitleaks on every commit, and it only looks at what you staged. It fails closed. A found secret blocks the commit, and so does a scan that couldn't run (missing binary, scan error). If you have Snyk, the hook runs that too, but only when a commit changes your dependencies. Snyk Code also runs, at most once a day per repo, when source files are staged. By default (SNYK_HOOK_MODE=warn) it reports findings without blocking the commit. Set block to make them blocking, or off to turn it off.

Install gitleaks first (a user-level install is fine), then point git at the hooks. First, check that nothing else already owns your hooks path:

bash
git config --local --get core.hooksPath

It should print nothing. If it prints a path, another tool (for example Husky) already manages this repo's hooks, so sort that out first. (--local reads only this repo's setting. A global one doesn't get in the way of the one-repo setup, which overrides it, and the machine-wide installer below checks for one itself.)

For one repo:

bash
git config core.hooksPath Scripts/githooks

For every repo on the machine:

bash
sh Scripts/githooks/install.sh

The installer copies the hooks to ~/.githooks by default and sets your global core.hooksPath there. Want them somewhere else? Override the root:

bash
GITHUB_ROOT="$HOME/somewhere" sh Scripts/githooks/install.sh

Re-run it after you edit a hook. If you already have a global core.hooksPath, the installer stops and shows it; add --force to replace it.

If a commit gets blocked, here's how to get past it:

  • Real secret found: take it out, then rotate it. There is no override, on purpose.
  • Scan couldn't run: fix the install. For a single commit you can run GITLEAKS_DEGRADED_OK=1 git commit ..., and say why in the message.
  • Skip only the Snyk part, in a real emergency: SNYK_SKIP=1 git commit ...

Cost: gitleaks is free. Undo: for a single repo, git config --unset core.hooksPath. For the global install, git config --global --unset core.hooksPath.

Snyk websiteSign up to Snyk (referral link)

Referral link — we may get credit if you sign up. The tool's price is the same for you.

3. CI security workflow

security.yml runs on every pull request, on every push to main, and again on a weekly schedule. It does three jobs:

  • gitleaks scans for secrets. On a pull request it scans that PR's commits; the full-history scan runs on the weekly schedule.
  • osv-scanner checks your dependencies against the OSV vulnerability database.
  • npm audit, plus npm audit signatures to confirm package provenance. Both npm jobs skip with a notice when there's no package-lock.json at the repo root.

The hook catches a secret before it's committed. CI catches it for the contributor who never installed your hook (there's always one). You want both.

In your repo's branch ruleset, turn on "Dismiss stale pull request approvals" and require code-owner review for .github/. A pull request can edit a workflow to skip its own scans, and GitHub counts a skipped job as a passing required check.

Cost: free on public repos. On private repos it uses GitHub Actions minutes. Undo: delete the workflow file.

4. Dependabot with grouped security updates

dependabot.yml turns on weekly updates and rolls the security fixes into one pull request per ecosystem, so a bad week doesn't hand you fifteen PRs. Version updates wait out a 7-day cooldown, so you don't take a release the day it ships. Security updates skip the cooldown, because a fix shouldn't wait.

Turn on Dependabot alerts in your repo settings too. The alert list is the real source of truth. A security PR can fail to show up when a dependency is transitive-only or has no fixed version yet.

Cost: free. Undo: delete dependabot.yml and switch alerts off in settings.

5. Minimum package age

One line in .npmrc:

ini
min-release-age=7

npm then refuses any version published fewer than 7 days ago. Most malicious packages get yanked within days, so a one-week floor dodges a lot of them. It needs npm 11.10 or newer (older npm warns and ignores it). npm ci installs your lockfile as-is, so it isn't affected.

There's one override. If a vulnerability has a fix younger than 7 days, install the fix anyway:

bash
npm install <package>@<fixed-version> --min-release-age=0

Pick the lowest version that clears the advisory, so you don't pick up a feature jump along with it.

Cost: free. Undo: delete the line.

6. AI pull-request reviewers

We run two bots on top of a human read. They catch different kinds of problems, which is why we run both.

  • CodeRabbit reviews every push. It's billed per PR author, so check the current plan before you turn it on for a team. We set the profile to chill and tell it to skip wording nitpicks on Markdown.
  • Greptile costs about $1 per review at the base effort level. In .greptile/config.json we set "effort": "base" and review on PR open only, so the bill stays predictable. It doesn't re-review a push. After you add commits, trigger a fresh review yourself.

Two things worth knowing. A green check doesn't mean "no findings": both bots post findings as inline comments, so read the comments, not just the check. And a bot only counts if it reviewed the commit you're about to merge.

To skip a review, open the PR with the no-ai-review label already on it. A label added afterward is too late.

Greptile websiteSign up to Greptile (referral link)

Referral link — we may get credit if you sign up. The tool's price is the same for you.

CodeRabbit websiteSign up to CodeRabbit (referral link)

Referral link — we may get credit if you sign up. The tool's price is the same for you.

Undo: remove the app in your GitHub settings and delete the config file.

7. Snyk (optional, metered)

Snyk checks your dependencies and your own source code. Our hook runs Snyk only on commits that change dependencies (and Snyk Code at most once a day). We also run both by hand before a PR:

bash
snyk test snyk code test

Run snyk test when the PR adds, removes or upgrades a dependency. Run snyk code test when it changes application code. The free plan is metered, so we don't spend runs on docs-only changes.

A dependency finding comes with a version to move to, so just apply it. A code finding needs a judgment call: fix it now if the change is small, otherwise write down why it isn't exploitable.

Cost: the Snyk Free plan is metered, and steps 2 through 5 give you scanning without it. Undo: stop running the commands. If you use our hook, set SNYK_HOOK_MODE=off.

8. Never use pull_request_target

Don't use the pull_request_target trigger in a workflow. It runs in your base repo with write permissions and access to every secret, while checking out code from a fork you haven't read. That combination sits behind a lot of GitHub Actions supply-chain compromises. Use pull_request instead.

If a workflow really does need secrets to comment on fork PRs, split it in two. A pull_request workflow builds an artifact, and a separate workflow_run workflow picks it up with the secrets. Never check out the untrusted PR head in the privileged half.

Cost: free. Undo: n/a. This one is a rule, not a tool.

9. For AI coding agents

If you use Claude Code or another coding agent, you can copy our agent setup too:

Inside Claude Code:

text
/plugin marketplace add lelandg/.claude_code /plugin marketplace add Chameleon-Labs-LLC/plugins

Cost: free. Undo: /plugin marketplace remove <name>.

Maestro AI

Hello, there