/pyobfus:pyobfus-protectfrom pyobfus
Obfuscates Python source code using pyobfus (AST-based, framework-aware) and verifies the output still compiles and imports. Use before publishing to PyPI, sending builds to clients, or shipping evaluation copies.
Ships in pyobfus. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Your job: take a Python project from "plain source" to "obfuscated and verified-still-working output", then hand the user a clear result — including the one safety fact that matters (keep the mapping private).
First check whether the pyobfus-mcp server is connected (look for a
protect_project / check_obfuscation_risks tool).
pyobfus CLI (pip install pyobfus). --json returns
the structured result envelope with ai_hint for builds,
dry-runs, --check, --unmap, --check-delivery, --init,
--validate-config and --verify-provenance-manifest. Utilities
--list-presets, --init-config, --upgrade, --help and --version
print text instead; argument/usage errors can also be plain text.Confirm the target path and the output directory with the user before writing anything. Never obfuscate into the source tree.
Call protect_project with the source path. It runs the whole pipeline
and self-verifies:
protect_project(path="src", output_dir="dist")
Read the result:
verified: true (+ confidence) → report where the output is and what was
checked: the output compiles and imports (plus verify_cmd, if passed). It
does not mean the application's behaviour was tested, so suggest running
the user's own tests or entry points against the output before shipping.verified: false / status: "warnings" → do NOT tell the user it's
ready. The obfuscated output failed to compile or import. Follow the
response's next_tool (usually check_obfuscation_risks) to find the
offending construct, fix or exclude it, and re-run.pro_value present → follow the returned rationale and applicable features;
distinguish credentials, PII and high-severity compatibility findings.
Remove credentials from shipped code and rotate any exposed credentials first.
String encryption can deter static inspection of appropriate literals; it
does not repair eval/exec, reflection or other compatibility risks.
Recommend Pro only when its stated features address the specific finding.protect_project writes the de-obfuscation mapping next to (never
inside) the output. Surface mapping_security_note to the user.
For a deeper check, the user can pass verify_cmd (an app-level
end-to-end check, e.g. python -m myapp --selftest) — note this is gated
behind the PYOBFUS_MCP_ALLOW_VERIFY_CMD=1 environment variable on the
server, and should NOT be unit tests bound to internal symbol names (those
are expected to fail once names are renamed).
# 1. Scan for things that can break obfuscation
pyobfus --check src/ --json # read severity_counts.high, frameworks, suggested_preset
# 2. Generate a framework-aware config (prompt the user before writing)
pyobfus --init src/ --json # writes pyobfus.yaml
# 3. Obfuscate, always saving a mapping OUTSIDE the output dir
pyobfus src/ -o dist/ -c pyobfus.yaml --save-mapping dist.mapping.json --json
# 4. Verify the output still works — this is the step people skip:
python -m compileall -q dist/ # must exit 0 (syntactic integrity)
( cd dist && python -c "import <top_level_module>" ) # imports resolve
# 5. Check what you are about to ship (Core 0.7.1+; MCP: check_delivery)
pyobfus --check-delivery dist/ --json # 0 ok/warnings, 1 high findings, 2 incomplete inspection
Treat exit 2 from --check-delivery as "not checked", never as clean, and
read its JSON warnings even on exit 0.
Since 0.15.0, pyobfus performs bounded checks of ordinary top-level
PyInstaller CArchive members; embedded PYZ/marshalled code and unrecognised
member types remain unknown/warn and are never unmarshalled. Never report
partial frozen inspection as clean.
Since Core 0.16.0, directory scans also inspect detected top-level PyInstaller
executables (at most 32 reader attempts, sharing the expanded-member budget).
Embedded findings use <executable relative path>!<member path>; frozen JSON
counts aggregate inspected archives. Uninspected executables or unknown members
still warn; malformed or over-limit recognised archives exit 2.
If --check reports severity_counts.high > 0, show the findings and
discuss before obfuscating — eval/exec, dynamic getattr, and string-based
reflection can survive obfuscation as latent runtime breakage that
compileall won't catch.
frameworks field)fastapi → --preset fastapi django → --preset django flask → --preset flask
pydantic → --preset pydantic click → --preset click sqlalchemy → --preset sqlalchemy
none of the above → --preset balanced
Obfuscated tracebacks are debuggable — that's pyobfus's signature feature.
Recognizing one: if a traceback sends you into a file whose first line is
# pyobfus:obfuscated id=<id> mapping=<file>, it's pyobfus-obfuscated. Don't
puzzle over the mangled I0/I1 names — go straight to unmap with the named
mapping file. (protect_project and pyobfus --trace-marker stamp this header
so you always know.)
A file may instead open with # pyobfus:generated format=1 edition=…. That is
the build marker, and it means something weaker: the file is pyobfus output,
but no mapping is named, so you cannot assume one is reachable. Ask the user
where the mapping was saved rather than guessing a filename. Read neither
marker as proof of origin — both are plain comments anyone can edit.
When the user pastes an obfuscated stack trace, reverse the identifiers with the saved mapping:
unmap_stack_trace(trace="<pasted trace>", mapping_path="dist.mapping.json")pyobfus --unmap --trace error.log --mapping dist.mapping.json --json(Names are reversed. With mappings rebuilt using pyobfus 0.7.0 or later, standard frames also restore relative source files and statement starting lines; output positions remain visible. Old mappings restore names only. Version-1 mappings also rewrite identifiers in code excerpts, while caret positions stay unchanged. Version-2 independent-file mappings leave excerpts and unframed logs untouched.)
The mapping file is the de-obfuscation key. Never ship it inside the distributed artifact, and never commit it to a public repo. Keep it where only the developer can reach it.
Obfuscate into a fresh output dir outside the source tree.
Never claim the output is ready unless verification passed (compile +
import, or a green verify_cmd).
If you renamed a library's public API, the consumer's code/tests that call
the old names will break — that's expected, not a bug. Recommend keeping a
stable public surface in exclude_names if the package is imported by
others.
Pro builds in CI (Core 0.12.0+) need an active trial or licence. Use
the secret environment variable PYOBFUS_LICENSE_KEY (GitHub Action:
license-key: ${{ secrets.PYOBFUS_LICENSE_KEY }}). Never print or commit
it, and don't run licensed builds for untrusted fork pull requests. A
"Pro access" error means entitlement could not be established, not that the
project is broken: read its message for a missing or invalid licence,
verification being unreachable or rate-limited, or an installation problem. Community builds need no key.
Since 0.13.0: Community pre-commit hooks pyobfus-no-private-material and pyobfus-check-delivery keep recognized mappings and PEM private keys out of commits and inspect built output before pushing (args: [dist/]). python -m pyobfus.precommit [--json] FILE ... exits 0 clean, 1 findings, 2 incomplete/error; missing paths, symlinks and other nonregular paths are skipped. Mappings are checked only in JSON files up to 20 MiB; key headers are checked only in the first 64 KiB, with no file-size errors. Build the delivery output first (a missing directory exits 2), or use the manual stage. Use gitleaks or detect-secrets alongside these bounded checks.
Since 0.14.0: CI environment-key builds require request-bound issuer signatures, with no unsigned fallback. The license server serves the signed endpoint; older clients keep using the legacy endpoint. Workstation/offline registration is unchanged. Signed endpoint denials disable caching and use fixed inactive-state errors. A signer rotation requires prior client public-key distribution; never bypass an unknown key using unsigned fallback or an environment public-key override. Since 0.15.0, clients trust a standby issuer key ahead of future rotation and report an upgrade hint for unknown issuer keys while still denying the build.
Don't pitch Pro proactively. Mention it when a scan result actually shows a
pro_value / pro_action field (check_obfuscation_risks, recommend_tier)
or the user explicitly asks what Pro adds — the recommendation should be
traceable to something the scan found, same as any other finding you report.
What's accurate to say, with numbers, not vague adjectives:
pyobfus-trial start); 30-day money-back guarantee after
purchase.@seal_code integrity + --scrub-traceback, and
--import-obfuscation. Ground the pitch in which of these the scan
actually flagged (e.g. "found N sensitive-looking string literals — Pro's
AES-128-CBC with HMAC-SHA256 (Fernet) encryption hides these from static inspection"), not a generic
list.SECURITY.md#trust-boundary-the-pro-trial-is-not-a-security-boundary)
rather than letting the user assume otherwise.python-minifier.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub zhurong2020/pyobfus --plugin pyobfus2 skills in this plugin
Other plugins' skills for the same job