agentleFS
facebookfacebook/infer/AGENTS.md

infer

AGENTS.md16k starsChanged 13 days agoMITView on GitHub

This file provides guidance to Open Code / Codex / Claude Code (claude.ai/code) when working with code in this repository. Infer is a multi-language static analysis tool developed by Meta. It detects bugs in Java, C, C++, Objective-C, Erlang, Hack, Python, Rust, Swift, and C# code. The primary implementation language is OCaml. All build commands run from the repository root. You must have run ./build-infer.sh and make devsetup initially. Direct test names follow the pattern {lang}{analyzer}, e.g., directjavapulsetest, directcpppulsetest, directcfrontendtest.…

We split this AGENTS.md into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All build commands run from the repository root.

    line 11
  2. Distinctive:

    Test procedure naming conventions:

    line 45
  3. Very specific:

    Polymorphic equality is disabled: Use type-specific equality (e.g., Int.equal, String.equal).

    line 101
  4. Very specific:

    Printf debugging: Use Logging.debug_dev (triggers a warning to prevent accidental commits).

    line 109
  5. Very specific:

    Use [@@deriving compare, equal] for comparison/equality derivations.

    line 110
  6. Very specific:

    Use named arguments when purpose isn't obvious, especially for bool/int params and function-typed params (conventionally named f).

    line 111
  7. Very specific:

    Avoid globally opening modules other than IStd and PolyVariantEqual.

    line 112

≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

This file provides guidance to Open Code / Codex / Claude Code (claude.ai/code) when working with code in this repository.

What is Infer?

Infer is a multi-language static analysis tool developed by Meta. It detects bugs in Java, C, C++, Objective-C, Erlang, Hack, Python, Rust, Swift, and C# code. The primary implementation language is OCaml.

Build Commands

All build commands run from the repository root. You must have run ./build-infer.sh and make devsetup initially.

CommandPurpose
make -jFull native build (default dev mode, warnings are fatal)
make -j BUILD_MODE=dev-noerrorBuild ignoring warnings
make -j -C infer/src checkType-check only (fastest iteration cycle, requires prior full build)
make -j -C infer/src byteBytecode build (for testing changes quickly)
make optOptimized build with flambda
make fmtFormat changed OCaml files with ocamlformat
make fmt_allFormat all OCaml files

Testing

CommandPurpose
make -j 4 testRun all tests (adjust parallelism to your cores)
make -j test_buildVerify build has no warnings
make test-replaceUpdate expected test outputs after intentional changes
make direct_{lang}_{analyzer}_testRun a single test suite (rebuilds infer first)
make -C infer/tests/codetoanalyze/{lang}/{analyzer}/ testRun a single test suite (assumes infer is up-to-date)
make ocaml_unit_testRun OCaml unit tests only
make swift_testsRun Swift tests (separate from main test target)

Direct test names follow the pattern {lang}_{analyzer}, e.g., direct_java_pulse_test, direct_cpp_pulse_test, direct_c_frontend_test. These are defined in the DIRECT_TESTS variable in the root Makefile.

Test structure

Tests live in infer/tests/codetoanalyze/{language}/{analyzer}/. Each test directory has:

  • Source files to analyze
  • issues.exp with expected output (one issue per line)
  • Makefile that runs infer and diffs output against issues.exp

Test procedure naming conventions:

  • *Bad — should report an error
  • *Ok — should not report an error
  • FP_* — false positive (known limitation, include explanatory comment)
  • FN_* — false negative (known limitation, include explanatory comment)

Debugging analysis

infer --debug -- clang -c examples/hello.c
firefox infer-out/captured/hello.c.*.html

Architecture

Frontends (language → SIL translation)

Each supported language has a frontend that translates source code into SIL (Separation Logic Intermediate Language), defined in infer/src/IR/:

DirectoryLanguageMechanism
clang/C/C++/Objective-CCustom clang plugin (facebook-clang-plugins/)
java/Javajavalib/Sawja bytecode parsing
erlang/ErlangErlang compiler integration
python/PythonPyML-based frontend
rust/RustCharon IR translation
llvm/LLVM bitcodeLLVM OCaml bindings (used by Swift)
textual/Textual SILText-based SIL representation (Hack, Python, LLVM)

Intermediate Representation (infer/src/IR/)

Core types: Sil.ml (instructions), Procdesc.ml (procedure descriptors), Typ.ml (types), Procname.ml (procedure names), Tenv.ml (type environments).

Analysis engines

  • Pulse (pulse/, ~150+ files) — The main abstract domain. Handles memory safety, taint tracking, null safety, resource leaks via abductive reasoning.
  • Abstract interpretation framework (absint/) — AbstractDomain.ml, AbstractInterpreter.ml define the fixpoint computation infrastructure.
  • Buffer overrun (bufferoverrun/) — Array bounds analysis.
  • Concurrency (concurrency/) — Race condition detection (RacerD).
  • Cost (cost/) — Computational cost analysis.
  • TOPL (topl/) — Temporal property checking.
  • Checkers (checkers/) — Miscellaneous checkers (liveness, purity, annotations, etc.).

Backend (infer/src/backend/)

Analysis scheduling (AnalysisDependencyGraph.ml), call graph construction (CallGraph.ml), checker registration (callbacks.ml), reporting.

Configuration (infer/src/base/Config.ml)

Very large file (~189KB) defining all command-line options. Uses CommandLineOption module (aliased CLOpt).

OCaml Coding Conventions

  • 100-character line limit. Format with ocamlformat.
  • IStd is auto-opened in every file. Always write open! IStd explicitly at the top.
  • Polymorphic equality is disabled. Use type-specific equality (e.g., Int.equal, String.equal). Use PolyVariantEqual only for modules heavy on argument-free polymorphic variants.
  • Standard module aliases (use consistently, do not alias these names to other modules):
    module CLOpt = CommandLineOption
    module F = Format
    module L = Logging
    module MF = MarkupFormatter
  • Printf debugging: Use Logging.debug_dev (triggers a warning to prevent accidental commits).
  • Use [@@deriving compare, equal] for comparison/equality derivations.
  • Use named arguments when purpose isn't obvious, especially for bool/int params and function-typed params (conventionally named f).
  • Avoid globally opening modules other than IStd and PolyVariantEqual.
  • OCaml debugger: Module M is really InferModules__M (or InferBase__M, etc.) when setting breakpoints in ocamldebug.

Key Files

  • infer/src/base/Config.ml — All CLI options
  • infer/src/IR/Sil.ml — SIL instruction definitions
  • infer/src/absint/AbstractInterpreter.ml — Fixpoint computation
  • infer/src/pulse/PulseAbductiveDomain.ml — Pulse's core abstract state
  • infer/src/dune — Main dune build config (generated from dune.common + dune.in)
  • Makefile — Test targets and build orchestration

Download now (ZIP)

Trending

Less talk lately.about the whole repository

Dec 2025: 2 mentionsJan 2026: 1 mentionFeb 2026: 1 mentionMar 2026: 2 mentionsApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 2 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the facebook/infer repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about facebook/infer

The biggest 5 of 40 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 40

Talked about on GitHub, YouTube, Stack Overflow and Hacker News (40 times).

On GitHub · 32

27 more on GitHub
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.