intermediateFree course

Merge Gates: Hardening a GitHub Org for AI-Written Code

Org-wide rulesets, central security checks, supply-chain controls, hardened Actions and managed AI agents, practiced on a fleet of deliberately weak repos

  • 10 modules
  • 34 lessons

What you'll learn

  • Inventory every repository and org setting that affects security, with scripts you can rerun
  • Enforce branch, review and file-ownership rules that individual repos cannot quietly remove, on free and paid plans
  • Run one central security gate (SAST, secrets, dependencies, workflow lint) across a fleet, rolled out without stopping delivery
  • Block invented, too-new and unpinned dependencies, including GitHub Actions
  • Find and fix dangerous workflow triggers, script injection and over-privileged tokens
  • Lock down Claude Code and other AI agents on developer machines with managed settings and enforced hooks
  • Run AI review in CI without giving the model write access or trusting its verdict as a gate
  • Detect drift, audit bypasses, measure the program, and respond to leaked secrets and malicious packages

About this course

AI agents now write a large share of the code that reaches your repositories, and they open more pull requests than reviewers can read carefully. They also suggest packages that do not exist, copy insecure workflow patterns, and run with real credentials on developer machines and in CI. If you are responsible for security across many repositories, you cannot fix this one pull request at a time, and you cannot rely on every developer (or every agent) doing the right thing.

This course shows how to build protections that hold anyway. You create a free test organization, bootstrap a fleet of five deliberately weak repositories, and harden them the way you would harden a real org: inventory first, then enforcement that developers cannot switch off, a central security gate, supply-chain controls, hardened GitHub Actions, managed settings for AI coding agents, safe AI review in CI, and the operating work that keeps it all in place.

Everything runs on GitHub Free with public lab repos, so it costs nothing. Every lesson also says what changes on private repos and which paid plan (Team, Enterprise, Secret Protection, Code Security) a feature needs, because most companies run on paid plans. Every command and config in the course is in the companion repo, one directory per lesson, and was tested against a real org.

Curriculum

10 modules · 34 lessons
01What AI changed, and your lab3 lessons

The threat model for AI-assisted development at org scale, a free test org with a fleet of weak repos, and the inventory habit everything else builds on.

  1. 1.1What AI changed for the people who own the repos
  2. 1.2Your lab: a test org and a fleet of weak repos
  3. 1.3You can't harden what you can't list
02Audit the fleet3 lessons

Org settings, repo settings, workflows and secrets in history, scanned across every repo and turned into a risk-ranked backlog.

  1. 2.1Org settings that matter, and their defaults
  2. 2.2Scanning every repo: settings, workflows and secrets in history
  3. 2.3Scorecard, repo tiers and a risk-ranked backlog
03Enforcement developers can't turn off4 lessons

Rulesets on free and paid plans, a baseline applied to every repo, CODEOWNERS for security-critical files, and secret scanning with push protection.

  1. 3.1Rulesets: repo and org, free and paid
  2. 3.2A baseline ruleset on every repo, put back when it drifts
  3. 3.3CODEOWNERS for the files that control security
  4. 3.4Secret scanning and push protection across the org
04A central security gate4 lessons

One reusable security workflow for the whole fleet: diff-aware SAST, secrets, dependencies and config, rolled out from audit to block with exceptions that expire.

  1. 4.1One reusable security workflow for the whole fleet
  2. 4.2Diff-aware SAST with a baseline
  3. 4.3Secrets, dependencies and workflow lint in the same gate
  4. 4.4Rolling out a gate: audit, warn, block, and exceptions that expire
05Supply chain at fleet scale4 lessons

Dependabot everywhere, lockfiles and install scripts, a gate for invented and too-new packages, and GitHub Actions treated as dependencies.

  1. 5.1Dependabot across the fleet
  2. 5.2Lockfiles and install scripts
  3. 5.3Catching invented and too-new packages before merge
  4. 5.4Actions are dependencies too: pinning, allowlists and lockfiles
06Hardening GitHub Actions4 lessons

Least-privilege tokens, dangerous triggers and script injection, zizmor across the fleet, and OIDC, environments and runners.

  1. 6.1The GITHUB_TOKEN and least privilege
  2. 6.2Dangerous triggers and script injection
  3. 6.3zizmor across the fleet
  4. 6.4OIDC, environments and runners
07AI agents on developer machines4 lessons

What an org can enforce on Claude Code with managed settings, permissions, sandboxing, enforced hooks and MCP control, and where instruction files stop.

  1. 7.1Managed settings: what an org can enforce on Claude Code
  2. 7.2Permissions, secrets and the sandbox
  3. 7.3Enforced hooks and MCP server control
  4. 7.4Instruction files are advice; Cursor and other agents
08AI agents in the pipeline3 lessons

AI review in CI without the keys, prompt injection through pull request content, and scoping coding agents and autofix bots.

  1. 8.1AI review in CI without giving it the keys
  2. 8.2Prompt injection through pull request content
  3. 8.3Coding agents and autofix bots: scope, network and approval
09Running the program4 lessons

Exceptions and bypasses you can audit, scheduled drift detection, metrics that mean something, and playbooks for leaked secrets and malicious packages.

  1. 9.1Exceptions and bypasses you can audit
  2. 9.2Drift detection on a schedule
  3. 9.3Metrics that mean something
  4. 9.4Incident playbooks: leaked secret, malicious dependency
10Capstone1 lesson

Harden the whole fleet and prove it with evidence.

  1. 10.1Capstone: harden the fleet and prove it

// final project

Final project

Take the five-repo lab fleet from its weak starting state to a hardened state and prove it. Submit: the inventory output before and after; the baseline ruleset and drift-check output showing zero drift; a pull request that the central gate blocked, with the reason; a dependency PR rejected by the package check; zizmor results before and after; your managed-settings.json for Claude Code with a short note on what it enforces and what it cannot; and an exceptions log with at least one expiring exception.

Prerequisites

  • Comfortable on the command line (bash) and with git
  • A GitHub account, and permission to create a free organization
  • GitHub CLI (gh) 2.x installed and logged in
  • Docker (for running scanners without installing them)
  • Basic reading knowledge of YAML and JavaScript

Who it's for

Security engineers, secops and platform teams responsible for many repositories, who need protections that hold even when developers and their AI agents take shortcuts. Developers who own their team's repos can follow along too.