security-practices
Use when code touches a trust boundary — HTTP endpoints, webhooks, file uploads, auth, sessions, permissions, SQL or shell built from input, deserialization, service-to-service calls — when handling secrets, API keys, or .env files, on a CVE or vulnerability alert, when writing a threat model, or when choosing secret, SCA, SAST, or container scanners.
- License 许可
- MIT
- 所属仓库
- rahulmutt/devkit
- 最近更新
- 2026-10-19
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- security-practices
- description
- Use when code touches a trust boundary — HTTP endpoints, webhooks, file uploads, auth, sessions, permissions, SQL or shell built from input, deserialization, service-to-service calls — when handling secrets, API keys, or .env files, on a CVE or vulnerability alert, when writing a threat model, or when choosing secret, SCA, SAST, or container scanners.
02 资源文件 7
- 参考文档references/distributed-systems.md2.1 KB
- 参考文档references/go.md834 B
- 参考文档references/haskell.md842 B
- 参考文档references/python.md886 B
- 参考文档references/rust.md869 B
- 参考文档references/threat-model.md3.7 KB
- 参考文档references/typescript.md945 B
03 SKILL.md 正文
Security Practices
Treat every boundary as a trust decision. In a distributed system, every place data crosses a boundary — a network call, a queue, user input, another service, a dependency — is untrusted until proven otherwise. When you design or change a component, name the boundary, ask what crosses it and who controls that, and apply the control it demands. Defense in depth and least privilege are the two governing defaults: no single control is load-bearing, and every identity gets the narrowest access that still works.
Commit a threat model
The boundary lens above is reasoning you do in the moment; a threat model is that reasoning written down and committed to the repo. Without it, every agent and contributor re-derives what you are defending and against whom — usually incompletely. Commit the artifact so the assumptions are durable and discoverable: the assets you protect, the adversaries you assume, the boundaries that matter, and what is explicitly out of scope.
Write one when a component handles untrusted input, secrets, or
cross-trust-boundary traffic, and revisit it when those boundaries change. Keep
it in the repo (location is yours) and point to it from CLAUDE.md /
AGENTS.md so agents load it before touching security-sensitive code. Full
method and template →
references/threat-model.md.
Controls — match the boundary to its control
| Boundary / risk | Control | Reach for it when |
|---|---|---|
| Caller identity unknown | Authentication (service identity, tokens) | Any request crossing a service or trust boundary |
| Caller may exceed rights | Authorization, least privilege | The caller could reach data/actions beyond its scope |
| Untrusted network in path | Transport encryption (TLS / mTLS) | Anything leaving the process, especially service↔service |
| Input from outside | Validate & canonicalize at the edge | Parsing, deserializing, or trusting any external bytes |
| Credentials in the system | Secrets handling (inject at runtime) | Any key, token, or password the code needs |
| Endpoint abuse / replay | Rate limits, idempotency keys, timeouts | Public or expensive endpoints; non-idempotent writes |
| Code you did not write | Supply-chain trust (pin + scan deps) | Every third-party dependency |
For the reasoning behind these — boundary enumeration, hostile-network
assumptions, identity, and supply chain — read
references/distributed-systems.md.
Security tooling — match the scanner to the stack
Pick the categories that fit the repo and wire each where it catches problems earliest:
| Category | Catches | Integration point |
|---|---|---|
| Secret scanning | Committed credentials / keys | pre-commit (block) + CI |
| Dependency / SCA | Known CVEs in dependencies | CI gate + scheduled (new CVEs land on old code) |
| SAST | Vulnerable code patterns (injection, SSRF, unsafe deserialization) | CI |
| Container / IaC | Misconfig in Dockerfile / Terraform / k8s | CI — only when those artifacts exist |
Secret-scan-in-pre-commit and SCA-in-CI are non-negotiable hygiene, not optional
polish — the stance testing-practices takes on lint-in-CI. Container/IaC
scanning is conditional: run it only when the repo actually has those artifacts.
Universal tools (not language-specific)
- Secret scanning: gitleaks (default), trufflehog, or detect-secrets — language-agnostic; scan history and every commit.
- Container / IaC: Trivy (images, IaC, dependencies, and secrets in one), Checkov (IaC policy), hadolint (Dockerfile), kube-linter (Kubernetes).
Multi-purpose scanners (Trivy, osv-scanner) span several categories — prefer one that covers the need over stacking redundant tools.
Boundaries with sibling skills
- Scanner / tool installation →
developer-environment(mise-pinned, devenv.nix fallback). This skill names the tool and the idiom; it never gives install commands. - Workflow token permissions, action pinning, and where scanners sit in the
pipeline →
ci-pipelines.
References
references/distributed-systems.md— the full trust-boundary design lens.references/threat-model.md— how to write and commit a threat model (lightweight method + STRIDE deepening).- Per-language SCA + SAST tools:
references/typescript.md,references/python.md,references/rust.md,references/go.md,references/haskell.md.
04 同仓库更多 Skills
writing-clean-code
Use when refactoring or restructuring code, splitting a file or module that has grown too large, deciding whether to extract a helper or inline it, naming things, removing dead or unused code, drawing module or package boundaries, handling errors, writing comments, applying DDD or hexagonal (ports and adapters) architecture, or checking a language's idiomatic style.
using-devkit
Use when starting any conversation or new engineering task in a repo with devkit installed — establishes that devkit skills exist and must be checked before acting.
testing-practices
Use when writing, adding, or reviewing tests; choosing between unit, integration, snapshot/golden, property, fuzz, mutation, e2e/UI, or formal methods; when a test is flaky or the suite or CI is slow; or when deciding what runs in pre-commit, PR CI, or nightly.
navigable-codebases
Use when writing or updating a README, AGENTS.md, CLAUDE.md, GEMINI.md, ARCHITECTURE.md, or onboarding docs; when setting up a new repository; when adding or naming task-runner commands (mise tasks, Makefile, justfile, npm scripts); or when getting-started steps are missing, stale, or slow for newcomers.
developer-environment
Use when installing or upgrading any tool, runtime, CLI, or library — brew, apt, npm i -g, pip install, cargo install, nvm, pyenv, asdf — editing mise.toml or .tool-versions, bumping or pinning versions, adding a dependency, hitting "command not found", setting up a dev or CI toolchain, reviewing Renovate or Dependabot version bumps, or considering Bazel.
commits-and-releases
Use when writing commit messages or splitting work into commits; when cutting, versioning, or tagging a release; when editing a CHANGELOG or bumping a version number; when setting up or fixing release-please, semantic-release, or changesets; or when a release has the wrong version or is missing changelog entries.