Skip to main content Switch to mobile version Pre-release This release is a pre-release and may not be stable for production use.
A private twin of your code for AI agents: the AI works on the twin, its edits merge back into the original
pip install doppelcode==0.7.0b10 Copy PIP instructions
Version: 0.7.0b10 (public beta)
DoppelCode lets you use AI coding agents on proprietary code while reducing what an AI sees of your code. It writes a twin of your project: the same code with your names and file names replaced by placeholders. By default, whole comments are hidden (comments: hide) and names are replaced inside strings (strings: scrub); strings: hide replaces whole strings too. Optionally your tuned constants are hidden and your core function bodies left out. The AI works only on the twin. doppel import merges its edits back into your original with the real names, and DoppelCode records what was sent to the AI, so you can show later which parts of your code an AI was given.
Python 3.11+, no third-party packages. Optional: gcc/g++ or clang (header harvesting, compile check), git (3-way merge).
Quick Start (5 minutes)
pip install doppelcode # installs the doppel command (or: python -m doppelcode ...) pip install . # or: install from source, in a clone of this repo doppel init path/to/project # optional: writes .doppel/config.json with the defaults doppel export path/to/project --out path/to/twin # writes the twin On Windows, pip may say The script doppel.exe is installed in '...\Scripts' which is not on PATH. Then doppel is not found: add that folder to your user Path (Settings > System > About > Advanced system settings > Environment Variables; open a new terminal afterwards), or run every command as py -m doppelcode ... instead of doppel .... The VS Code extension uses py -m doppelcode by itself when doppel is not found.
Open the twin folder, not the original, in your agent (Claude Code, GitHub Copilot agent, Cursor, or paste it into a chat). The twin has an AGENTS.md / CLAUDE.md that tells the agent the rules.
Let the agent work in the twin as usual.
doppel import path/to/project merges the agent's changes into your original, with your names.
doppel check path/to/project verifies the round trip, scans the twin for leaks and compiles both versions (C / C++ machine code is compared; Python syntax trees are compared).
doppel report path/to/project shows which function bodies were made available to an AI, and when.
Pilot results (DeepSeek, DeepThink on; two small projects, one in C and one in Python; one chat per project and condition). The attack question asked for every value and whether the core functions could be rebuilt:
These are small pilots with one model; they show the direction, not a guarantee.
The defaults and the trade-off (0.7.0b10)
Configs written before 0.7.0b10 keep their values; doppel init prints how to switch.
For the "declared" languages, a name is kept when it is used as a member of something the project does not declare (os.path, sb.Append, crypto.createHash), when it is imported from an outside module, when it is a keyword argument to a library call (json.dumps(indent=2)), or when it is a method of a class derived from a library class (unittest setUp, Thread.run). Python packages (folders with __init__.py) are renamed together with their imports; Java files take their public class's new name. Code inside f"{x}", $"{x}" and `${x}` is always translated, strings that name code (getattr(o, "x"), __all__, obj["x"], reflection) are renamed with it, and module names (require("crypto"), import ... from "lib") are never hidden.
Machine code is compared against a names-only version of the twin (strings and comments untouched), so the comparison proves that renaming changed no code whatever the string policy. With strings set to keep, a Python twin prints exactly what the original prints.
check also builds Java, C# and JS / TS. The original is built first; if it does not build with the tool found, its files are listed as NOT CHECKED with the reason, so only errors the twin alone has count. The twin's code is never run (javac without annotation processors, csc without analyzers, JS / TS only compiled). Tools are found automatically and can be set in .doppel/config.json:
With strings set to keep, file and folder names inside path strings (require("./falconRadio"), fopen("rec_01.dat")) are still renamed, so the twin finds its renamed modules and data files.
A desktop app is planned for a later release. This beta is the doppel command line; everything below works with it.
python -m doppelcode init
init writes the defaults, with your OS user name and git user.name (and its words) as sensitive_terms, so check reports them anywhere in the twin. A term under 4 letters (a user name ted) is matched as a whole word only, so it does not flag "tested"; init lists such terms. Longer terms match inside words too. An existing config is not changed.
Where the twin is, and copied or moved projects
The twin goes where --out says, or twin_dir in the config, or else next to the project as twin_
Moved (the old folder is gone): the twin stays; export notes the move.
Copied with its .doppel folder (the old folder still has its own): the copy must not use the other project's twin. import and check refuse until export has run in the copy, and that export writes a new twin for it (twin_
A project that has both .doppel and an old .cobf folder uses the one with the vault (.doppel when both have one) and every command warns until you keep only one.
Review before applying (--preview)
python -m doppelcode import
--from-preview DIR applies exactly what was previewed, with the preview's --rename / --accept. It refuses, and writes nothing, when a twin file or an original changed since the preview: preview again. Applied files leave the manifest, so the rest can be applied later. The VS Code extension uses this for its review view.
Files that are not UTF-8, and line ends
DoppelCode keeps every file's bytes: a Windows-1255 or Windows-1252 file goes into the twin in its own encoding (with comments: hide its comments do not go at all) and comes back the same, except the lines the AI changed. An AI agent's editor often saves such a twin file as UTF-8 (replacement characters, or the code page decoded). Import gives every line whose only change is that re-encoding its original bytes back, and writes the lines the AI did change in the file's code page when it can tell which one it is (encoding: in the output). Line ends do not take part in the merge: the AI adding LF lines to a CRLF file, or your editor saving the file again with one style, is not a change; changed lines take the original's style.
Writing to the AI in real names (translate)
python -m doppelcode translate
--to-original --stream is a filter for an AI agent's live output (the VS Code extension's Agent panel uses it): it reads stdin line by line, writes each line translated as soon as it is complete (UTF-8, flushed after every line, line ends kept) and exits with 0 when stdin ends. It prints no warnings.
Whole identifiers only, case-sensitive: sample_rate_hz is one name, never sample_rate plus _hz.
A name that is a plain English word (block, key, state) is translated where the text is code (in backticks, in a code fence, or next to code punctuation such as block[i], ctx->key, key(...)); in prose it stays a word, so "encrypt the first block" does not become "encrypt the v_0030 v_0008".
File paths, with / or \, follow the twin (Utils/Utils_ReadWriteFile.c -> Utils/mod_0001.c).
A withheld function becomes its B_ id; its body and purpose line are never used.
Back to the original: the same reverse translator as import, so names the AI coined from a placeholder (fn_0005_checked) come back as import restores them, K_ names show the real value and str_ / cmt_ ids the real text. Placeholder-style names the vault does not know stay as they are, with a warning.
--to-twin warns, and never blocks, about: a sensitive term (sensitive_terms, the project folder name, the OS user name, git user.name), a number or text equal to a secret constant's value, a word or phrase that is part of a real name (Falcon, "sample rate"), an identifier-shaped word the vault does not know (it may be a real name the twin does not cover), and a real file path (absolute, or a project file the twin does not have). leak_allow silences a word. A single word of a real name that is also a common English word (round, first, chain) is reported as information, not as a warning: almost every request has such words, so they tell the AI little. A phrase that spells out a real name ("sample rate") stays a warning. Exit code 0 without warnings (information alone included), 3 with warnings (on stderr as warning: and info: lines, or in the JSON), 2 on an error. --json prints text, replacements (from, to, count) and warnings (kind, severity (warning or info), text, position, line, column, length, detail) in ASCII.
Names the AI coins in DoppelCode's style
AI models often name new things like the placeholders they see (v_0048, fn_0017, "str_0013"). Mapped back blindly, a new parameter v_0048 would become an unrelated existing name (fips_expected), and a new string "str_0013" would become an existing text ("ALL PASS"). On the lines the AI added or changed, import therefore flags:
a known alias in a declaration position (function, parameter, local, field, type, macro) that the old version of the file did not declare;
an alias-shaped name that is not in the vault (fn_0017);
a string literal that is exactly "str_NNNN" and was not in the old version of the file.
Plain uses of existing names map silently. Flagged files are not merged; the findings go to the console and to .doppel/import_review.txt. Resolve them and import again:
python -m doppelcode import
export also writes AGENTS.md and CLAUDE.md into the twin root (unless the project has its own) asking the agent to give new things plain names, and a .doppel-twin marker, a small JSON file ("doppelcode": "twin") that tools such as the VS Code extension use to know a twin folder. The marker names nothing of the project. import ignores all three files.
Example (samples/aes_project)
/* original */ /* twin */ void falcon_encrypt_block( void fn_0002( const FalconAesContext *ctx, const T_0001 *v_0006, uint8_t block[FALCON_BLOCK_SIZE]); uint8_t v_0008[M_0002]); #include "falcon_aes.h" #include "mod_0001.h" The names are gone, and with the default config the comments are hidden and the Makefile's falcon_selftest target is renamed. The strings still say "Falcon", and check says so. Copy samples/aes_project somewhere first (export writes .doppel into the project):
doppel export aes_project --out aes_twin doppel check aes_project round trip: OK leaks: 3 line(s) - full list in ...\aes_project\.doppel\leaks.txt by kind: name part 3 src/main.c:8: name part 'falcon' in Falcon src/main.c:54: name part 'falcon' in FalconLinkKey01 src/main.c:55: name part 'falcon' in FalconInitVec01 3 line(s) of source files have parts of your names in strings ('scrub' keeps that text). Fix: "strings": "hide" in .doppel/config.json, then export again (with strings hidden, the twin may behave differently at runtime); or add words that may stay (a public product name) to "leak_allow". name parts by word: 3 line(s) from 1 word(s): falcon (3) Words that may stay (a public product name): add to .doppel/config.json: "leak_allow": ["falcon"] hints: name parts that are common or technical words, not counted as leaks: decrypt (2), encrypt (2), link (1) compile: 2 C/C++ file(s), 0 twin-only error(s) check exits with 1: the twin's strings still say "Falcon telemetry frame #42: altitude=1200m" and "FalconLinkKey01". The fix: hide the strings, then export and check again:
doppel export aes_project --strings hide doppel check aes_project round trip: OK leaks: none compile: 2 C/C++ file(s), 0 twin-only error(s) check exits with 0. The other way: list the words that may stay visible in leak_allow ("leak_allow": ["falcon"]); the strings then stay as they are. Words such as encrypt or link are common technical words: check lists them as hints, not as leaks.
Renaming hides names, but in DSP or classifier code the numbers are often the real know-how: thresholds, coefficients, tuning tables. Marked numbers are replaced in the twin by aliases K_0001, K_0002, ...; the vault keeps the real values and import puts them back.
python -m doppelcode secrets suggest
0, 1, -1, 2 and 0.5 are never hidden by value list (only at a tagged or named place), and never count as leaks.
The twin still runs. A twin-only file gives every alias a neutral dummy value, and each file that uses one gets a marked line that import removes again:
In C a table initializer is replaced as a whole (static const uint8_t k_rcon[10] = K_0001;, the size kept), and #define NAME 0x1b works with secret_symbols too. The dummy file is never imported; if the AI edits it, the import reports "secret value change requested" and keeps the real value.
check compiles / parses the dummy twin, and compares the original with the twin with the real values put back (C: machine code, Python: syntax trees).
If the AI replaces an alias by a literal (K_0003 -> 3.5), the file is not merged until you decide: --accept K_0003 takes 3.5, --rename K_0003=@keep keeps the secret, --rename K_0003=@secret takes 3.5 and adds it to secret_values.
The elements of a secret table are hidden wherever else they are written in the same form (a test generator that hard-codes 400.0 from the tone table), and in comments and strings in any form (400Hz). Small integers (-15..15) and powers of two stay visible: they are indexes, loop bounds, sizes and bit masks. doppel secrets suggest lists the functions that write such values - consider withholding them.
Values computed from secrets (145 * 2 written as 290) are out of scope.
Supported for Python, C and C++.
With withheld functions or secret constants set, strings defaults to hide (banners and help texts would still tell the purpose); set "strings" in .doppel/config.json to choose otherwise. One-word mode strings passed straight to a library call (filterwarnings("ignore"), btype="band", encode("utf-8")) stay, so the twin still runs. Python dict keys are one class: in scrub and hide every identifier-shaped key ('pitch', 'f1', 'spectral_centroid') gets an alias, so the keys do not list what a withheld function computes. Only keys of a library's dict stay (os.environ["PATH"], a dict literal handed to a library call); a key that merely matches a library name ('f2') is still aliased. A library dict is also followed through names (devs = sd.query_devices(), for d in devs: d['max_input_channels'] stays, in hide too). In the text of a function that uses a secret table (its name, one of its values, or a table linked by indexing such as frequencies[target_sequence[i]]), the table's small integers are hidden too ("Symbol 10" -> "Symbol K_0012"); elsewhere small numbers stay. With protected code and "strings": "scrub", check prints a warning with an example string.
Withheld functions (optional)
Choose functions the AI may call but not read. In the twin their body becomes a stub; everything else is renamed as before:
def fn_0004(self, v_0005): raise NotImplementedError("doppel: body withheld (B_0001)") static void fn_0009(uint8_t v_0021[16]) { /* doppel: body withheld (B_0002) */ } float fn_0002(const float* v_0014, int v_0015, double v_0016, double v_0017) { /* doppel: body withheld (B_0003) */ return (float){0}; } A non-void C function returns a zero value (return (T){0};, C++ return {};), so the twin builds with -Werror=return-type; a Python stub raises, so a twin-side test fails where the function is called, not later with a None.
Choosing: in .doppel/config.json: "core_functions": ["detector.py::Detector.classify", "src/filter.c::design_lowpass", "detector.py::Detector"] (a class withholds all its methods), "core_modules": ["dsp/", "secret_algo.py"] (whole files).
Import puts the real bodies back byte for byte; edits elsewhere merge as usual. If the AI changes or removes a withheld body, the file is not merged until you take its version with --accept B_0001.
A change inside a withheld function: the AI is told to describe it in plain words instead of editing the stub, so you apply it yourself. Or release the body for one session: doppel withhold release PROJECT B_0001 --reason "widen the pitch range". The next export sends the body, the AI's edit merges as usual, and the export after it withholds the function again. The release and the send are both in the exposure ledger. doppel withhold list PROJECT shows the ids.
Purpose line (optional): doppel withhold purpose PROJECT B_0002 "returns (gender, confidence) for one chunk" (or right-click it in the outline) lists that line in the twin's AGENTS.md, so the AI calls the right withheld function. Off unless you write one; it tells the AI the function's role, not its body (names and secret values in it are translated). In pilot round 4 the AI called the feature extractor where the gender decision was meant; both were withheld.
check: the dummy twin still parses / compiles to objects; the machine-code comparison uses the full-body copy, so it stays exact; Python syntax trees are compared without the withheld bodies.
Exposure: withheld functions are logged as declaration, not body, so doppel report and the budgets show the real share (e.g. 15 of 17 bodies, 88%).
Python, C and C++ (Java and C# need typed stubs; later). The twin's AGENTS.md / CLAUDE.md tell the agent not to implement or change withheld functions.
Every export records which function bodies it made available to an AI in .doppel/ledger.jsonl (append-only, kept as an audit trail). A body is logged when it is new or changed, or when it is sent again to a new twin folder ("repeat": true); a plain refresh adds nothing.
python -m doppelcode report
Key config options (.doppel/config.json)
Files that are not source, build or known text files are not copied to the twin (they may leak); add them to copy_verbatim if the AI needs them. Build templates, packaging files, scripts (.sh, .pl, #! files without an extension) and text files a build file names are copied; scripts are never imported as new files, and changes to existing ones are listed for review.
The twin is written by an AI agent, so DoppelCode treats it as untrusted:
Import accepts new files only if they are C sources or known text files outside hidden folders. Scripts (.bat, .ps1, .sh), binaries, Windows device names and anything under .github, .vscode, .git and similar are reported as BLOCKED and never written. Changed build and config files (Makefile, *.mk, *.json, ...) are listed under Review before building.
Links: symlinks and junctions inside the twin are never followed (reported as IGNORED (link)), and export refuses to write or delete through them. export also refuses to take over a non-empty folder it did not create (--force to override).
Compile check: if a twin file includes something outside the twin (absolute, .. or UNC \\host\share paths, which would make Windows connect to that host), the compiler is not run.
Leak scan also reports absolute paths, the project folder name and the Windows user name (as a path segment, an e-mail or a handle only, so a user root does not flag "rooted"). Absolute paths in build and text files (toolchain folders, the source checkout) become $(DOPPEL_PATH_0001) in the twin and come back on import. Prose that spells a renamed name out ("read audio file" for read_audio_file) is listed under hints:; it does not fail the check (hide removes it).
Parts of your names in comments and strings (0.7.0b9): scrub replaces whole names, so /* Falcon link self-test */ or "FalconLinkKey01" stay. check reports such parts (4+ letters, used in at least two of your names, falcon from falcon_encrypt_block and FalconAesContext) in comments and strings of source files, as it does in build files. A part that is also a common English or technical word (link, round, symbol, frequency, samples) is listed under hints:, not as a leak (0.7.0b10), unless it is one of your sensitive_terms. The project's folder name counts the same way: a name made of such words (AudioSequence) gives hints, a codename (Atlas_fw, Mercury) is always reported. Name-part leaks are grouped by word, with a ready leak_allow line. Fix: comments / strings: hide, or leak_allow.
Import checks its snapshots (0.7.0b9): import compares the AI's edits with the twin as DoppelCode wrote it (.doppel/twin_base) and merges them against the original as of the last sync (.doppel/base). Each snapshot has its hash in the vault. If one changed since (an agent with access to the project edited it), import refuses and names the files. Delete a changed twin_base file and import rebuilds it from the base copy; delete a changed base file and import writes the AI's version of that file next to the original (
Large projects: check prints a leak summary (counts by kind, the top files, 30 examples, secret values and absolute paths first) and writes the full list to .doppel/leaks.txt (--leaks-all prints it). "leak_allow": ["opus"] accepts words such as a public project name; secret values and absolute paths are always reported. Build and CLI words (cmake, version, option, enable, ...) are not name parts. Headers and modules export could not find are counted and listed in .doppel/missing.txt.
Includes: the compile check refuses a twin whose #include is absolute, a drive or UNC path, or goes above the twin root; #include "../x.h" that stays inside the twin is compiled.
Import warns when a new function reuses an existing alias for its own variable (it would come back as the old meaning); keywords and builtins are not listed as new names. With comments: hide, placeholder comments (// cmt_0040) the AI left out when it returned whole functions are put back next to the code they belong to; a comment that went together with deleted code stays deleted.
IDE and tool state (.vs, .settings, *.user, workspace and c_cpp_properties.json files) is never copied, because it holds absolute paths and user names.
.doppel/vault.json holds the real names and the hidden comments and strings in plain text, like the project's own sources next to it, so it needs the same care. Keep the project folder private.
The compile check uses the compiler's default C dialect (compile_flags: []); set the flags of your real build if needed. Files it cannot verify are listed as NOT CHECKED with the reason.
A twin builds and compiles like the original, but it does not always behave the same. With strings: scrub, names inside data strings (command-line option tables, registry keys) may be replaced; with strings: hide, the program's text output changes. On librosa (pilot, 0.6.4) the original passed 1,957 tests; the twin passed 1,835 (74 failed, 48 errors) with scrub and 1,351 (558 failed, 48 errors) with hide. Run your tests on the original after doppel import; do not trust failing tests in the twin.
DoppelCode reduces what an AI sees; it does not make code unreadable. Function signatures, call structure, control flow and well-known algorithms stay visible in the twin, and a capable model can often tell what a program does.
With the default strings: scrub (and with comments: scrub), the rest of the text in strings (and comments) stays visible, including words that are parts of your names (for example a product name inside a message or a key string). Use strings: hide for code whose messages or keys are sensitive.
With strings: hide, every format specifier stays visible (%d, %.1f, %1$d, %(rate)d, {0}, {x:.2f}, ${x}); only the words are hidden. One known case: in Python, "%(rate)d Hz" % {"rate": rate} hides the dict key "rate" on its own, so in the twin the key no longer matches %(rate)d and the line raises KeyError if the twin runs it. Import restores both; the original is not affected.
Values are hidden only if you mark them (secret_*); doppel secrets suggest proposes candidates.
A withheld function cannot be edited by the AI: it describes the change in plain words and you apply it, or you release the body for one session (doppel withhold release), which is recorded.
A CMake regex that finds several macros by a shared prefix (curl: "#define LIBCURL_VERSION( |_NUM )") cannot find them once they are renamed: add those macros to keep.
In CMake projects (or with build files that compute file paths), file and folder names stay visible in the twin: DoppelCode keeps them unless the config sets "rename_files": true, so the twin builds with the project's own build. check reports this as one finding ("File names kept for the CMake build: N files and folders") and fails until you accept it once with "accept_file_names": true; after that it prints one hint line.
In a pytest project, test names (test_*, Test*), pytest_* hooks and pytest's fixture names are kept so the twin's tests run; they are visible to the AI. "keep_test_names": false hides them.
Comments in shell, Perl and other script files (.sh, .pl, .bat, ...) are not hidden yet, even with comments: hide; author lines and your names in them stay visible. check reports them.
Leak scans and pilot results reduce risk; they are not a proof that nothing leaks. Review check output.
python -m unittest discover -s tests License
DoppelCode is free for personal use, education, research and other noncommercial purposes under the PolyForm Noncommercial License 1.0.0. Any commercial use, including use by or for a company, requires a paid commercial license: see COMMERCIAL.md.
Released: Dec 1, 2026
Both files in this release have provenance metadata.
View provenance details
PolyForm-Noncommercial-1.0.0 View SPDX License List
Development Status 4 - Beta
Intended Audience Developers
Operating System Microsoft :: Windows
Programming Language Python :: 3
Topic Software Development
Release files for doppelcode 0.7.0b10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 449.5 kB
Release files / doppelcode-0.7.0b10.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Release files / doppelcode-0.7.0b10-py3-none-any.whl
Security for doppelcode 0.7.0b10
Both files in this release have been uploaded with provenance metadata.
With provenance doppelcode-0.7.0b10.tar.gz Dec 1, 2026
With provenance doppelcode-0.7.0b10-py3-none-any.whl Dec 1, 2026
Attestation for doppelcode-0.7.0b10.tar.gz
Attestation for doppelcode-0.7.0b10-py3-none-any.whl
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Dec 1, 2026 2 release files Full provenance
0.7.0b10 This release
Nov 30, 2026 2 release files Full provenance
Nov 29, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from 1875753











