---
title: "How we ship code faster and safer with feature flags"
description: "GitHub puts risky changes and in-progress features behind feature flags so it can deploy continuously and disable problems in seconds instead of rolling back a deployment over several minutes."
url: "https://swe.quest/articles/how-we-ship-code-faster-and-safer-with-feature-flags-49a97b8efaf60044"
canonical: "https://github.blog/engineering/infrastructure/ship-code-faster-safer-feature-flags/"
source: "GitHub Engineering"
published: "2021-04-27"
difficulty: "medium"
kind: "Case study"
reading_minutes: 9
tags: ["deployment","ci-cd","testing","refactoring","ruby"]
---

# How we ship code faster and safer with feature flags

A post on [GitHub Engineering](https://swe.quest/sources/github.md), published 2021-04-27, 9 min read, Case study. Original: [https://github.blog/engineering/infrastructure/ship-code-faster-safer-feature-flags/](https://github.blog/engineering/infrastructure/ship-code-faster-safer-feature-flags/)

## Summary

GitHub puts risky changes and in-progress features behind feature flags so it can deploy continuously and disable problems in seconds instead of rolling back a deployment over several minutes. Flags can target individual actors (users, orgs, repos, GitHub Apps or custom actor types), all staff, beta groups, a sticky percentage of actors, or a per-request percentage ("dark shipping") for invisible changes such as query optimizations. CI runs two builds, one with all flags on and one with all flags off, to cover both code paths. The costs are runtime lookups (metadata in MySQL cached in memcached, with per-actor MySQL queries for large flags) and dead-code debt, which GitHub is automating away with a git grep and rubocop-ast script that rewrites conditionals and tests and opens a pull request routed to CODEOWNERS.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)

## Prerequisites

- feature flags ([easy posts on Deployment](https://swe.quest/tags/deployment.md?difficulty=easy))
- CI pipelines ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))
- pull request workflows

## Keywords

GitHub, feature flags, rubocop-ast, MySQL, memcached, CODEOWNERS, dark shipping

## Related posts

- [Roll it out, roll it back, never redeploy](https://swe.quest/articles/roll-it-out-roll-it-back-never-redeploy-c13aa355b1437d78.md): Railway · 2026-07-17 · Medium · 7 min read · Deployment, Configuration management, AI agents, Developer tools
  Railway now offers feature flags across its dashboard, CLI, TypeScript SDK and MCP server, so code can ship dark behind a default-off flag and be rolled out to a team, a percentage of users, or targeted segments without redeploying.
- [Now you see me, now you don't: feature-flagging with LaunchDarkly at incident.io](https://swe.quest/articles/now-you-see-me-now-you-don-t-feature-flagging-with-launchdarkly-at-incident-io-cb6cda92c3363bee.md): incident.io · 2021-11-09 · Medium · 6 min read · Deployment, Go, React, Testing
  incident.io ships to production many times a day and uses feature flags to merge large features like Announcement Rules incrementally while hiding them from customers until launch.
- [How GitHub uses CodeQL to secure GitHub](https://swe.quest/articles/how-github-uses-codeql-to-secure-github-3ead357c38ddce28.md): GitHub Engineering · 2025-02-12 · Medium · 14 min read · Static analysis, Application security, Ruby, CI/CD
  GitHub's Product Security Engineering team runs CodeQL across more than 10,000 repositories, mostly with default setup and the security-extended suites.
- [How we use Dependabot to secure GitHub](https://swe.quest/articles/how-we-use-dependabot-to-secure-github-a37d347bd1917fad.md): GitHub Engineering · 2022-05-25 · Medium · 7 min read · Supply chain security, Engineering management
  GitHub's Product Security Engineering team rolled Dependabot out across several thousand internal repositories in three stages: measuring alerts org-wide through the GraphQL API, a staged enablement (200 repos, then 1,000 at 30 days, then the whole org at 45 days), and remediation.
- [Building GitHub with Ruby and Rails](https://swe.quest/articles/building-github-with-ruby-and-rails-99851966c067c871.md): GitHub Engineering · 2023-04-06 · Medium · 5 min read · Ruby, Refactoring & migrations, CI/CD, Deployment, Open source
  GitHub's ~2M-line Rails monolith upgrades to the latest Rails main-branch commit every week via a scheduled GitHub Actions workflow that opens an automated PR, runs all builds, and ships the next day.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
