security-best-practices by tech-leads-club/agent-skills
npx skills add https://github.com/tech-leads-club/agent-skills --skill security-best-practices本技能描述了如何识别当前上下文所使用的语言和框架,然后从本技能的参考资料目录中加载关于该语言和/或框架的安全最佳实践信息。
如果存在此信息,可用于编写默认安全的新代码,或被动检测现有代码中的重大问题,或者(如果用户要求)提供漏洞报告并建议修复方案。
本技能的第一步是识别您被要求使用的或您正在处理的项目范围内已存在的所有语言和所有框架。重点关注核心的主要框架。通常,您需要识别前端和后端的语言和框架。
然后检查本技能的参考资料目录,查看是否有针对该语言和/或框架的相关文档。确保阅读与特定框架或语言相关的所有参考文件。文件名的格式为 <language>-<framework>-<stack>-security.md。您还应该检查是否存在 <language>-general-<stack>-security.md 文件,该文件与您可能使用的框架无关。
如果处理包含前端和后端的 Web 应用程序,请确保已检查前端和后端的参考文档!
如果要求您制作一个包含前端和后端的 Web 应用程序,但未指定前端框架,也请查看 javascript-general-web-frontend-security.md。理解如何保护前端和后端非常重要。
如果技能的参考资料目录中没有相关信息,请思考一下您对该语言、框架及其所有众所周知的安全最佳实践的了解。如果不确定,可以尝试在线搜索有关安全最佳实践的文档。
之后,它可以以几种方式运行。
主要模式:仅使用这些信息从此开始编写默认安全的代码。这对于启动新项目或编写新代码很有用。
次要模式:在项目中工作并为用户编写代码时,被动检测漏洞。可以标记关键或非常重要的漏洞或违反安全指南的重大问题,并告知用户。这种被动模式应侧重于影响最大的漏洞和安全默认设置。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
用户请求模式:用户可以要求生成安全报告或改进代码库的安全性。在这种情况下,应生成一份完整的报告,描述项目未能遵循安全最佳实践指南的任何方面。报告应区分优先级,并有清晰的严重性和紧急性部分。然后主动提出开始修复这些问题。请参阅下面的 #修复。
references/ 目录中存在匹配的指南,则仅加载相关文件并遵循其说明。虽然这些参考资料包含了针对语言和框架的安全最佳实践,但客户可能在某些情况下需要绕过或覆盖这些实践。请注意项目文档和提示文件中的特定规则和说明,这些可能要求您覆盖某些最佳实践。当覆盖最佳实践时,您可以向用户报告,但不要与他们争论。如果由于某些项目特定原因需要绕过/忽略某个安全最佳实践,您也可以建议将此记录添加到项目中,以便清楚地说明为什么不遵循该最佳实践,并在未来遵循该绕过方案。
生成报告时,您应将报告作为 Markdown 文件写入 security_best_practices_report.md 或用户提供的其他位置。您可以询问用户希望将报告写入何处。
报告顶部应有一个简短的执行摘要。
报告应根据漏洞的严重性清晰地划分为多个部分。报告应侧重于最关键的问题,因为它们对用户的影响最大。所有发现的问题都应标注数字 ID,以便于引用。
对于关键发现,请包含一句话的影响说明。
报告编写完成后,也应直接向用户报告,尽管可以简洁一些。如果用户希望了解更多关于任何发现的信息,您可以主动解释任何发现或安全最佳实践指南背后的原因。
重要提示:在报告中引用代码时,请确保找到并包含所引用代码的行号。
编写报告文件后,向用户总结发现的问题。
同时告知用户最终报告写入的位置。
如果您生成了报告,请让用户阅读报告并请求开始执行修复。
如果您被动发现了一个关键问题,请通知用户并询问他们是否希望您修复此问题。
生成修复时,请专注于一次修复一个发现的问题。修复应附有简洁明了的注释,解释新代码基于特定的安全最佳实践,并可能简要说明不这样做可能带来的危险。
始终考虑您想要进行的更改是否会影响用户代码的功能。考虑更改是否可能导致项目当前工作方式的回归。通常,不安全的代码可能由于其他原因而被依赖(这就是为什么不安全的代码会存在很长时间)。避免破坏用户的项目,因为这可能会使他们将来不愿意应用安全修复。最好是编写一个经过深思熟虑、充分了解项目其他部分的修复,而不是一个仓促的、草率的更改。
始终遵循用户配置的任何正常更改或提交流程。如果进行 git 提交,请提供清晰的提交消息,说明这是为了符合安全最佳实践。尽量避免将多个不相关的发现合并到一次提交中。
始终遵循用户配置的任何正常测试流程(如果有),以确认您的更改不会引入回归问题。考虑更改可能产生的二阶影响,并在进行更改之前(如果有的话)告知用户。
以下是一些适用于几乎所有语言或框架的安全编码建议。
在为某些资源分配 ID 时,如果该 ID 将暴露在互联网上使用,请避免使用小的自增 ID。应使用更长的、随机的 UUID4 或随机十六进制字符串。这将防止用户了解资源的数量并能够猜测资源 ID。
虽然 TLS 对于生产部署很重要,但大多数开发工作将在 TLS 禁用或由某些范围外的 TLS 代理提供的情况下进行。因此,要非常小心,不要将缺少 TLS 报告为安全问题。同样,在使用 "secure" cookie 时要非常小心。只有在应用程序确实通过 TLS 运行时才应设置它们。如果在非 TLS 应用程序上设置(例如在本地开发或测试部署时),将会破坏应用程序。您可以提供一个环境变量或其他标志来覆盖 secure 设置,以便在 TLS 生产部署之前保持其关闭状态。此外,避免推荐 HSTS。在不完全理解其持久影响(可能导致重大中断和用户锁定)的情况下使用它是危险的,并且在审查中通常不建议大多数项目使用。
每周安装数
77
代码仓库
GitHub 星标数
1.9K
首次出现
2026年2月5日
安全审计
安装于
gemini-cli69
codex68
opencode68
github-copilot67
amp63
kimi-cli63
This skill provides a description of how to identify the language and frameworks used by the current context, and then to load information from this skill's references directory about the security best practices for this language and or frameworks.
This information, if present, can be used to write new secure by default code, or to passively detect major issues within existing code, or (if requested by the user) provide a vulnerability report and suggest fixes.
The initial step for this skill is to identify ALL languages and ALL frameworks which you are being asked to use or already exist in the scope of the project you are working in. Focus on the primary core frameworks. Often you will want to identify both frontend and backend languages and frameworks.
Then check this skill's references directory to see if there are any relevant documentation for the language and or frameworks. Make sure you read ALL reference files which relate to the specific framework or language. The format of the filenames is <language>-<framework>-<stack>-security.md. You should also check if there is a <language>-general-<stack>-security.md which is agnostic to the framework you may be using.
If working on a web application which includes a frontend and a backend, make sure you have checked for reference documents for BOTH the frontend and backend!
If you are asked to make a web app which will include both a frontend and backend, but the frontend framework is not specified, also check out javascript-general-web-frontend-security.md. It is important that you understand how to secure both the frontend and backend.
If no relevant information is available in the skill's references directory, think a little bit about what you know about the language, the framework, and all well known security best practices for it. If you are unsure you can try to search online for documentation on security best practices.
From there it can operate in a few ways.
The primary mode is to just use the information to write secure by default code from this point forward. This is useful for starting a new project or when writing new code.
The secondary mode is to passively detect vulnerabilities while working in the project and writing code for the user. Critical or very important vulnerabilities or major issues going against security guidance can be flagged and the user can be told about them. This passive mode should focus on the largest impact vulnerabilities and secure defaults.
The user can ask for a security report or to improve the security of the codebase. In this case a full report should be produced describe anyways the project fails to follow security best practices guidance. The report should be prioritized and have clear sections of severity and urgency. Then offer to start working on fixes for these issues. See #fixes below.
references/, load only the relevant files and follow their instructions.While these references contain the security best practices for languages and frameworks, customers may have cases where they need to bypass or override these practices. Pay attention to specific rules and instructions in the project's documentation and prompt files which may require you to override certain best practices. When overriding a best practice, you MAY report it to the user, but do not fight with them. If a security best practice needs to be bypassed / ignored for some project specific reason, you can also suggest to add documentation about this to the project so it is clear why the best practice is not being followed and to follow that bypass in the future.
When producing a report, you should write the report as a markdown file in security_best_practices_report.md or some other location if provided by the user. You can ask the user where they would like the report to be written to.
The report should have a short executive summary at the top.
The report should be clearly delineated into multiple sections based on severity of the vulnerability. The report should focus on the most critical findings as these have the highest impact for the user. All findings should be noted with an numeric ID to make them easier to reference.
For critical findings include a one sentence impact statement.
Once the report is written, also report it to the user directly, although you may be less verbose. You can offer to explain any of the findings or the reasons behind the security best practices guidance if the user wants more info on any findings.
Important: When referencing code in the report, make sure to find and include line numbers for the code you are referencing.
After you write the report file, summarize the findings to the user.
Also tell the user where the final report was written to
If you produced a report, let the user read the report and ask to begin performing fixes.
If you passively found a critical finding, notify the user and ask if they would like you to fix this finding.
When producing fixes, focus on fixing a single finding at a time. The fixes should have concise clear comments explaining that the new code is based on the specific security best practice, and perhaps a very short reason why it would be dangerous to not do it in this way.
Always consider if the changes you want to make will impact the functionality of the user's code. Consider if the changes may cause regressions with how the project works currently. It is often the case that insecure code is relied on for other reasons (and this is why insecure code lives on for so long). Avoid breaking the user's project as this may make them not want to apply security fixes in the future. It is better to write a well thought out, well informed by the rest of the project, fix, then a quick slapdash change.
Always follow any normal change or commit flow the user has configured. If making git commits, provide clear commit messages explaining this is to align with security best practices. Try to avoid bunching a number of unrelated findings into a single commit.
Always follow any normal testing flows the user has configured (if any) to confirm that your changes are not introducing regressions. Consider the second order impacts the changes may have and inform the user before making them if there are any.
Below is a few bits of secure coding advice that applies to almost any language or framework.
When assigning an ID for some resource, which will then be used by exposed to the internet, avoid using small auto-incrementing IDs. Use longer, random UUID4 or random hex string instead. This will prevent users from learning the quantity of a resource and being able to guess resource IDs.
While TLS is important for production deployments, most development work will be with TLS disabled or provided by some out-of-scope TLS proxy. Due to this, be very careful about not reporting lack of TLS as a security issue. Also be very careful around use of "secure" cookies. They should only be set if the application will actually be over TLS. If they are set on non-TLS applications (such as when deployed for local dev or testing), it will break the application. You can provide a env or other flag to override setting secure as a way to keep it off until on a TLS production deployment. Additionally avoid recommending HSTS. It is dangerous to use without full understanding of the lasting impacts (can cause major outages and user lockout) and it is not generally recommended for most projects in review.
Weekly Installs
77
Repository
GitHub Stars
1.9K
First Seen
Feb 5, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli69
codex68
opencode68
github-copilot67
amp63
kimi-cli63
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
46,900 周安装
Intercom自动化指南:通过Rube MCP与Composio实现客户支持对话管理
69 周安装
二进制初步分析指南:使用ReVa工具快速识别恶意软件与逆向工程
69 周安装
PrivateInvestigator 道德人员查找工具 | 公开数据调查、反向搜索与背景研究
69 周安装
TorchTitan:PyTorch原生分布式大语言模型预训练平台,支持4D并行与H100 GPU加速
69 周安装
screenshot 截图技能:跨平台桌面截图工具,支持macOS/Linux权限管理与多模式捕获
69 周安装
tmux进程管理最佳实践:交互式Shell初始化、会话命名与生命周期管理
69 周安装