---
title: "Automating dead code cleanup"
description: "Meta's SCARF framework finds dead code by building a cross-language, symbol-level dependency graph from Glean and augmenting it with runtime usage data such as API endpoint logs, URI dispatch tables and async job invocations, then garbage-collects unreachable nodes, subgraphs and cycles."
url: "https://swe.quest/articles/automating-dead-code-cleanup-e03bc4ba07b5bf1c"
canonical: "https://engineering.fb.com/2023/10/24/data-infrastructure/automating-dead-code-cleanup/"
source: "Meta Engineering"
published: "2023-10-24"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["static-analysis","refactoring","developer-productivity","python"]
---

# Automating dead code cleanup

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2023-10-24, 7 min read, Case study. Original: [https://engineering.fb.com/2023/10/24/data-infrastructure/automating-dead-code-cleanup/](https://engineering.fb.com/2023/10/24/data-infrastructure/automating-dead-code-cleanup/)

## Summary

Meta's SCARF framework finds dead code by building a cross-language, symbol-level dependency graph from Glean and augmenting it with runtime usage data such as API endpoint logs, URI dispatch tables and async job invocations, then garbage-collects unreachable nodes, subgraphs and cycles. Switching from per-symbol classifiers to whole-graph analysis raised dead code removal in one large codebase by nearly 50%, at the cost of a longer indexing and data-pipeline cycle that makes prototyping harder. Over five years SCARF has deleted more than 100 million lines in over 370,000 change requests generated through CodemodService, with some languages auto-merged without review. BigGrep textual-reference checks act as a conservative fallback, accepting false negatives to avoid unsafe deletions.

Written by swe.quest, not by the author.

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

## Topics

- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Developer productivity](https://swe.quest/tags/developer-productivity.md) (Engineering practices)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- dependency graphs
- static analysis basics ([easy posts on Static analysis](https://swe.quest/tags/static-analysis.md?difficulty=easy))
- codemods

## Keywords

SCARF, Glean, CodemodService, BigGrep, Hack, Meta

## Related posts

- [Automating product deprecation](https://swe.quest/articles/automating-product-deprecation-9c964f5b3db1d6d5.md): Meta Engineering · 2023-10-17 · Medium · 10 min read · Refactoring & migrations, Developer productivity, Static analysis, Developer tools
  SCARF (Systematic Code and Asset Removal Framework) is Meta's tooling for deprecating products by removing dead code and unused data, credited with deleting over 100M lines of code in five years and petabytes of data across 12.8M data types in 21 systems in one year.
- [Automating data removal](https://swe.quest/articles/automating-data-removal-d163bb8b8352c57e.md): Meta Engineering · 2023-10-31 · Medium · 9 min read · Privacy, Databases, Static analysis, Refactoring & migrations
  Meta's SCARF framework includes a subsystem that finds and deletes unused classes of data, such as tables, storage use cases and TAO object types, across 21 data systems.
- [Protecting user data through source code analysis at scale](https://swe.quest/articles/protecting-user-data-through-source-code-analysis-at-scale-357585a0d96f83c8.md): Meta Engineering · 2025-02-18 · Medium · 4 min read · Static analysis, Threat detection, Application security, Python
  Meta's Anti-Scraping team encodes known scraping attack vectors as taint-analysis rules in its in-house static analyzers, Zoncolan for Hack and Pysa for Python, so potential vectors are flagged before code ships.
- [Fixit 2: Meta’s next-generation auto-fixing linter](https://swe.quest/articles/fixit-2-meta-s-next-generation-auto-fixing-linter-71b7e5da0973759e.md): Meta Engineering · 2023-08-07 · Medium · 6 min read · Static analysis, Python, Developer tools, Refactoring & migrations, Open source
  Fixit 2 is a partial rewrite of Meta's open-source Python auto-fixing linter, built on LibCST so rules can safely suggest and apply code replacements without regex or broken syntax.
- [An open source compositional deadlock detector for Android Java](https://swe.quest/articles/an-open-source-compositional-deadlock-detector-for-android-java-baaa0219c7853320.md): Meta Engineering · 2022-03-08 · Hard · 2 min read · Static analysis, Concurrency, Java & JVM, Mobile
  Meta built a compositional static analyzer, now part of the open source Infer framework, that detects deadlocks in Android Java code without running it.

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)
