Pre-Commit vs CI Quality Gates: When Fast-Shipping Moves The Checks Upstream
Fixing it now means reloading context on a branch they have mentally already closed. Multiply that across a team shipping fast, and the queue becomes the bottleneck, rather than the code itself.
This article looks at when it makes sense to move enforcement earlier, into the IDE and the local Git workflow, and when CI should stay the first and only line of defense.
TL;DR
CI remains the authoritative place to validate a merge, but it doesn’t have to be the first place developers discover every issue. Moving fast, deterministic checks closer to where code is written minimizes pointless context switching and lets CI verify the changes that need full-system context.
Why CI-stage feedback starts to break down at high PR volume
The problem is that, usually, CI quality gates arrive too late relative to how a developer's attention actually works. The moment code is pushed, most engineers move to the next task, whether that is a standup, a different ticket, or a second branch entirely.
When CI fails ten or twenty minutes later, the fix requires reloading a mental model that has already been discarded.
Research from Gloria Mark at UC Irvine, whose work tracks how knowledge workers respond to interruptions, found that it takes an average of 23 minutes and 15 seconds before returning to an interrupted task after being pulled away from it. A one-line lint fix does not take 23 minutes, but interrupting a developer after they have mentally moved on still incurs a meaningful reload cost.
This is why the complaint rarely shows up as "CI is slow." It shows up as reviewers re-requesting changes on PRs that already look finished, as Slack threads asking someone to "just push the fix," and as a growing gap between when a PR opens and when it actually merges.
None of that is a tooling failure. It is a timing failure, and it compounds with every additional pull request a team pushes through the pipeline each week.
What pre-commit checks change in the development workflow
Moving enforcement earlier means running checks before code becomes a pull request at all, typically inside the IDE or as part of the local Git workflow.
The mechanical shift is straightforward: instead of a developer learning about a problem after pushing, they learn about it while the file is still open and the reasoning behind the change is still active in their head.
A misused string interpolation, an accidentally overbroad exception handler, or a hardcoded API key gets caught and fixed in the same sitting the code was written, not in a second sitting triggered by a failed build.
The practical consequence is that pull requests arrive at review already clean of the categories of problems that pre-commit checks cover.
Reviewers stop spending their attention on formatting arguments and obvious static analysis findings, and CI becomes a confirmation layer rather than a discovery layer: it still validates the merge candidate, but fewer issues show up there for the first time.
The distinction worth holding onto is that pre-commit enforcement is not meant to be a direct, smaller copy of the CI pipeline. Its value depends entirely on staying narrow, fast, and scoped to whatever the developer just changed. The moment it tries to do everything CI does, it stops being a convenience and starts being an obstacle developers route around.
When pre-commit quality gates are worth the tradeoff
Moving checks earlier is an architectural decision, not a default setting, and it only pays off when the cost of late feedback exceeds the cost of running checks locally.
Industry tracking from DX's Q4 2025 developer impact report, based on a sample of more than 135,000 engineers, found that 22% of merged code in its sample was AI-authored, and daily AI users merged roughly 60% more pull requests than light AI users.
That is not a marginal increase in review load. It means more code reaching CI for the first time, more of it generated quickly enough that a developer may not have scrutinized every line — Stack Overflow's 2025 survey found 66% of developers cite AI solutions that are “almost right, but not quite” as their biggest frustration.
A second signal worth watching is what CI failures actually contain. If a meaningful share of failed builds trace back to formatting, an obvious static analysis rule, or a secret that should never have been staged, those are candidates for earlier enforcement regardless of team size.
The counter-signal matters too: if CI already returns feedback quickly and rarely blocks anyone, or if the checks in question depend on full build context or a resolved dependency graph, pushing them earlier will not help and may just add noise that erodes trust in the gate itself.
What makes a check suitable for pre-commit enforcement
Because pre-commit checks sit directly inside a developer's flow, they need to clear a higher bar than anything running in CI. A check that takes ninety seconds in a pipeline is invisible. The same check running before every commit is not, and developers will find a way around it within days if it slows them down.
The check also needs to be scoped to whatever changed rather than scanning the whole repository, and it needs to agree with whatever CI enforces downstream, since a rule that behaves differently in the two places teaches developers to distrust both.
Good candidates for pre-commit enforcement typically include:
- Formatting and lint rules, which are deterministic and cheap to auto-fix on save.
- Secrets detection, since a hardcoded credential is far easier to catch before it is committed than after it has been pushed to a shared branch (more than 39 million secrets were leaked across GitHub in 2024 alone).
- Targeted, high-confidence static analysis rules that flag clearly insecure patterns without requiring a security specialist to interpret the result.
- Dependency introduction checks that flag a newly added, vulnerable, or disallowed package before it lands in a PR.
- Repository-specific policy checks, such as file-type restrictions or ownership rules tied to the files actually being touched

