secrets-handling

secrets-handling is a skill for Claude Code, Codex from Wade-DevCode/awesome-coding-skills-cn. It costs 27 tokens per session (2,558 once invoked), scanned A, original, MIT.

A set of rules for keeping API keys, passwords, tokens, and other secrets out of source code and configuration files. It uses environment variables or dedicated secret-storage services to provide them when the program runs.

In plain words
What is it for?
Use it when writing application code, deployment settings, or CI/CD pipelines that need credentials. It helps with local .env files, example configuration, secret rotation, and leaked-key response.
Why use it?
It reduces the risk of credentials being committed to a repository, copied into logs, or exposed after a leak. It also explains what to do when a secret has already been exposed.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing application code, deployment settings, or CI/CD pipelines that need credentials. It helps with local .env files, example configuration, secret rotation, and leaked-key response.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/secrets-handling
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill secrets-handling
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for secrets-handling

README.md
[![agentmods](https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/secrets-handling/github.svg)](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/secrets-handling)
Your own site
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/secrets-handling"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/secrets-handling/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for secrets-handling

Your own site · 80×15
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/secrets-handling"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/secrets-handling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,558 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00027 $0.02558
Opus 5.5 $0.00011 $0.01023
Sonnet 5.5 $0.00005 $0.00512
Haiku 4.5 $0.00003 $0.00256

Measured 3mo ago against content hash 12aca6f479bb, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

secrets-handling scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/secrets-handling/SKILL.md · 213 lines

How it starts

The opening of the file, as written. The whole thing — 213 lines — stays where its author put it; the contents beside it link to each section on GitHub.

密钥处理

何时用

  • 代码中需要使用 API key、数据库密码、JWT secret、OAuth 凭据等任何形式的密钥。
  • 部署配置、CI/CD pipeline 涉及凭据传递时。
  • 接到密钥泄露告警,需要评估影响并响应时。
  • 代码审查发现任何疑似硬编码凭据时。

核心规则

1. 密钥不进代码库:用环境变量或 secret manager

规则: 任何密钥、token、密码都不允许出现在代码文件、配置文件、注释里;通过环境变量或专用 secret 管理工具(AWS Secrets Manager、HashiCorp Vault、GCP Secret Manager)在运行时注入;.env 文件本地使用但必须加入 .gitignore。

为什么: AI 生成示例代码时最常见的陷阱就是把真实密钥硬编码进代码并提交。GitHub 的安全研究表明,每天有数万个 API key 被意外推送到公开仓库,其中大量来自"我只是先写死方便测试,待会改"的侥幸心态,但改了代码、历史记录里的密钥仍然存在。GitGuardian 报告显示 AI 生成的代码中密钥硬编码比例显著高于人类开发者。

怎么做:

# 反例:硬编码
OPENAI_API_KEY = "sk-proj-abc123xyz..."    # ❌ 直接写死在代码里

# 正例:从环境变量读取
import os
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]   # ✅ 启动时不存在则报错
# .gitignore
.env
.env.local
.env.production
*.pem
*_rsa
*_rsa.pub
credentials.json
  • 提供 .env.example(只含变量名,无值)作为文档,不提供含真实值的 .env。

2. 已泄露的密钥立即轮换,不只是删除提交

规则: 发现密钥被提交进 git 后,第一步是立即在对应服务撤销/轮换该密钥,而不是先删除提交或 rebase;历史记录里的密钥通过 git filter-repo 清除只是事后补救,不能替代密钥轮换。

为什么: AI 有时建议"删掉那次提交然后 force push 就好了",这是错误的响应姿势。在发现密钥泄露到 force push 完成之间的时间窗口内,密钥仍然有效;更重要的是,GitHub 等平台会镜像 push 事件,第三方爬虫可能在秒级内就已经抓取并存档了该密钥。2022 年 Samsung 源码泄露事件中,即便代码被删除,密钥早已被利用。

怎么做:

密钥泄露响应流程:
1. [立即] 在服务控制台撤销/轮换该密钥(AWS IAM、GitHub Settings、Stripe Dashboard 等)
2. [立即] 审计该密钥从泄露到轮换期间的访问日志,确认是否被滥用
3. [之后] 用 git filter-repo 清理历史(需要团队所有人重新 clone)
4. [之后] 复盘:补充 pre-commit 扫描防止再次发生
  • 不要因为仓库是私有的就认为安全——内部人员、协作工具的 webhook、泄露的 deploy key 都可能导致私有仓库内容外泄。

3. 日志、报错、前端不输出密钥

规则: 日志输出、异常信息、HTTP 响应、前端 JavaScript(包括注释和 source map)都不能包含密钥或完整 token;脱敏展示时只显示前4后4位,中间用 **** 替代。

为什么: AI 生成的调试日志和错误处理代码里频繁出现 logger.error(f"API调用失败,key={api_key}, error={e}"),这行日志把完整 API key 写进日志文件。日志文件通常被运维、开发、监控系统等多人访问,远比代码库传播面广。前端 bundle 里的密钥更危险,任何访问网页的用户打开开发者工具即可获取。

怎么做:

def mask_secret(secret: str) -> str:
    """只保留前4后4位,其余脱敏"""
    if not secret or len(secret) <= 8:
        return "****"
    return f"{secret[:4]}****{secret[-4:]}"

# 反例
logger.error(f"调用失败: key={api_key}")         # ❌ 完整 key 进日志

# 正例
logger.error(f"调用失败: key={mask_secret(api_key)}, error={type(e).__name__}")  # ✅
  • 前端只能持有"无权限到后台直接用的"公开配置,如 Google Maps 的 clientId(受域名限制),不能有任何后端密钥。
  • Node.js 项目禁止把 .env 内容打包进 webpack bundle(检查 DefinePlugin 的使用)。

Read the full file on GitHub · 213 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 213 lines · 27 tokens per session scan A 12aca6f479bb

Subscribe to this mod's changes

secrets-handling is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (7 stars, last pushed 5mo ago), licensed MIT. It adds 27 tokens to every session and 2,558 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

secrets-handling compared with skills from other repositories

secrets-handling next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
secrets-handlingWade-DevCode/awesome-coding-skills-cnSkill75mo agoMITA27Claude Code, Codex
executing-plansjnMetaCode/superpowers-zhSkill8.6k15d agoMITA46Claude Code
chinese-git-workflowjnMetaCode/superpowers-zhSkill8.6k15d agoMITA69Claude Code
chinese-code-reviewjnMetaCode/superpowers-zhSkill8.6k15d agoMITA62Claude Code
chinese-commit-conventionsjnMetaCode/superpowers-zhSkill8.6k15d agoMITA65Claude Code
chinese-documentationjnMetaCode/superpowers-zhSkill8.6k15d agoMITA62Claude Code
systematic-debuggingjnMetaCode/superpowers-zhSkill8.6k15d agoMITA24Claude Code