There’s one often-overlooked issue with code obfuscation: once class and function names are changed to `I0`, `I1`, and so on, it becomes difficult for outsiders to read the code directly. But even the production error messages that developers themselves receive may lose their meaning, and tools like Claude Code and Cursor have no way of knowing what these names originally represented.
It is a Python AST-based code obfuscator. The Community Edition is licensed under Apache -2.0 and supports framework presets for FastAPI, Django, Flask, Pydantic, Click, and SQLAlchemy, as well as a stable JSON CLI and MCP server.
Pyobfus does not compromise obfuscation; instead, it keeps “readability” on the developer’s local machine. During the build, use `--save-mapping mapping.json`, which saves the mapping between the original identifiers and the obfuscated names; in production, only the obfuscated code runs, and external observers still see names like I0 and I1. When error logs come back from production, developers can use `--unmap` and this `mapping.json` file to restore the traceback locally: `pyobfus --unmap --trace error.log --mapping mapping.json`. The resulting stack trace will display the original class and function names, which developers can understand, and AI coding tools like Claude Code and Cursor can also make sense of it with the source code semantics. The key point is that `mapping.json` is not distributed with the code; it is kept only by the developer. Production builds remain obfuscated, while the debugging entry point remains on the local machine.
znhskzj•4h ago
This is precisely what motivated me to create https://github.com/zhurong2020/pyobfus.
It is a Python AST-based code obfuscator. The Community Edition is licensed under Apache -2.0 and supports framework presets for FastAPI, Django, Flask, Pydantic, Click, and SQLAlchemy, as well as a stable JSON CLI and MCP server.
Pyobfus does not compromise obfuscation; instead, it keeps “readability” on the developer’s local machine. During the build, use `--save-mapping mapping.json`, which saves the mapping between the original identifiers and the obfuscated names; in production, only the obfuscated code runs, and external observers still see names like I0 and I1. When error logs come back from production, developers can use `--unmap` and this `mapping.json` file to restore the traceback locally: `pyobfus --unmap --trace error.log --mapping mapping.json`. The resulting stack trace will display the original class and function names, which developers can understand, and AI coding tools like Claude Code and Cursor can also make sense of it with the source code semantics. The key point is that `mapping.json` is not distributed with the code; it is kept only by the developer. Production builds remain obfuscated, while the debugging entry point remains on the local machine.