Which checks should stay in CI
Pre-commit enforcement is not a replacement for CI, and trying to make it one usually backfires. Some validations genuinely require the centralized, reproducible environment that only a pipeline can offer.
A full test suite is the clearest example: integration and end-to-end tests often depend on services, seed data, or environment configuration that does not exist on a laptop, and running them locally either fails inconsistently or takes long enough that developers disable the hook entirely.
Checks that generally belong in CI rather than pre-commit include:
- Full unit, integration, and end-to-end test suites, which need broader environment setup than a local machine typically provides.
- Comprehensive static analysis and SCA, where scanning the entire dependency graph or codebase benefits from the compute and context a pipeline has and a laptop does not.
- Build and packaging validation, since CI needs to remain the authoritative answer to whether the merge candidate actually builds.
- Compliance evidence generation, because auditors need a reproducible record of enforcement rather than a local log that varies by machine.
- Release and deployment gates, which are tied to environment policy and production risk and should never depend on an individual developer's local setup.
The split, in other words, is about timing and cost. Pre-commit catches the obvious and local. CI validates the full system and produces the record that everything else depends on.
How to design a practical pre-commit enforcement model
Building this out well is less about picking tools and more about sequencing the rollout so it earns trust instead of losing it.
A useful starting point is to pull 30 to 60 days of CI failure logs and classify them by cause: formatting, lint, secrets, static analysis on changed code, dependency policy, or genuine build failures that needed full project context.
That classification tells you, in your own data rather than in a generic best-practices list, which failures could have been caught before the PR was ever opened.
From there, a practical rollout generally follows this sequence:
- Start narrow. Introduce auto-formatting, secrets detection, and a small set of high-confidence static analysis rules first. Resist the urge to move every gate at once.
- Define enforcement levels. Not every finding needs to block a commit. Informational findings surface the issue without stopping work, warnings allow an explicit override, and only low-noise findings should actually block.
- Keep local and CI policy in sync. Store rules as code, version them, and use the same severity model in both places so a fix that passes locally never fails downstream for a different reason.
- Treat performance as a requirement, not an afterthought. Run checks incrementally on changed files, cache results, and set a hard time budget. Anything that regularly exceeds it should be moved back to CI.
This is the place where a unified platform earns its keep. Running formatting, secrets detection, static analysis, and dependency checks through separate tools at the IDE, pre-commit, and CI stages means maintaining separate configurations and separate severity models at each layer.
Codacy applies the same policy across all three, in the editor is the same rule enforced in the pipeline, without teams having to define separate policies for each stage.

Final takeaway
For teams shipping quickly, the real question is not whether quality and security checks should run, but where they run first. CI remains the system of record for merge readiness, but treating it as the first serious feedback point creates avoidable latency for the problems that are local, obvious, and cheap to fix while the developer is still in the file.
Pre-commit checks work when they stay narrow, fast, low-noise, and aligned with whatever CI enforces downstream. Layered enforcement, catching the simple problems early and validating the full system later, is what lets fast-shipping teams keep both their velocity and their standards intact.
Keep CI focused on what only CI can do
Not every quality check belongs in the pipeline. Codacy catches quality, security, and policy issues earlier in the development workflow while keeping CI focused on validating the merge candidate.