{"record":{"id":"9bdb64d23fe631b6","repo":"JuliusBrussee/caveman","slug":"skill-md-contains-credential-shaped-material","errorCode":null,"errorMessage":"SKILL.md contains credential-shaped material","messagePattern":"SKILL\\.md contains credential-shaped material","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":1590,"sourceCode":"function importedSkillSource(input: string): { root: string; file: string } {\n\tlet resolved: string;\n\ttry { resolved = realpathSync(resolve(process.cwd(), expandTilde(input))); } catch {\n\t\tthrow new Error(`source does not exist: ${input}`);\n\t}\n\tconst stat = lstatSync(resolved);\n\tconst file = stat.isDirectory() ? join(resolved, SKILL_MD) : resolved;\n\tif (!stat.isDirectory() && basename(resolved) !== SKILL_MD) throw new Error(\"source file must be named SKILL.md\");\n\tif (!hasFile(file)) throw new Error(`SKILL.md missing under ${resolved}`);\n\treturn { root: stat.isDirectory() ? resolved : dirname(resolved), file };\n}\n\nfunction cavemannifyImportedSkill(bytes: Buffer): { body: string; removedDuplicates: number; removedSeparators: number } {\n\tif (bytes.length === 0 || bytes.length > 256 * 1024) throw new Error(\"SKILL.md must be 1..262144 bytes\");\n\tif (bytes.includes(0)) throw new Error(\"SKILL.md contains NUL bytes\");\n\tconst text = bytes.toString(\"utf8\");\n\tif (!Buffer.from(text, \"utf8\").equals(bytes)) throw new Error(\"SKILL.md must be valid UTF-8\");\n\tif (/-----BEGIN [A-Z ]*PRIVATE KEY-----|\\b(?:sk|ghp|github_pat|xox[baprs])[-_][A-Za-z0-9_-]{16,}/i.test(text)) {\n\t\tthrow new Error(\"SKILL.md contains credential-shaped material\");\n\t}\n\tconst split = splitSkillMarkdown(bytes);\n\tif (!split) throw new Error(\"SKILL.md needs closed YAML frontmatter\");\n\tconst blocks = split.bodyText.trim().split(/\\r?\\n(?:[ \\t]*\\r?\\n)+/);\n\tconst seen = new Set<string>();\n\tconst kept: string[] = [];\n\tlet removedDuplicates = 0;\n\tlet removedSeparators = 0;\n\tfor (const block of blocks) {\n\t\tconst clean = block.trim();\n\t\tif (/^(?:---+|\\*\\*\\*+|___+)$/.test(clean)) {\n\t\t\tremovedSeparators++;\n\t\t\tcontinue;\n\t\t}\n\t\tconst identity = clean.replace(/\\s+/g, \" \");\n\t\tif (seen.has(identity)) {\n\t\t\tremovedDuplicates++;\n\t\t\tcontinue;","sourceCodeStart":1572,"sourceCodeEnd":1608,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L1572-L1608","documentation":"The importer scans the decoded SKILL.md text for credential-shaped material: PEM private key headers and API-token patterns (sk-, ghp-, github_pat-, xoxb/p/a/r/s- prefixes). Matches cause an immediate rejection to prevent secrets from being committed into skills.","triggerScenarios":"Running skill import on a SKILL.md whose text matches /-----BEGIN [A-Z ]*PRIVATE KEY-----/ or contains a token-like string such as 'sk-...' (note: the generic sk- prefix also matches non-OpenAI strings of sufficient length).","commonSituations":"Authoring a skill that embeds example API keys or real secrets; documentation that quotes a private key block; a long random slug beginning with 'sk-' or 'xoxa-' tripping the heuristic.","solutions":["Remove or redact the private key / token-like string from SKILL.md and re-import.","Replace example credentials with placeholders like <YOUR_API_KEY> or ${API_KEY}.","If a false positive (e.g. a benign 'sk-' prefixed slug), rewrite the string to avoid the credential prefix pattern."],"exampleFix":"// before (in SKILL.md)\napi_key = sk-abc123def456ghi789jk\n\n// after\napi_key = ${MY_API_KEY}","handlingStrategy":"validation","validationCode":"const text = readFileSync('SKILL.md', 'utf8');\nconst credPattern = /-----BEGIN [A-Z ]*PRIVATE KEY-----|\\b(?:sk|ghp|github_pat|xox[baprs])[-_][A-Za-z0-9_-]{16,}/i;\nif (credPattern.test(text)) throw new Error('remove credential-shaped material before import');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never paste real keys/tokens into skill docs; use ${ENV_VAR} placeholders","Run a secret scanner (gitleaks, trufflehog) on skill directories before import","Avoid naming example strings with 'sk-'/'ghp-'/'xox' prefixes"],"tags":["security","secrets","validation"],"backgroundTag":"missing-credentials","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}