Local CLI for safer LLM workflows: redact code before pasting, generate verified obfuscated copies, enforce policy from your repo.
Project description
CLOAK
Local CLI for safer LLM workflows. Redact code before pasting into ChatGPT or Claude. Generate verified obfuscated copies for sharing. Enforce policy from your repo.
[!IMPORTANT] CLOAK is alpha software in active development. APIs and policy format may change before 1.0. The three headline commands (
scan,context,obfuscate) are functional for Python; JS/TS support arrives in Phases 3.5 and 5. See docs/BUILD_PLAN.md for the roadmap.
What CLOAK is
A command-line tool for developers who want to share code with LLMs without leaking proprietary IP or secrets. Runs locally — no server, no SaaS, no cloud — and is governed by a .cloakpolicy file checked into your repo, so engineering teams have an enforceable answer to "what code is allowed to reach an LLM?"
Three commands:
cloak scan ./repo
cloak context ./repo --out safe-context.md --copy
cloak obfuscate ./repo --out ./repo.cloaked --verify "pytest"
cloak scan— Find secrets and proprietary markers in code (wrapsdetect-secrets/gitleaksand layers your policy on top).cloak context— Generate a redacted markdown view of a repo (function bodies hidden, signatures + docstrings kept) safe to paste into an LLM for architectural feedback. Use--strictto also alias enums and paraphrase docstrings.cloak obfuscate— Produce a transformed copy of your code that still passes your test suite, for sharing with contractors or third parties. The--verifyflag is the differentiator: if your tests don't pass against the transformed copy, the operation fails.
Why this exists
The "Shadow AI" problem is real: leadership says "don't paste code into ChatGPT" and developers do it anyway because they have deadlines. Existing solutions are either enterprise-grade network DLP (expensive, blunt, requires IT) or policy documents nobody reads.
CLOAK is the developer-side, repo-governed alternative. A CTO commits a .cloakpolicy once; developers run cloak context --copy before they paste; the right thing happens by default. Authority follows repo merge access — no separate permissions system to invent.
What CLOAK is NOT
Honest positioning matters in security tooling.
- Not unbreakable. A motivated reader (human or LLM) given an obfuscated copy of your code can still extract logic. CLOAK reduces leak surface and creates friction; it does not provide cryptographic protection. Real protection comes from blocking, redacting, encrypting, compiling, or simply never sending the source.
- Not a replacement for enterprise DLP. Network-layer enforcement (Lasso, Polymer, Cyberhaven, Prisma AIRS, etc.) operates at a different layer and is complementary. CLOAK lives in the developer's workflow, not the network egress.
- Not a secret scanner from scratch.
cloak scanwraps existing battle-tested OSS scanners (detect-secrets,gitleaks) and layers policy-aware rules on top. The reuse is intentional and disclosed. - Not magic for content the LLM has already seen. Once code is sent, it's sent. CLOAK helps before paste, not after.
Quickstart
The PyPI package is named
cloak-cli(the simplercloakname was already taken). The command on your$PATHis still justcloak.
# Install:
pip install cloak-cli
# Or from source:
git clone https://github.com/newtophilly/cloak.git
cd cloak
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
# First-time setup in a repo (one prompt, ~10 seconds):
cd your-repo
cloak policy init # detects Python/JS/TS, scaffolds .cloakpolicy
# Then:
cloak scan .
cloak context . --copy # safe redacted markdown to clipboard
cloak obfuscate ./src --out ./src.cloaked --verify "pytest"
A real example
# 1. About to ask Claude for help on a sensitive file? Redact first:
$ cloak context src/pricing.py --copy
# Pasted into Claude: signatures + docstrings, bodies replaced with `...`,
# proprietary tables (UPPER_SNAKE = {...}) replaced with `... `.
# 2. Shipping a contractor a working module?
$ cloak obfuscate src/payments --out /tmp/payments.cloaked --verify "pytest tests/payments"
# Output is transformed AND verified — if your tests don't pass, exit 1.
# A cloak-manifest.json with sha256s + rename map sits in the output dir.
# 3. CI guardrail:
$ cloak scan . --json # exits 1 if any secrets, JSON for parsing.
How .cloakpolicy works
The policy lives in a .cloakpolicy YAML file at the repo root. It's checked into git, versioned with your code, and reviewed via the same PR process as everything else. Authority = whoever has merge access.
version: 1
# Paths CLOAK treats with extra care
sensitive_paths:
- "src/pricing/**"
- "src/auth/**"
# Names that must NEVER be renamed by `cloak obfuscate`
public_api:
- "QuoteEngine.calculate_quote"
- "PaymentGateway.*"
# Custom secret-detection rules layered on top of the built-in scanner
secret_rules:
- id: internal_api_endpoint
pattern: 'https?://internal\..*\.corp\.example'
severity: high
# Default behavior of `cloak context`
context_defaults:
keep_docstrings: true
redact_function_bodies: true
alias_enums: false # set true to behave like --strict by default
# Default behavior of `cloak obfuscate`
obfuscate_defaults:
rename_private: true
rename_public_api: false
encode_strings: false
profile: standard
A full annotated example is at .cloakpolicy.example.
Documentation
docs/BUILD_PLAN.md— how this is being built, in the opendocs/research/— Phase 0 validation experiment + competitive landscape research
Integrations
CLOAK is designed to be called as a subprocess from other developer tools and AI agents. It runs cleanly headless: stable JSON output (--json), predictable exit codes, no interactive prompts.
- fob — local AI workspace. When a fob project has a
.cloakpolicy, fob can route context packets throughcloak contextto redact code before sending to an LLM. CLOAK works fine without fob; this is value-added, not load-bearing. - AI agents (Codex, Claude, custom) — see
docs/AGENT_INTEGRATION.mdfor the agent-readable integration spec: when to call CLOAK, JSON output contracts, exit codes, and common patterns.
Status
| Phase | What | Status |
|---|---|---|
| 0 | Validation experiment | ✅ Done — strategy validated, two-tier redaction discovered |
| 1 | CLI scaffold + .cloakpolicy loader |
✅ Done |
| 2 | cloak scan (wraps detect-secrets) |
✅ Done |
| 3 | cloak context for Python |
✅ Done |
| 3.5 | cloak context JS/TS via tree-sitter |
✅ Done |
| 4 | cloak obfuscate Python with --verify |
✅ Done (v1) |
| 5 | cloak obfuscate JS/TS (javascript-obfuscator) |
⏳ |
| 6 | cloak eval (LLM-prompt-based regression harness) |
⏳ |
Contributing
Issues and PRs welcome. See CONTRIBUTING.md for development setup, code style, and how to report security issues.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cloak_cli-0.1.2.tar.gz.
File metadata
- Download URL: cloak_cli-0.1.2.tar.gz
- Upload date:
- Size: 59.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3b76006ffcd78da4c059ed1955fff6c5322ea9be4d16bc57763e82ec226aa55
|
|
| MD5 |
0f0b6edc9338558c57c067485efe3b8a
|
|
| BLAKE2b-256 |
36604fa468a88a615d22c1784c6890f4b398aa1e534acb9ebf2cab49d45b4c02
|
Provenance
The following attestation bundles were made for cloak_cli-0.1.2.tar.gz:
Publisher:
release.yml on newtophilly/cloak
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cloak_cli-0.1.2.tar.gz -
Subject digest:
d3b76006ffcd78da4c059ed1955fff6c5322ea9be4d16bc57763e82ec226aa55 - Sigstore transparency entry: 1479608100
- Sigstore integration time:
-
Permalink:
newtophilly/cloak@cb954b4ea3034db1d49769fae28588ffd7ff9d35 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/newtophilly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cb954b4ea3034db1d49769fae28588ffd7ff9d35 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cloak_cli-0.1.2-py3-none-any.whl.
File metadata
- Download URL: cloak_cli-0.1.2-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1722328a280c9c4017c2a85a2c8773d4be687069e719b8df655657058532df14
|
|
| MD5 |
f389512d578a8ec70e553387b3650940
|
|
| BLAKE2b-256 |
26d034a477228c8ee5691fb5e84fb0336c5de168c2a608536034591d4345ec56
|
Provenance
The following attestation bundles were made for cloak_cli-0.1.2-py3-none-any.whl:
Publisher:
release.yml on newtophilly/cloak
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cloak_cli-0.1.2-py3-none-any.whl -
Subject digest:
1722328a280c9c4017c2a85a2c8773d4be687069e719b8df655657058532df14 - Sigstore transparency entry: 1479608179
- Sigstore integration time:
-
Permalink:
newtophilly/cloak@cb954b4ea3034db1d49769fae28588ffd7ff9d35 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/newtophilly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cb954b4ea3034db1d49769fae28588ffd7ff9d35 -
Trigger Event:
push
-
Statement type: