MonkeyType is a Python library and CLI tool that collects runtime types of function arguments and return values using Python's sys.setprofile hook. It stores these call traces (default SQLite) and can generate PEP 484 stub files or directly apply type annotations to source code via libcst. The architecture separates tracing (CallTracer), storage (CallTraceStore interface with SQLite implementation), stub generation (FunctionDefinition, ModuleStub), and application (libcst-based code transformation). It provides a configurable plugin system (Config/DefaultConfig) for customizing trace storage, code filtering, sampling, and type rewriting. The type rewriting subsystem includes a GenericTypeRewriter visitor pattern and several built-in rewriters (RemoveEmptyContainers, RewriteConfigDict, RewriteLargeUnion, RewriteMostSpecificCommonBase, RewriteGenerator) that refine raw union types into more idiomatic annotations. The project is well-tested with a comprehensive test suite and has been used in production at Instagram.