Index of every page on this site: llms.txt
All skills
andreimerlescu avatar

/secure-code-standards

@eb35785
Run it yourself

Mandatory security-conscious engineering for every task that writes, edits, reviews, configures, builds, packages or ships code, scripts, Dockerfiles, CI, config or docs, and especially any task where the agent is handed, discovers or reads a credential, API key, token, password, private key, certificate, connection string, sample .env, or personal data. Forces the agent to classify sensitive material before touching it, keep secrets out of source, binaries, flag defaults, embeds, logs, tests, commits and chat, and to prove it with a scan. Language-agnostic with Go-specific rules; pairs with go-engineering-standards.

  • 19 files
  • 104.4 KB
  • Updated 4 weeks ago
  • GitHub
Use this Skill: https://skilld.dev/gh/andreimerlescu/skills/secure-code-standards

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

README.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

secure-code-standards — operator notes

Unique Visitors

This README is for the humans who install and run the skill. The model reads SKILL.md; it does not need this file.

What it fixes

Coding agents optimize for "it runs". Given a sample API key in a text file, an unaided agent will happily //go:embed the file and use the key as a flag default. It works, and it ships the key inside the binary, prints it in -h, and leaks it to everyone who receives the artifact. This skill gives the agent the instincts of a security-conscious engineer: classify sensitive material before touching it, inject it at runtime from outside the artifact, fail closed, redact by type, contain the source file, and prove all of that with a scan whose real output goes in the report.

Layout

secure-code-standards/
├── SKILL.md                    # always-loaded core: prime directive, protocol, channels, S1–S10, loop, report
├── references/                 # loaded on demand per the routing table
│   ├── secrets-lifecycle.md    # recognizing, reading, designing, rotating secrets
│   ├── go-secrets.md           # go:embed / flag defaults / ldflags traps, redacting Secret type, HTTP, files
│   ├── config-and-cli.md       # defaults, flags, config files, --help, env
│   ├── logging-and-disclosure.md
│   ├── build-and-supply-chain.md   # Docker, CI, ignore files, dependencies
│   ├── application-security.md # injection, SSRF, authn/z, crypto, DoS
│   ├── tests-and-docs.md       # hermetic tests, fixtures, docs, commits
│   ├── incident-response.md    # a secret has been exposed: rotate first
│   └── review-gates.md         # 13 gates + scoring
├── templates/go-secret/        # tested redacting Secret package (copy into a project)
├── scripts/secret-scan.sh      # the gate; never prints secret values
├── AGENTS.snippet.md           # paste into AGENTS.md so the skill always triggers
├── evals/scenarios.md          # prompts to verify the agent actually follows the skill
└── CHANGELOG.md

Install the whole directory: the core points at references/, templates/ and scripts/ by relative path.

Enabling it

  1. Copy the directory into your agent runtime's skills location.
  2. Paste AGENTS.snippet.md into the highest relevant AGENTS.md and fix the path.
  3. Run evals/scenarios.md S1, S2 and S5 and read the transcripts. It works when the agent writes a SENSITIVE: line, never copies the key, uses a path flag with an empty default, ignores keys.txt, and quotes a real SECRET-SCAN SUMMARY.

The scanner

bash scripts/secret-scan.sh                                   # changed files (or whole tree if clean)
bash scripts/secret-scan.sh --all                             # everything tracked and unignored
bash scripts/secret-scan.sh --literal-file keys.txt --artifact ./app   # known secret vs tree, git history, binary
bash scripts/secret-scan.sh --artifact image.tar              # from `docker save`
  • It reports rule ID, file and line only, never the matched value, so its output is safe to paste into a transcript.
  • Rules: credential formats (S1-PATTERN), literal assignments (S1-ASSIGN), embeds and whole-context COPY (S2-EMBED), flag/config defaults (S3-DEFAULT), argv/ldflags/build-arg/query-string secrets (S4-ARGV), secret-named files tracked or unignored (S8-TRACKED), known literals in tree/history (LITERAL) and built artifacts (ARTIFACT).
  • Exit codes: 0 clean, 1 findings, 2 usage, 3 nothing scanned.
  • It is a heuristic gate. Clean output is not proof of absence. Run gitleaks or trufflehog as well if you have them; the summary tells you whether they are installed.
  • The --literal-file search is the strongest check: it looks for the actual secret in source, git history, binaries and layers. Archive artifacts are searched as bytes, so compressed layers (.tar.gz) can hide a literal; extract or use an uncompressed docker save tar.
  • Scanning a repository that documents secret handling (like this one) reports the intentional "WRONG" examples. That is the scanner working.
  • Works with macOS's bash 3.2. Needs grep, find, sort, git (optional, for git-aware scope), strings (optional, for binaries).

The Go template

templates/go-secret/ is a drop-in secret package: a Secret type that prints [REDACTED] through fmt (every verb), encoding/json, encoding.TextMarshaler and log/slog; and FromFile, FromEnv and Resolve that fail closed, check permissions on the opened handle, bound the read, trim, and reject empty and placeholder values. Its tests prove the redaction and the failure modes. Run go test ./... inside a module after copying it.

Keeping it current

Re-check the credential patterns in scripts/secret-scan.sh when providers change key formats. Re-check the Go claims against the current release notes (embed semantics, os.Root, crypto/rand.Text). Authoritative sources:

Repository conventions outrank this skill's style preferences, never its security rules.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at eb35785. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated 4 weeks ago

README badge

README badge for andreimerlescu/skills/secure-code-standards