unleak
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUnleak
Unleak
Use for database questions only when the current project has an folder. Unleak reduces leakage risk; it is not a sandbox.
unleakunleak/仅当当前项目包含文件夹时,才针对数据库问题使用。Unleak可降低泄漏风险,但它并非沙箱环境。
unleak/unleakRules
规则
- Never read or edit .
unleak/local/db-conf.json - Never edit ,
unleak/scripts/**, orunleak/local/schema/**.unleak/local/active-policies/** - Never run ; only suggest the manual command with
activate-policy.mjs.!node - Never use raw database CLIs when is configured.
unleak - Do not query until schema and an active policy exist.
- When schema and an active policy already exist, answer normal data-inspection requests by querying approved data only. Do not propose, validate, activate, or re-create policy unless the user explicitly asks to set up or update policy.
- Prefer inline SQL with for normal queries. Do not create project-visible query files like
query.mjs --sqlfor routine analysis../query.sql - Create a SQL file only when the query is very complex. Put those files under in the skill local state, not in the user's project surface.
unleak/local/queries/ - Treat Claude permissions as guardrails, not a complete sandbox.
- Keep the user's current project directory as the working directory. Relative paths must continue to work for the user.
- 切勿读取或编辑。
unleak/local/db-conf.json - 切勿编辑、
unleak/scripts/**或unleak/local/schema/**。unleak/local/active-policies/** - 切勿运行;仅建议用户使用
activate-policy.mjs执行手动命令。!node - 当已配置时,切勿使用原始数据库CLI。
unleak - 在模式和有效策略存在之前,请勿执行查询。
- 当模式和有效策略已存在时,仅通过查询已批准的数据来响应常规数据检查请求。除非用户明确要求设置或更新策略,否则请勿提议、验证、激活或重新创建策略。
- 对于常规查询,优先使用带的内联SQL。请勿为常规分析创建如
query.mjs --sql这类项目可见的查询文件。./query.sql - 仅当查询非常复杂时才创建SQL文件。将这些文件放在技能本地状态的下,而非用户的项目表层目录中。
unleak/local/queries/ - 将Claude权限视为防护规则,而非完整的沙箱环境。
- 保持用户当前的项目目录为工作目录。相对路径必须对用户持续有效。
Workflow
工作流
Run scripts from the user's current project directory, replacing with the actual folder path.
.claude/skills/unleakunleak/Important cwd rule:
- Do not leave the shell inside the Unleak skill root after installing dependencies.
- Prefer so the working directory stays at the project root.
npm install --prefix .claude/skills/unleak - If you must change directories to install dependencies, immediately return to the original project directory before retrying scripts or giving the user any relative-path commands.
- Check readiness:
If the output reports
node .claude/skills/unleak/scripts/check-readiness.mjsor suggestsDEPENDENCIES_NOT_INSTALLED, run:npm installThen retry the same readiness command from the original project directory and continue.npm install --prefix .claude/skills/unleak - List safe connections:
If the user asked to inspect, analyze, query, or find patterns in data and the requested connection already has schema and an active policy, skip setup and policy work. Write focused SELECT queries and run:
node .claude/skills/unleak/scripts/list-connections.mjsContinue iterating with more SELECT queries until the user's data question is answered. If a query is too complex for inline SQL, create it undernode .claude/skills/unleak/scripts/query.mjs --connection <name> --sql "SELECT ..."and run:.claude/skills/unleak/local/queries/<short-name>.sqlOnly continue to setup steps 3-12 when config, schema, or active policy is missing, or when the user explicitly asks to set up, propose, validate, activate, or update policy.node .claude/skills/unleak/scripts/query.mjs --connection <name> --file .claude/skills/unleak/local/queries/<short-name>.sql - If config is missing, do not read or create . Ask the user to run:
unleak/local/db-conf.jsonnode .claude/skills/unleak/scripts/init-config.mjs - Ask the user to edit manually:
unleak/local/db-conf.json- Set a random .
hmacSecret - Keep and configure only the connections they need.
- For SQLite, set the database file path.
- For Postgres, set host, port, dbname, username, and password.
- Set a random
- When the user says the config is saved, rerun:
node .claude/skills/unleak/scripts/list-connections.mjs - Install deny rules if needed:
node .claude/skills/unleak/scripts/install-claude-settings.mjs - Dump schema:
node .claude/skills/unleak/scripts/dump-schema.mjs - Propose policy:
node .claude/skills/unleak/scripts/propose-policy.mjs - Read schema and proposed policy files. Briefly explain policy recommendations.
- Edit only files under .
./unleak-policy-review/*.policy.proposed.json - Validate:
node .claude/skills/unleak/scripts/validate-policy.mjs - Ask the user to activate manually:
!node .claude/skills/unleak/scripts/activate-policy.mjs ./unleak-policy-review/<connection>.policy.proposed.json - Query approved data:
node .claude/skills/unleak/scripts/query.mjs --connection <name> --sql "SELECT ..."
从用户当前的项目目录运行脚本,将替换为实际的文件夹路径。
.claude/skills/unleakunleak/重要的工作目录规则:
- 安装依赖后,请勿让Shell停留在Unleak技能根目录中。
- 优先使用,这样工作目录会保持在项目根目录。
npm install --prefix .claude/skills/unleak - 如果必须切换目录来安装依赖,请在重试脚本或向用户提供任何相对路径命令之前,立即返回原始项目目录。
- 检查就绪状态:
如果输出报告
node .claude/skills/unleak/scripts/check-readiness.mjs或建议运行DEPENDENCIES_NOT_INSTALLED,则执行:npm install然后从原始项目目录重试相同的就绪状态检查命令并继续。npm install --prefix .claude/skills/unleak - 列出安全连接:
如果用户要求检查、分析、查询或查找数据中的模式,且请求的连接已存在模式和有效策略,则跳过设置和策略相关工作。编写目标明确的SELECT查询并执行:
node .claude/skills/unleak/scripts/list-connections.mjs继续执行更多SELECT查询,直到用户的数据问题得到解答。 如果查询过于复杂而无法使用内联SQL,则在node .claude/skills/unleak/scripts/query.mjs --connection <name> --sql "SELECT ..."下创建查询文件并执行:.claude/skills/unleak/local/queries/<short-name>.sql仅当配置、模式或有效策略缺失,或用户明确要求设置、提议、验证、激活或更新策略时,才继续执行步骤3-12的设置流程。node .claude/skills/unleak/scripts/query.mjs --connection <name> --file .claude/skills/unleak/local/queries/<short-name>.sql - 如果配置缺失,请勿读取或创建。请用户执行:
unleak/local/db-conf.jsonnode .claude/skills/unleak/scripts/init-config.mjs - 请用户手动编辑:
unleak/local/db-conf.json- 设置随机的。
hmacSecret - 仅保留并配置所需的连接。
- 对于SQLite,设置数据库文件路径。
- 对于Postgres,设置主机、端口、数据库名、用户名和密码。
- 设置随机的
- 当用户表示配置已保存时,重新执行:
node .claude/skills/unleak/scripts/list-connections.mjs - 如有需要,安装拒绝规则:
node .claude/skills/unleak/scripts/install-claude-settings.mjs - 导出模式:
node .claude/skills/unleak/scripts/dump-schema.mjs - 提议策略:
node .claude/skills/unleak/scripts/propose-policy.mjs - 读取模式和提议的策略文件。简要说明策略建议。
- 仅编辑下的文件。
./unleak-policy-review/*.policy.proposed.json - 验证策略:
node .claude/skills/unleak/scripts/validate-policy.mjs - 请用户手动激活策略:
!node .claude/skills/unleak/scripts/activate-policy.mjs ./unleak-policy-review/<connection>.policy.proposed.json - 查询已批准的数据:
node .claude/skills/unleak/scripts/query.mjs --connection <name> --sql "SELECT ..."
Initialized Query Playbook
初始化查询手册
When a schema and active policy exist for the requested connection, optimize for valid queries:
- Read the schema file and active policy for that connection before writing analysis SQL:
.claude/skills/unleak/local/schema/<connection>.schema.json.claude/skills/unleak/local/active-policies/<connection>.json
- Make a quick allowed-field map:
- objects with
objectPolicy: "enabled" - columns with policy ,
visible,masked, orhashedjoinable - columns with policy only
visible
- objects with
- Build queries from this map, not from guessed database knowledge.
- For first-pass exploration, prefer simple one-table summaries: , visible categorical counts, visible numeric
COUNT(*)/MIN/MAX/AVG, and visible date buckets.SUM - Avoid for table overviews. Run simple count queries separately instead.
UNION - Avoid parallel or chained query batches until each query shape has passed once. One failed query can cancel useful follow-up work.
- For non-trivial queries, run first, then run the same SQL without
--dry-runafter it validates.--dry-run
Policy-aware SQL rules:
- ,
WHERE,HAVING, scalar expressions, and aggregate expressions may reference only columns with the matching capability. Without explicitORDER BY, this keeps the legacy rule: onlycapabilitiescolumns are allowed.visible - may reference any column policy by default. Grouped protected values are still transformed or hidden according to their output policy.
GROUP BY - Direct may include non-hidden columns, but protected columns (
SELECT,masked,hashed) should not be used in filters, sorts, calculations, or aggregate expressions.joinable - Join conditions may use equality between or
visiblecolumns only.joinable - Every derived expression must have an explicit alias, e.g. .
COUNT(*) AS cnt - may use output aliases or direct sortable columns. Do not use ordinals or raw expressions.
ORDER BY - Prefer qualified column names in joins, e.g. .
t.company_id = lc.company_id - If validation fails, read the error code and adjust the SQL to use visible columns or simpler direct selections. Do not respond by proposing a new policy unless the user asked to update policy.
Column policy handling:
- : Safe for normal analysis. May be selected, filtered, grouped, sorted, joined, and used in expressions or aggregates.
visible - : May be selected directly when useful for display or grouped counts, but the output is transformed. Do not use it for filters, sorting, joins, expressions, or aggregates.
masked - : May be selected directly for pseudonymous display, local comparison, or grouped counts, but the output is transformed. Do not use it for filters, sorting, joins, expressions, or aggregates.
hashed - : Intended for equality joins, direct pseudonymous selection, and grouped counts. May be used in
joinablewhen both sides areON a.col = b.colorvisible. Do not filter, sort, aggregate, or calculate with it.joinable - : May be used only in
hiddenwhen needed for counts. Never select it or reference it elsewhere.GROUP BY - object: Never query it.
disabled
Capability overrides:
- Policies may add per column to allow analysis use without changing output transformation.
capabilities - Valid capabilities: ,
select,filter,group,sort,join,aggregate.expression - Example: a hashed can use
account_idfor pseudonymous investigation, or add["select", "join", "group"]/filteronly when policy owners explicitly allow that workflow.sort - Hidden columns may only declare .
group
当请求的连接已存在模式和有效策略时,优化查询以确保合规:
- 在编写分析SQL之前,读取该连接的模式文件和有效策略:
.claude/skills/unleak/local/schema/<connection>.schema.json.claude/skills/unleak/local/active-policies/<connection>.json
- 快速创建允许字段映射:
- 的对象
objectPolicy: "enabled" - 策略为、
visible、masked或hashed的列joinable - 仅策略为的列
visible
- 基于此映射构建查询,而非依赖对数据库的猜测性认知。
- 对于首次探索,优先使用简单的单表汇总:, 可见分类计数, 可见数值的
COUNT(*)/MIN/MAX/AVG,以及可见日期分组。SUM - 避免使用进行表概览。改为分别运行简单的计数查询。
UNION - 在每个查询格式通过验证之前,避免并行或链式查询批次。一次失败的查询可能会中断后续的有用工作。
- 对于非简单查询,先运行,验证通过后再运行不带
--dry-run的相同SQL。--dry-run
策略感知SQL规则:
- ,
WHERE,HAVING, 标量表达式和聚合表达式仅可引用具备匹配能力的列。若无明确的ORDER BY,则遵循旧规则:仅允许capabilities列。visible - 默认情况下,可引用任何列策略。分组后的受保护值仍会根据其输出策略进行转换或隐藏。
GROUP BY - 直接可包含非隐藏列,但受保护列(
SELECT,masked,hashed)不得用于筛选、排序、计算或聚合表达式。joinable - 连接条件仅可使用或
visible列之间的相等性判断。joinable - 每个派生表达式必须有明确的别名,例如。
COUNT(*) AS cnt - 可使用输出别名或可直接排序的列。请勿使用序号或原始表达式。
ORDER BY - 在连接中优先使用限定列名,例如。
t.company_id = lc.company_id - 如果验证失败,请读取错误代码并调整SQL以使用可见列或更简单的直接选择。除非用户要求更新策略,否则请勿通过提议新策略来响应。
列策略处理:
- :适用于常规分析。可用于选择、筛选、分组、排序、连接,以及表达式或聚合操作。
visible - :当用于显示或分组计数时可直接选择,但输出会被转换。请勿将其用于筛选、排序、连接、表达式或聚合操作。
masked - :可直接选择用于匿名显示、本地比较或分组计数,但输出会被转换。请勿将其用于筛选、排序、连接、表达式或聚合操作。
hashed - :用于等值连接、直接匿名选择和分组计数。当双方均为
joinable或visible时,可用于joinable。请勿将其用于筛选、排序、聚合或计算。ON a.col = b.col - :仅在需要计数时可用于
hidden。切勿选择或在其他地方引用它。GROUP BY - 对象:切勿查询它。
disabled
能力覆盖:
- 策略可为每列添加,以允许在不改变输出转换的情况下进行分析使用。
capabilities - 有效能力:,
select,filter,group,sort,join,aggregate。expression - 示例:哈希后的可使用
account_id进行匿名调查,或仅在策略所有者明确允许该工作流时添加["select", "join", "group"]/filter。sort - 隐藏列仅可声明能力。
group
Policy Updates
策略更新
Treat an active policy as initialized state. For prompts like "inspect data", "find patterns", "analyze this connection", or "run a SELECT", use the active policy and focus on queries. Do not refresh schema, propose a replacement policy, edit proposed policies, validate proposals, or ask for activation just because the user requested analysis.
Policy can be updated only when the user explicitly asks to update, revise, expand, tighten, regenerate, or re-activate policy. In that case, run the relevant setup/policy steps above and keep edits limited to .
./unleak-policy-review/*.policy.proposed.json将有效策略视为初始化状态。对于如“检查数据”、“查找模式”、“分析此连接”或“运行SELECT”这类请求,请使用有效策略并专注于查询。请勿仅因用户请求分析就刷新模式、提议替代策略、编辑提议的策略、验证提议或请求激活。
仅当用户明确要求更新、修订、扩展、收紧、重新生成或重新激活策略时,才可更新策略。在这种情况下,执行上述相关的设置/策略步骤,并将编辑限制在文件中。
./unleak-policy-review/*.policy.proposed.json