[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DRXVWTRNFX9MNP6MS90T6G":3,"skill-same:01M6DRXVWTRNFX9MNP6MS90T6G":120},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":30,"linkOnly":31,"markdownContent":32,"markdownBody":33,"frontMatter":34,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":41,"install":42,"resources":55},"01M6DRXVWTRNFX9MNP6MS90T6G","k8s-yaml-validator",null,"Validate, lint, audit, or dry-run Kubernetes manifests (Deployment, Service, ConfigMap, CRD).","AntifragileTech\u002Fantifragile-claude-code","AntifragileTech","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F174357194?v=4","01M6DQCYMK4CDSQQAN0ZC72NTV","01M6DQCYS9YPW1WKMQ5TJMPQ43",9,"MIT","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29],"yaml","k8s","k8s yaml validator","kubernetes","validate","deployment","run","lint","audit","crd","service","dry","2026-11-10 10:12:30",false,"---\nname: k8s-yaml-validator\ndescription: Validate, lint, audit, or dry-run Kubernetes manifests (Deployment, Service, ConfigMap, CRD).\n---\n\n# Kubernetes YAML Validator\n\n## Overview\n\nThis skill provides a comprehensive validation workflow for Kubernetes YAML resources, combining syntax linting, schema validation, cluster dry-run testing, and intelligent CRD documentation lookup. Validate any Kubernetes manifest with confidence before applying it to the cluster.\n\n**IMPORTANT: This is a REPORT-ONLY validation tool.** Do NOT modify files, do NOT use Edit tool, do NOT use AskUserQuestion to offer fixes. Generate a comprehensive validation report with suggested fixes shown as before\u002Fafter code blocks, then let the user decide what to do next.\n\n## Trigger Phrases\n\nUse this skill when prompts look like:\n- \"Validate this Kubernetes YAML before deploy.\"\n- \"Lint these manifests and report what is broken.\"\n- \"Check this CRD manifest and explain schema issues.\"\n- \"Run dry-run checks on this manifest.\"\n- \"Find line-level errors in this multi-document YAML.\"\n\n## When to Use This Skill\n\nInvoke this skill when:\n- Validating Kubernetes YAML files before applying to a cluster\n- Debugging YAML syntax or formatting errors\n- Working with Custom Resource Definitions (CRDs) and need documentation\n- Performing dry-run tests to catch admission controller errors\n- Ensuring YAML follows Kubernetes best practices\n- Understanding what validation errors exist in manifests (report-only, user fixes manually)\n- The user asks to \"validate\", \"lint\", \"check\", or \"test\" Kubernetes YAML files\n\n## Read-Only Boundary (Mandatory)\n\nThis skill is strictly report-only:\n- Do NOT modify any user files.\n- Do NOT run Edit for fixes.\n- Do NOT ask for permission to apply fixes.\n- Do provide before\u002Fafter snippets as suggestions in the report.\n\n## Deterministic Path Setup\n\nRun with explicit paths so commands are repeatable:\n\n```bash\nREPO_ROOT=\"$(git rev-parse --show-toplevel 2>\u002Fdev\u002Fnull)\"\nSKILL_DIR=\"$REPO_ROOT\u002Fdevops-skills-plugin\u002Fskills\u002Fk8s-yaml-validator\"\nTARGET_FILE=\"$REPO_ROOT\u002F\u003Crelative\u002Fpath\u002Fto\u002Ffile.yaml>\"\n```\n\nPath checks:\n- If `REPO_ROOT` is empty, stop and ask for repository root.\n- If `SKILL_DIR` does not exist, stop and report path mismatch.\n- If `TARGET_FILE` does not exist, stop and ask for the correct file.\n\n## Validation Workflow\n\nFollow this sequential validation workflow. Each stage catches different types of issues:\n\n### Stage 0: Pre-Validation Setup (Deterministic Resource Count)\n\nBefore running validators, count documents using the bundled script:\n\n```bash\npython3 \"$SKILL_DIR\u002Fscripts\u002Fcount_yaml_documents.py\" \"$TARGET_FILE\"\n```\n\nExpected output (example):\n```json\n{\n  \"file\": \"...\u002Fmanifests.yaml\",\n  \"documents\": 3,\n  \"separators\": 2\n}\n```\n\nGate rules:\n- If `documents >= 3`, load `references\u002Fvalidation_workflow.md` before Stage 1.\n- Always include the document count in the final report summary.\n- If `python3` is unavailable, use fallback:\n```bash\nawk 'BEGIN{d=0;seen=0} \u002F^[[:space:]]*---[[:space:]]*$\u002F {if(seen){d++;seen=0}; next} \u002F^[[:space:]]*#\u002F {next} NF{seen=1} END{if(seen)d++; print d}' \"$TARGET_FILE\"\n```\nand mark the count as `estimated` in the report.\n\n### Stage 1: Tool Check\n\nBefore starting validation, verify required tools are installed:\n\n```bash\nbash \"$SKILL_DIR\u002Fscripts\u002Fsetup_tools.sh\"\n```\n\nRequired tools:\n- **yamllint**: YAML syntax and style linting\n- **kubeconform**: Kubernetes schema validation with CRD support\n- **kubectl**: Cluster dry-run testing (optional but recommended)\n\nIf tools are missing, display installation guidance from script output and continue with available tools. Document missing tools and skipped stages in the report.\n\n### Stage 2: YAML Syntax Validation\n\nValidate YAML syntax and formatting using yamllint:\n\n```bash\nyamllint -c \"$SKILL_DIR\u002Fassets\u002F.yamllint\" \"$TARGET_FILE\"\n```\n\n**Common issues caught:**\n- Indentation errors (tabs vs spaces)\n- Trailing whitespace\n- Line length violations\n- Syntax errors\n- Duplicate keys\n\n**Reporting approach:**\n- Report all syntax issues with file:line references\n- For fixable issues, show suggested before\u002Fafter code blocks\n- Continue to next validation stage to collect all issues before reporting\n\n### Stage 3: CRD Detection and Documentation Lookup\n\nBefore schema validation, detect if the YAML contains Custom Resource Definitions:\n\n```bash\nbash \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd_wrapper.sh\" \"$TARGET_FILE\"\n```\n\nThe wrapper script automatically handles Python dependencies by creating a temporary virtual environment if PyYAML is not available.\n\n**Resilient Parsing:** The script is resilient to syntax errors in individual documents. If a multi-document YAML file has some valid and some invalid documents, the script will:\n- Parse valid documents and detect their CRDs\n- Report errors for invalid documents but continue processing\n- This matches kubeconform's behavior of validating 2\u002F3 resources even when 1\u002F3 has syntax errors\n\nThe script outputs JSON with resource information and parse status:\n```json\n{\n  \"resources\": [\n    {\n      \"kind\": \"Certificate\",\n      \"apiVersion\": \"cert-manager.io\u002Fv1\",\n      \"group\": \"cert-manager.io\",\n      \"version\": \"v1\",\n      \"isCRD\": true,\n      \"name\": \"example-cert\"\n    }\n  ],\n  \"parseErrors\": [\n    {\n      \"document\": 1,\n      \"start_line\": 2,\n      \"error_line\": 6,\n      \"error\": \"mapping values are not allowed in this context\"\n    }\n  ],\n  \"summary\": {\n    \"totalDocuments\": 3,\n    \"parsedSuccessfully\": 2,\n    \"parseErrors\": 1,\n    \"crdsDetected\": 1\n  }\n}\n```\n\n**For each detected CRD:**\n\n1. **Try Context7 MCP first (preferred):**\n   - Resolve library:\n     - Tool: `mcp__context7__resolve-library-id`\n     - `libraryName`: CRD project name (example: `cert-manager` for `cert-manager.io`)\n   - Query docs:\n     - Tool: `mcp__context7__query-docs`\n     - `libraryId`: resolved library ID from previous step\n     - `query`: include CRD kind, group, and version (example: `Certificate cert-manager.io v1 required fields in spec`)\n\n2. **Fallback to `web.search_query` if Context7 fails or returns insufficient details:**\n   ```\n   Search query pattern:\n   \"\u003Ckind>\" \"\u003Cgroup>\" kubernetes CRD \"\u003Cversion>\" documentation spec\n\n   Example:\n   \"Certificate\" \"cert-manager.io\" kubernetes CRD \"v1\" documentation spec\n   ```\n\n3. **Extract key information:**\n   - Required fields in `spec`\n   - Field types and validation rules\n   - Examples from documentation\n   - Version-specific changes or deprecations\n\n**Secondary CRD Detection via kubeconform:** If `detect_crd_wrapper.sh` cannot identify CRDs (for example, syntax errors in all documents), but kubeconform still validates a CRD resource, look up docs for that CRD anyway. Parse kubeconform output to identify validated CRDs and perform Context7\u002F`web.search_query` lookups.\n\n**Why this matters:** CRDs have custom schemas not available in standard Kubernetes validation tools. Understanding the CRD's spec requirements prevents validation errors and ensures correct resource configuration.\n\n### Stage 4: Schema Validation\n\nValidate against Kubernetes schemas using kubeconform:\n\n```bash\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict \\\n  -ignore-missing-schemas \\\n  -summary \\\n  -verbose \\\n  \"$TARGET_FILE\"\n```\n\n**Options explained:**\n- `-strict`: Reject unknown fields (recommended for production - catches typos)\n- `-ignore-missing-schemas`: Skip validation for CRDs without available schemas\n- `-kubernetes-version 1.30.0`: Validate against specific K8s version\n\n**Common issues caught:**\n- Invalid apiVersion or kind\n- Missing required fields\n- Wrong field types\n- Invalid enum values\n- Unknown fields (with -strict)\n\n**For CRDs:** If kubeconform reports \"no schema found\", this is expected. Use the documentation from Stage 3 to manually validate the spec fields.\n\n**kubeconform line number behavior — two distinct cases:**\n\nkubeconform does NOT report file-absolute line numbers. You must translate:\n\n1. **Parse errors** (e.g. `error converting YAML to JSON: yaml: line N`):\n   - `N` is **document-relative** (line N within that document's content).\n   - Convert to file-absolute: `file_line = doc_start_line + N - 1`\n   - `doc_start_line` comes from the `start_line` field in `detect_crd_wrapper.sh` output.\n   - Example: document starts at file line 4, kubeconform says `yaml: line 5` →\n     file-absolute line = 4 + 5 − 1 = **line 8** (matches yamllint output).\n\n2. **Schema validation errors** (e.g. `got string, want integer`):\n   - kubeconform reports **JSON path only**, no line number.\n   - Example: `at '\u002Fspec\u002Ftemplate\u002Fspec\u002Fcontainers\u002F0\u002Fports\u002F0\u002FcontainerPort': got string, want integer`\n   - To find the line: search the YAML file for the field name (e.g. `containerPort`) within\n     the relevant document section, using file-absolute line numbers from the surrounding context.\n\nAlways present line numbers as file-absolute in the validation report even when translating\nfrom kubeconform's document-relative output.\n\n### Stage 5: Cluster Dry-Run (if available)\n\n**IMPORTANT: Always try server-side dry-run first.** Server-side validation catches more issues than client-side because it runs through admission controllers and webhooks.\n\n**Decision Tree:**\n\n```\n1. Try server-side dry-run first:\n   kubectl apply --dry-run=server -f \"$TARGET_FILE\"\n\n   └─ If SUCCESS → Use results, continue to Stage 6\n\n   └─ If FAILS with connection error (e.g., \"connection refused\",\n      \"unable to connect\", \"no configuration\"):\n      │\n      ├─ 2. Attempt client-side dry-run (parse-only fallback):\n      │     kubectl apply --dry-run=client --validate=false -f \"$TARGET_FILE\"\n      │\n      │     ├─ If SUCCESS:\n      │     │    Document in report: \"Server-side validation skipped (no cluster access); client fallback ran in parse-only mode\"\n      │     │\n      │     └─ If FAILS with discovery\u002Fopenapi error (e.g., \"unable to recognize\",\n      │        \"failed to download openapi\", \"couldn't get current server API group list\"):\n      │        Document in report: \"Dry-run skipped (cluster discovery unavailable)\"\n      │        Continue to Stage 6\n      │\n      └─ If FAILS with validation error (e.g., \"admission webhook denied\",\n         \"resource quota exceeded\", \"invalid value\"):\n         └─ Record the error, continue to Stage 6\n\n   └─ If FAILS with parse error (e.g., \"error converting YAML to JSON\",\n      \"yaml: line X: mapping values are not allowed\"):\n      └─ Record the error, skip client-side dry-run (same error will occur)\n         Document in report: \"Dry-run blocked by YAML syntax errors - fix syntax first\"\n         Continue to Stage 6\n```\n\n**Note:** Parse errors from earlier stages (yamllint, kubeconform) will also cause dry-run to fail. Do NOT attempt client-side dry-run as a fallback for parse errors - it will produce the same error. Parse errors must be fixed before dry-run validation can proceed.\n\n**Server-side dry-run catches:**\n- Admission controller rejections\n- Policy violations (PSP, OPA, Kyverno, etc.)\n- Resource quota violations\n- Missing namespaces\n- Invalid ConfigMap\u002FSecret references\n- Webhook validations\n\n**Client-side dry-run with `--validate=false` catches (fallback, when command succeeds):**\n- YAML\u002FJSON conversion and request-construction issues\n- Whether `kubectl` can process and submit the manifest shape in client mode\n- **Note:** `--validate=false` disables schema\u002Ftype\u002Frequired-field validation and still does NOT catch admission controller or policy issues.\n\n**Document in your report which mode was used:**\n- If server-side: \"Full cluster validation performed\"\n- If client-side with `--validate=false`: \"Limited parse-only validation (no cluster access) - schema and admission policies not checked\"\n- If skipped: \"Dry-run skipped - kubectl not available\"\n- If skipped after client fallback attempt: \"Dry-run skipped (cluster discovery unavailable)\"\n\n**For updates to existing resources:**\n```bash\nkubectl diff -f \"$TARGET_FILE\"\n```\nThis shows what would change, helping catch unintended modifications.\n\n### Stage 6: Generate Detailed Validation Report (REPORT ONLY)\n\nAfter completing all validation stages, generate a comprehensive report. **This is a REPORT-ONLY stage.**\n\n**NEVER do any of the following:**\n- Do NOT use the Edit tool to modify files\n- Do NOT use AskUserQuestion to offer to fix issues\n- Do NOT prompt the user asking if they want fixes applied\n- Do NOT modify any YAML files\n\n**ALWAYS do the following:**\n- Generate a comprehensive validation report\n- Show before\u002Fafter code blocks as SUGGESTIONS only\n- Let the user decide what to do after reviewing the report\n- End with \"Next Steps\" for the user to take manually\n\n1. **Summarize all issues found** across all stages in a table format:\n\n   ```\n   | Severity | Stage | Location | Issue | Suggested Fix |\n   |----------|-------|----------|-------|---------------|\n   | Error | Syntax | file.yaml:5 | Indentation error | Use 2 spaces |\n   | Error | Schema | file.yaml:21 | Wrong type | Change to integer |\n   | Warning | Best Practice | file.yaml:30 | Missing labels | Add app label |\n   ```\n\n2. **Categorize by severity:**\n   - **Errors** (must fix): Syntax errors, missing required fields, dry-run failures\n   - **Warnings** (should fix): Style issues, best practice violations\n   - **Info** (optional): Suggestions for improvement\n\n3. **Show before\u002Fafter code blocks for each issue:**\n\n   For every issue, display explicit before\u002Fafter YAML snippets showing the suggested fix:\n\n   ```\n   **Issue 1: deployment.yaml:21 - Wrong field type (Error)**\n\n   Current:\n   ```yaml\n           - containerPort: \"80\"\n   ```\n\n   Suggested Fix:\n   ```yaml\n           - containerPort: 80\n   ```\n\n   **Why:** containerPort must be an integer, not a string. Kubernetes will reject string values.\n   Reference: See k8s_best_practices.md \"Invalid Values\" section.\n   ```\n\n4. **Provide validation summary:**\n\n   ```\n   ## Validation Report Summary\n\n   File: deployment.yaml\n   Resources Analyzed: 3 (Deployment, Service, Certificate)\n\n   | Stage | Status | Issues Found |\n   |-------|--------|--------------|\n   | YAML Syntax | ❌ Failed | 2 errors |\n   | CRD Detection | ✅ Passed | 1 CRD detected (Certificate) |\n   | Schema Validation | ❌ Failed | 1 error |\n   | Dry-Run | ❌ Failed | 1 error |\n\n   Total Issues: 4 errors, 2 warnings\n\n   ## Detailed Findings\n\n   [List each issue with before\u002Fafter code blocks as shown above]\n\n   ## Next Steps\n\n   1. Fix the 4 errors listed above (deployment will fail without these)\n   2. Consider addressing the 2 warnings for best practices\n   3. Re-run validation after fixes to confirm resolution\n   ```\n\n5. **Do NOT modify files** - this is a reporting tool only\n   - Present all findings clearly\n   - Let the user decide which fixes to apply\n   - User can request fixes after reviewing the report\n\n## Objective Stage Gates (Repeatable)\n\nUse this table to keep stage decisions deterministic:\n\n| Stage | Required | Command | Pass\u002FFail Criteria | Fallback |\n|------|----------|---------|--------------------|----------|\n| 0 Resource Count | Yes | `python3 \"$SKILL_DIR\u002Fscripts\u002Fcount_yaml_documents.py\" \"$TARGET_FILE\"` | Pass when count output is produced and `documents` is recorded. | Use AWK estimator and mark `estimated`. |\n| 1 Tool Check | Yes | `bash \"$SKILL_DIR\u002Fscripts\u002Fsetup_tools.sh\"` | Pass when command runs and tool availability is known. | Continue with available tools and log skips. |\n| 2 YAML Syntax | If `yamllint` available | `yamllint -c \"$SKILL_DIR\u002Fassets\u002F.yamllint\" \"$TARGET_FILE\"` | Pass on exit code `0`; fail on lint errors. | Skip with explicit reason if missing binary. |\n| 3 CRD Detection | If `python3` available | `bash \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd_wrapper.sh\" \"$TARGET_FILE\"` | Pass when JSON output includes `summary`. | Skip CRD extraction and rely on kubeconform clues. |\n| 4 Schema | If `kubeconform` available | kubeconform command from Stage 4 | Pass when kubeconform reports valid resources. | Skip and record as coverage gap if missing binary. |\n| 5 Dry-Run | If `kubectl` available | `kubectl apply --dry-run=server -f \"$TARGET_FILE\"` | Pass on successful server dry-run. | Attempt parse-only client fallback with `--dry-run=client --validate=false`; if discovery still fails, mark stage skipped. |\n| 6 Report | Yes | Report generation | Pass when summary + per-issue snippets + next steps are provided. | No fallback; this stage is mandatory. |\n\n## Fallback Matrix\n\n| Constraint | Action | Report Language |\n|-----------|--------|-----------------|\n| `python3` unavailable | Skip `count_yaml_documents.py` and CRD parser scripts. Use AWK count only. | `Python runtime unavailable; CRD parser skipped, resource count is estimated.` |\n| `yamllint` unavailable | Skip Stage 2; continue with schema\u002Fdry-run stages if available. | `YAML lint skipped because yamllint is not installed.` |\n| `kubeconform` unavailable | Skip Stage 4; run lint and dry-run only. | `Schema validation skipped because kubeconform is not installed.` |\n| `kubectl` unavailable | Skip Stage 5 entirely. | `Dry-run skipped because kubectl is not installed.` |\n| No cluster connectivity | Run server-side first, then attempt parse-only client fallback with `--dry-run=client --validate=false`; if it still fails, skip dry-run and continue. | `Server-side dry-run unavailable due cluster access; parse-only client-side dry-run attempted (schema checks disabled).` |\n| Client dry-run still requires discovery | Treat dry-run as unavailable and rely on lint + schema stages. | `Dry-run skipped (cluster discovery unavailable); lint and schema results used.` |\n| External docs unavailable | Continue local validation and state documentation gap. | `CRD documentation lookup deferred due tooling\u002Fnetwork limitation.` |\n\n## Best Practices Reference\n\nFor detailed Kubernetes YAML best practices, load the reference:\n```\nRead \"$SKILL_DIR\u002Freferences\u002Fk8s_best_practices.md\"\n```\n\nThis reference includes:\n- Metadata and label conventions\n- Resource limits and requests\n- Security context guidelines\n- Probe configurations\n- Common validation issues and fixes\n\n**When to load (ALWAYS load in these cases):**\n- Schema validation fails with type errors (e.g., string vs integer, invalid values)\n- Schema validation reports missing required fields\n- kubeconform reports invalid field values or unknown fields\n- Dry-run fails with validation errors related to resources, probes, or security\n- When explaining why a fix is needed (to provide context from best practices)\n\n## Detailed Validation Workflow Reference\n\nFor in-depth workflow details and error handling strategies, load the reference:\n```\nRead \"$SKILL_DIR\u002Freferences\u002Fvalidation_workflow.md\"\n```\n\nThis reference includes:\n- Detailed command options for each tool\n- Error handling strategies\n- Multi-resource file handling\n- Complete workflow diagram\n- Troubleshooting guide\n\n**When to load (ALWAYS load in these cases):**\n- File contains 3 or more resources (multi-document YAML)\n- Validation produces errors you haven't seen before or can't immediately diagnose\n- Need to understand the complete workflow for debugging\n- Errors span multiple validation stages\n\n## Working with Multiple Resources\n\nWhen a YAML file contains multiple resources (separated by `---`):\n\n1. **Validate the entire file first** with yamllint and kubeconform\n2. **If errors occur, identify which resource** has issues by checking line numbers\n3. **For dry-run**, the file is tested as a unit (Kubernetes processes in order)\n4. **Track issues per-resource** when presenting findings to the user\n\n### Partial Parsing Behavior\n\nWhen a multi-document YAML file has some valid and some invalid documents:\n\n**Expected behavior:**\n- The CRD detection script (`detect_crd.py`) will parse valid documents and skip invalid ones\n- kubeconform will validate resources it can parse and report errors for unparseable ones\n- The validation report should clearly show which documents parsed and which failed\n\n**Example scenario:**\nA file with 3 documents where document 1 has a syntax error:\n- Document 1 (Deployment): Syntax error at line 8\n- Document 2 (Service): Valid\n- Document 3 (Certificate CRD): Valid\n\n**Expected output:**\n- CRD detection: Finds Certificate CRD from document 3\n- kubeconform: Reports error for document 1, validates documents 2 and 3\n- Report: Shows syntax error for document 1, validation results for documents 2 and 3\n\n**In your report:**\n```\n| Document | Resource | Parsing | Validation |\n|----------|----------|---------|------------|\n| 1 | Deployment | ❌ Syntax error (line 8) | Skipped |\n| 2 | Service | ✅ Parsed | ✅ Valid |\n| 3 | Certificate | ✅ Parsed | ✅ Valid |\n```\n\n**Line Number Reference Style:**\n- **Always use file-absolute line numbers** (line numbers relative to the start of the entire file)\n- This matches what yamllint, kubeconform, and kubectl report\n- Example: If a file has 3 documents and the error is in document 2 which starts at line 35, report as \"line 42\" (the absolute line in the file), not \"line 7\" (relative to document start)\n- This consistency makes it easy for users to navigate directly to the error in their editor\n\nThis ensures users get maximum validation feedback even when some documents have issues.\n\n## Error Handling Strategies\n\n### Tool Not Available\n- Run `bash \"$SKILL_DIR\u002Fscripts\u002Fsetup_tools.sh\"` to check availability\n- Provide installation instructions\n- Skip optional stages but document what was skipped\n- Continue with available tools\n\n### Cluster Access Issues\n- Attempt parse-only client-side dry-run with `--dry-run=client --validate=false`\n- Treat this fallback as transport\u002Fparsing signal only (`--validate=false` disables schema\u002Ftype\u002Frequired-field checks)\n- If client dry-run still fails with API discovery\u002Fopenapi errors, skip dry-run and rely on lint\u002Fschema stages\n- Document limitations in validation report\n\n### CRD Documentation Not Found\n- Document that documentation lookup failed\n- Attempt validation with kubeconform CRD schemas\n- Suggest manual CRD inspection:\n  ```bash\n  kubectl get crd \u003Ccrd-name>.group -o yaml\n  kubectl explain \u003Ckind>\n  ```\n\n### Validation Stage Failures\n- Continue to next stage even if one fails\n- Collect all errors before presenting to user\n- Prioritize fixing earlier stage errors first\n\n## Communication Guidelines\n\nWhen presenting validation results:\n\n1. **Be clear and concise** about what was found\n2. **Explain why issues matter** (e.g., \"This will cause pod creation to fail\")\n3. **Provide context** from best practices when relevant\n4. **Group related issues** (e.g., all missing label issues together)\n5. **Use file:line references** for all issues\n6. **Show fix complexity** - Include a complexity indicator in the issue header:\n   - **[Simple]**: Single-line fixes like indentation, typos, or value changes\n   - **[Medium]**: Multi-line changes or adding missing fields\u002Fsections\n   - **[Complex]**: Logic changes, restructuring, or changes affecting multiple resources\n\n   Example format in issue header:\n   ```\n   **Issue 1: deployment.yaml:8 - Wrong indentation (Error) [Simple]**\n   **Issue 2: deployment.yaml:15-25 - Missing security context (Warning) [Medium]**\n   **Issue 3: deployment.yaml - Selector mismatch with Service (Error) [Complex]**\n   ```\n7. **Always provide a comprehensive report** including:\n   - Summary table of all issues by stage\n   - Before\u002Fafter code blocks for each issue\n   - Total count of errors and warnings\n   - Clear next steps for the user\n8. **NEVER offer to apply fixes** - this is strictly a reporting tool\n   - Do not ask \"Would you like me to fix this?\"\n   - Do not use AskUserQuestion for fix confirmations\n   - Present the report and let the user take action\n\n## Performance Optimization\n\n### Parallel Tool Execution\n\nFor improved validation speed, some stages can be executed in parallel:\n\n**Can run in parallel (no dependencies):**\n- `yamllint` (Stage 2) and `detect_crd_wrapper.sh` (Stage 3) can run simultaneously\n- Both tools operate independently on the input file\n- Results from both are needed before proceeding to schema validation\n\n**Example parallel execution:**\n```\n# Run these in parallel (using & and wait, or parallel tool calls):\nyamllint -c \"$SKILL_DIR\u002Fassets\u002F.yamllint\" \"$TARGET_FILE\"\nbash \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd_wrapper.sh\" \"$TARGET_FILE\"\n```\n\n**Must run sequentially:**\n- Stage 0 (Resource Count Check) → Before all other stages\n- Stage 1 (Tool Check) → Before using any tools\n- Stage 4 (Schema Validation) → After CRD detection (needs CRD info for context)\n- Stage 5 (Dry-Run) → After schema validation\n- Stage 6 (Report) → After all validation stages complete\n\n**When to parallelize:**\n- Files with more than 5 resources benefit most from parallel execution\n- For small files (1-2 resources), sequential execution is fine\n\n## Version Awareness\n\nAlways consider Kubernetes version compatibility:\n- Check for deprecated APIs (e.g., `extensions\u002Fv1beta1` → `apps\u002Fv1`)\n- For CRDs, ensure the apiVersion matches what's in the cluster\n- Use `kubectl api-versions` to list available API versions in the cluster\n- Reference version-specific documentation when available\n\n## Test Coverage Guidance\n\nThe `test\u002F` directory contains example files to exercise all validation paths. Use these to verify skill behavior.\n\n### Test Files\n\n| Test File | Purpose | Expected Behavior |\n|-----------|---------|-------------------|\n| `deployment-test.yaml` | Valid standard K8s resource | All stages pass, no errors |\n| `certificate-crd-test.yaml` | Valid CRD resource | CRD detected, Context7 lookup performed, no errors |\n| `comprehensive-test.yaml` | Multi-resource with intentional YAML syntax error | Syntax error detected, partial parsing works, CRD found |\n| `schema-errors-test.yaml` | Valid YAML with intentional schema type errors | yamllint passes; kubeconform fails with 2 JSON-path errors (replicas, containerPort) |\n\n### Validation Paths to Test\n\n1. **Happy Path (All Valid)**\n   - File: `deployment-test.yaml`\n   - Expected: All stages pass, report shows \"0 errors, 0 warnings\"\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fdeployment-test.yaml\nyamllint -c assets\u002F.yamllint test\u002Fdeployment-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fdeployment-test.yaml\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict -ignore-missing-schemas -summary -verbose \\\n  test\u002Fdeployment-test.yaml\nkubectl apply --dry-run=server -f test\u002Fdeployment-test.yaml\n```\n\n2. **CRD Detection Path**\n   - File: `certificate-crd-test.yaml`\n   - Expected: CRD detected, `mcp__context7__resolve-library-id` and `mcp__context7__query-docs` used\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fcertificate-crd-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fcertificate-crd-test.yaml\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict -ignore-missing-schemas -summary -verbose \\\n  test\u002Fcertificate-crd-test.yaml\n```\n\n3. **Syntax Error Path**\n   - File: `comprehensive-test.yaml`\n   - Expected: yamllint catches error, kubeconform reports partial validation, dry-run blocked\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fcomprehensive-test.yaml\nyamllint -c assets\u002F.yamllint test\u002Fcomprehensive-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fcomprehensive-test.yaml\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict -ignore-missing-schemas -summary -verbose \\\n  test\u002Fcomprehensive-test.yaml\nkubectl apply --dry-run=server -f test\u002Fcomprehensive-test.yaml\n```\n\n4. **Multi-Resource Partial Parsing**\n   - File: `comprehensive-test.yaml` (has 3 resources, 1 with syntax error)\n   - Expected: 2\u002F3 resources validated, parse error reported for document 1\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fcomprehensive-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fcomprehensive-test.yaml\n```\n\n5. **Schema Validation Error Path (type mismatches)**\n   - File: `schema-errors-test.yaml`\n   - Expected: yamllint passes (valid YAML), kubeconform fails with 2 JSON-path schema errors\n   - Note: kubeconform reports JSON paths, not line numbers — locate fields manually in the YAML\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fschema-errors-test.yaml\nyamllint -c assets\u002F.yamllint test\u002Fschema-errors-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fschema-errors-test.yaml\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict -ignore-missing-schemas -summary -verbose \\\n  test\u002Fschema-errors-test.yaml\n```\n\n6. **No Cluster Access Path**\n   - Any valid file with no kubectl cluster configured\n   - Expected: Server-side dry-run fails; parse-only client-side fallback is attempted (no schema guarantees) and may still fail if API discovery is unavailable\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\nKUBECONFIG=\u002Ftmp\u002Fnonexistent-kubeconfig kubectl apply --dry-run=server -f test\u002Fdeployment-test.yaml\nKUBECONFIG=\u002Ftmp\u002Fnonexistent-kubeconfig kubectl apply --dry-run=client --validate=false -f test\u002Fdeployment-test.yaml\n```\n\n7. **Missing Tools Path**\n   - Test by temporarily removing a tool from PATH\n   - Expected: setup_tools.sh reports missing tools and prints install instructions, validation continues with available tools\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\nPATH=\"\u002Fusr\u002Fbin:\u002Fbin\" bash scripts\u002Fsetup_tools.sh\n```\n\n### Creating New Test Files\n\nWhen adding test files:\n1. Name files descriptively: `\u003Cscenario>-test.yaml`\n2. Document expected behavior in comments at top of file\n3. Include intentional errors for error-path tests\n4. Test both standard K8s resources and CRDs\n\n### Expected Report Structure\n\nFor any validation, the report should include:\n- [ ] Summary table with issue counts by severity\n- [ ] Stage-by-stage status table (passed\u002Ffailed\u002Fskipped)\n- [ ] Document parsing table (for multi-resource files)\n- [ ] Before\u002Fafter code blocks for each issue\n- [ ] Fix complexity indicators ([Simple], [Medium], [Complex])\n- [ ] File-absolute line numbers\n- [ ] \"Next Steps\" section\n\n## Done Criteria\n\nValidation is complete only when all conditions are true:\n- Stage gates were evaluated in order and every skipped stage includes a reason.\n- Resource count came from `count_yaml_documents.py` (or documented AWK fallback).\n- CRD lookups used `mcp__context7__resolve-library-id` + `mcp__context7__query-docs`, with `web.search_query` fallback only when needed.\n- Report-only boundary was preserved (no edits, no fix-application prompts).\n- Output includes exact commands run, findings by severity, and manual next steps.\n\n## Resources\n\n### scripts\u002F\n\n**detect_crd_wrapper.sh**\n- Wrapper script that handles Python dependency management\n- Automatically creates temporary venv if PyYAML is not available\n- Calls detect_crd.py to parse YAML files\n- Usage: `bash \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd_wrapper.sh\" \"$TARGET_FILE\"`\n\n**detect_crd.py**\n- Parses YAML files to identify Custom Resource Definitions\n- Extracts kind, apiVersion, group, and version information\n- Outputs JSON for programmatic processing\n- Requires PyYAML (handled automatically by wrapper script)\n- Can be called directly: `python3 \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd.py\" \"$TARGET_FILE\"`\n\n**count_yaml_documents.py**\n- Deterministically counts non-empty YAML documents in a multi-doc file\n- Returns JSON with document count and separators\n- Use before Stage 1 to decide whether to load deep workflow reference\n- Usage: `python3 \"$SKILL_DIR\u002Fscripts\u002Fcount_yaml_documents.py\" \"$TARGET_FILE\"`\n\n**setup_tools.sh**\n- Checks for required validation tools\n- Provides installation instructions for missing tools\n- Verifies versions of installed tools\n- Usage: `bash \"$SKILL_DIR\u002Fscripts\u002Fsetup_tools.sh\"`\n\n### references\u002F\n\n**k8s_best_practices.md**\n- Comprehensive guide to Kubernetes YAML best practices\n- Covers metadata, labels, resource limits, security context\n- Common validation issues and how to fix them\n- Load when providing context for validation errors\n\n**validation_workflow.md**\n- Detailed validation workflow with all stages\n- Command options and configurations\n- Error handling strategies\n- Complete workflow diagram\n- Load for complex validation scenarios\n\n### assets\u002F\n\n**.yamllint**\n- Pre-configured yamllint rules for Kubernetes YAML\n- Follows Kubernetes conventions (2-space indentation, line length, etc.)\n- Can be customized per project\n- Usage: `yamllint -c \"$SKILL_DIR\u002Fassets\u002F.yamllint\" \"$TARGET_FILE\"`\n","# Kubernetes YAML Validator\n\n## Overview\n\nThis skill provides a comprehensive validation workflow for Kubernetes YAML resources, combining syntax linting, schema validation, cluster dry-run testing, and intelligent CRD documentation lookup. Validate any Kubernetes manifest with confidence before applying it to the cluster.\n\n**IMPORTANT: This is a REPORT-ONLY validation tool.** Do NOT modify files, do NOT use Edit tool, do NOT use AskUserQuestion to offer fixes. Generate a comprehensive validation report with suggested fixes shown as before\u002Fafter code blocks, then let the user decide what to do next.\n\n## Trigger Phrases\n\nUse this skill when prompts look like:\n- \"Validate this Kubernetes YAML before deploy.\"\n- \"Lint these manifests and report what is broken.\"\n- \"Check this CRD manifest and explain schema issues.\"\n- \"Run dry-run checks on this manifest.\"\n- \"Find line-level errors in this multi-document YAML.\"\n\n## When to Use This Skill\n\nInvoke this skill when:\n- Validating Kubernetes YAML files before applying to a cluster\n- Debugging YAML syntax or formatting errors\n- Working with Custom Resource Definitions (CRDs) and need documentation\n- Performing dry-run tests to catch admission controller errors\n- Ensuring YAML follows Kubernetes best practices\n- Understanding what validation errors exist in manifests (report-only, user fixes manually)\n- The user asks to \"validate\", \"lint\", \"check\", or \"test\" Kubernetes YAML files\n\n## Read-Only Boundary (Mandatory)\n\nThis skill is strictly report-only:\n- Do NOT modify any user files.\n- Do NOT run Edit for fixes.\n- Do NOT ask for permission to apply fixes.\n- Do provide before\u002Fafter snippets as suggestions in the report.\n\n## Deterministic Path Setup\n\nRun with explicit paths so commands are repeatable:\n\n```bash\nREPO_ROOT=\"$(git rev-parse --show-toplevel 2>\u002Fdev\u002Fnull)\"\nSKILL_DIR=\"$REPO_ROOT\u002Fdevops-skills-plugin\u002Fskills\u002Fk8s-yaml-validator\"\nTARGET_FILE=\"$REPO_ROOT\u002F\u003Crelative\u002Fpath\u002Fto\u002Ffile.yaml>\"\n```\n\nPath checks:\n- If `REPO_ROOT` is empty, stop and ask for repository root.\n- If `SKILL_DIR` does not exist, stop and report path mismatch.\n- If `TARGET_FILE` does not exist, stop and ask for the correct file.\n\n## Validation Workflow\n\nFollow this sequential validation workflow. Each stage catches different types of issues:\n\n### Stage 0: Pre-Validation Setup (Deterministic Resource Count)\n\nBefore running validators, count documents using the bundled script:\n\n```bash\npython3 \"$SKILL_DIR\u002Fscripts\u002Fcount_yaml_documents.py\" \"$TARGET_FILE\"\n```\n\nExpected output (example):\n```json\n{\n  \"file\": \"...\u002Fmanifests.yaml\",\n  \"documents\": 3,\n  \"separators\": 2\n}\n```\n\nGate rules:\n- If `documents >= 3`, load `references\u002Fvalidation_workflow.md` before Stage 1.\n- Always include the document count in the final report summary.\n- If `python3` is unavailable, use fallback:\n```bash\nawk 'BEGIN{d=0;seen=0} \u002F^[[:space:]]*---[[:space:]]*$\u002F {if(seen){d++;seen=0}; next} \u002F^[[:space:]]*#\u002F {next} NF{seen=1} END{if(seen)d++; print d}' \"$TARGET_FILE\"\n```\nand mark the count as `estimated` in the report.\n\n### Stage 1: Tool Check\n\nBefore starting validation, verify required tools are installed:\n\n```bash\nbash \"$SKILL_DIR\u002Fscripts\u002Fsetup_tools.sh\"\n```\n\nRequired tools:\n- **yamllint**: YAML syntax and style linting\n- **kubeconform**: Kubernetes schema validation with CRD support\n- **kubectl**: Cluster dry-run testing (optional but recommended)\n\nIf tools are missing, display installation guidance from script output and continue with available tools. Document missing tools and skipped stages in the report.\n\n### Stage 2: YAML Syntax Validation\n\nValidate YAML syntax and formatting using yamllint:\n\n```bash\nyamllint -c \"$SKILL_DIR\u002Fassets\u002F.yamllint\" \"$TARGET_FILE\"\n```\n\n**Common issues caught:**\n- Indentation errors (tabs vs spaces)\n- Trailing whitespace\n- Line length violations\n- Syntax errors\n- Duplicate keys\n\n**Reporting approach:**\n- Report all syntax issues with file:line references\n- For fixable issues, show suggested before\u002Fafter code blocks\n- Continue to next validation stage to collect all issues before reporting\n\n### Stage 3: CRD Detection and Documentation Lookup\n\nBefore schema validation, detect if the YAML contains Custom Resource Definitions:\n\n```bash\nbash \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd_wrapper.sh\" \"$TARGET_FILE\"\n```\n\nThe wrapper script automatically handles Python dependencies by creating a temporary virtual environment if PyYAML is not available.\n\n**Resilient Parsing:** The script is resilient to syntax errors in individual documents. If a multi-document YAML file has some valid and some invalid documents, the script will:\n- Parse valid documents and detect their CRDs\n- Report errors for invalid documents but continue processing\n- This matches kubeconform's behavior of validating 2\u002F3 resources even when 1\u002F3 has syntax errors\n\nThe script outputs JSON with resource information and parse status:\n```json\n{\n  \"resources\": [\n    {\n      \"kind\": \"Certificate\",\n      \"apiVersion\": \"cert-manager.io\u002Fv1\",\n      \"group\": \"cert-manager.io\",\n      \"version\": \"v1\",\n      \"isCRD\": true,\n      \"name\": \"example-cert\"\n    }\n  ],\n  \"parseErrors\": [\n    {\n      \"document\": 1,\n      \"start_line\": 2,\n      \"error_line\": 6,\n      \"error\": \"mapping values are not allowed in this context\"\n    }\n  ],\n  \"summary\": {\n    \"totalDocuments\": 3,\n    \"parsedSuccessfully\": 2,\n    \"parseErrors\": 1,\n    \"crdsDetected\": 1\n  }\n}\n```\n\n**For each detected CRD:**\n\n1. **Try Context7 MCP first (preferred):**\n   - Resolve library:\n     - Tool: `mcp__context7__resolve-library-id`\n     - `libraryName`: CRD project name (example: `cert-manager` for `cert-manager.io`)\n   - Query docs:\n     - Tool: `mcp__context7__query-docs`\n     - `libraryId`: resolved library ID from previous step\n     - `query`: include CRD kind, group, and version (example: `Certificate cert-manager.io v1 required fields in spec`)\n\n2. **Fallback to `web.search_query` if Context7 fails or returns insufficient details:**\n   ```\n   Search query pattern:\n   \"\u003Ckind>\" \"\u003Cgroup>\" kubernetes CRD \"\u003Cversion>\" documentation spec\n\n   Example:\n   \"Certificate\" \"cert-manager.io\" kubernetes CRD \"v1\" documentation spec\n   ```\n\n3. **Extract key information:**\n   - Required fields in `spec`\n   - Field types and validation rules\n   - Examples from documentation\n   - Version-specific changes or deprecations\n\n**Secondary CRD Detection via kubeconform:** If `detect_crd_wrapper.sh` cannot identify CRDs (for example, syntax errors in all documents), but kubeconform still validates a CRD resource, look up docs for that CRD anyway. Parse kubeconform output to identify validated CRDs and perform Context7\u002F`web.search_query` lookups.\n\n**Why this matters:** CRDs have custom schemas not available in standard Kubernetes validation tools. Understanding the CRD's spec requirements prevents validation errors and ensures correct resource configuration.\n\n### Stage 4: Schema Validation\n\nValidate against Kubernetes schemas using kubeconform:\n\n```bash\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict \\\n  -ignore-missing-schemas \\\n  -summary \\\n  -verbose \\\n  \"$TARGET_FILE\"\n```\n\n**Options explained:**\n- `-strict`: Reject unknown fields (recommended for production - catches typos)\n- `-ignore-missing-schemas`: Skip validation for CRDs without available schemas\n- `-kubernetes-version 1.30.0`: Validate against specific K8s version\n\n**Common issues caught:**\n- Invalid apiVersion or kind\n- Missing required fields\n- Wrong field types\n- Invalid enum values\n- Unknown fields (with -strict)\n\n**For CRDs:** If kubeconform reports \"no schema found\", this is expected. Use the documentation from Stage 3 to manually validate the spec fields.\n\n**kubeconform line number behavior — two distinct cases:**\n\nkubeconform does NOT report file-absolute line numbers. You must translate:\n\n1. **Parse errors** (e.g. `error converting YAML to JSON: yaml: line N`):\n   - `N` is **document-relative** (line N within that document's content).\n   - Convert to file-absolute: `file_line = doc_start_line + N - 1`\n   - `doc_start_line` comes from the `start_line` field in `detect_crd_wrapper.sh` output.\n   - Example: document starts at file line 4, kubeconform says `yaml: line 5` →\n     file-absolute line = 4 + 5 − 1 = **line 8** (matches yamllint output).\n\n2. **Schema validation errors** (e.g. `got string, want integer`):\n   - kubeconform reports **JSON path only**, no line number.\n   - Example: `at '\u002Fspec\u002Ftemplate\u002Fspec\u002Fcontainers\u002F0\u002Fports\u002F0\u002FcontainerPort': got string, want integer`\n   - To find the line: search the YAML file for the field name (e.g. `containerPort`) within\n     the relevant document section, using file-absolute line numbers from the surrounding context.\n\nAlways present line numbers as file-absolute in the validation report even when translating\nfrom kubeconform's document-relative output.\n\n### Stage 5: Cluster Dry-Run (if available)\n\n**IMPORTANT: Always try server-side dry-run first.** Server-side validation catches more issues than client-side because it runs through admission controllers and webhooks.\n\n**Decision Tree:**\n\n```\n1. Try server-side dry-run first:\n   kubectl apply --dry-run=server -f \"$TARGET_FILE\"\n\n   └─ If SUCCESS → Use results, continue to Stage 6\n\n   └─ If FAILS with connection error (e.g., \"connection refused\",\n      \"unable to connect\", \"no configuration\"):\n      │\n      ├─ 2. Attempt client-side dry-run (parse-only fallback):\n      │     kubectl apply --dry-run=client --validate=false -f \"$TARGET_FILE\"\n      │\n      │     ├─ If SUCCESS:\n      │     │    Document in report: \"Server-side validation skipped (no cluster access); client fallback ran in parse-only mode\"\n      │     │\n      │     └─ If FAILS with discovery\u002Fopenapi error (e.g., \"unable to recognize\",\n      │        \"failed to download openapi\", \"couldn't get current server API group list\"):\n      │        Document in report: \"Dry-run skipped (cluster discovery unavailable)\"\n      │        Continue to Stage 6\n      │\n      └─ If FAILS with validation error (e.g., \"admission webhook denied\",\n         \"resource quota exceeded\", \"invalid value\"):\n         └─ Record the error, continue to Stage 6\n\n   └─ If FAILS with parse error (e.g., \"error converting YAML to JSON\",\n      \"yaml: line X: mapping values are not allowed\"):\n      └─ Record the error, skip client-side dry-run (same error will occur)\n         Document in report: \"Dry-run blocked by YAML syntax errors - fix syntax first\"\n         Continue to Stage 6\n```\n\n**Note:** Parse errors from earlier stages (yamllint, kubeconform) will also cause dry-run to fail. Do NOT attempt client-side dry-run as a fallback for parse errors - it will produce the same error. Parse errors must be fixed before dry-run validation can proceed.\n\n**Server-side dry-run catches:**\n- Admission controller rejections\n- Policy violations (PSP, OPA, Kyverno, etc.)\n- Resource quota violations\n- Missing namespaces\n- Invalid ConfigMap\u002FSecret references\n- Webhook validations\n\n**Client-side dry-run with `--validate=false` catches (fallback, when command succeeds):**\n- YAML\u002FJSON conversion and request-construction issues\n- Whether `kubectl` can process and submit the manifest shape in client mode\n- **Note:** `--validate=false` disables schema\u002Ftype\u002Frequired-field validation and still does NOT catch admission controller or policy issues.\n\n**Document in your report which mode was used:**\n- If server-side: \"Full cluster validation performed\"\n- If client-side with `--validate=false`: \"Limited parse-only validation (no cluster access) - schema and admission policies not checked\"\n- If skipped: \"Dry-run skipped - kubectl not available\"\n- If skipped after client fallback attempt: \"Dry-run skipped (cluster discovery unavailable)\"\n\n**For updates to existing resources:**\n```bash\nkubectl diff -f \"$TARGET_FILE\"\n```\nThis shows what would change, helping catch unintended modifications.\n\n### Stage 6: Generate Detailed Validation Report (REPORT ONLY)\n\nAfter completing all validation stages, generate a comprehensive report. **This is a REPORT-ONLY stage.**\n\n**NEVER do any of the following:**\n- Do NOT use the Edit tool to modify files\n- Do NOT use AskUserQuestion to offer to fix issues\n- Do NOT prompt the user asking if they want fixes applied\n- Do NOT modify any YAML files\n\n**ALWAYS do the following:**\n- Generate a comprehensive validation report\n- Show before\u002Fafter code blocks as SUGGESTIONS only\n- Let the user decide what to do after reviewing the report\n- End with \"Next Steps\" for the user to take manually\n\n1. **Summarize all issues found** across all stages in a table format:\n\n   ```\n   | Severity | Stage | Location | Issue | Suggested Fix |\n   |----------|-------|----------|-------|---------------|\n   | Error | Syntax | file.yaml:5 | Indentation error | Use 2 spaces |\n   | Error | Schema | file.yaml:21 | Wrong type | Change to integer |\n   | Warning | Best Practice | file.yaml:30 | Missing labels | Add app label |\n   ```\n\n2. **Categorize by severity:**\n   - **Errors** (must fix): Syntax errors, missing required fields, dry-run failures\n   - **Warnings** (should fix): Style issues, best practice violations\n   - **Info** (optional): Suggestions for improvement\n\n3. **Show before\u002Fafter code blocks for each issue:**\n\n   For every issue, display explicit before\u002Fafter YAML snippets showing the suggested fix:\n\n   ```\n   **Issue 1: deployment.yaml:21 - Wrong field type (Error)**\n\n   Current:\n   ```yaml\n           - containerPort: \"80\"\n   ```\n\n   Suggested Fix:\n   ```yaml\n           - containerPort: 80\n   ```\n\n   **Why:** containerPort must be an integer, not a string. Kubernetes will reject string values.\n   Reference: See k8s_best_practices.md \"Invalid Values\" section.\n   ```\n\n4. **Provide validation summary:**\n\n   ```\n   ## Validation Report Summary\n\n   File: deployment.yaml\n   Resources Analyzed: 3 (Deployment, Service, Certificate)\n\n   | Stage | Status | Issues Found |\n   |-------|--------|--------------|\n   | YAML Syntax | ❌ Failed | 2 errors |\n   | CRD Detection | ✅ Passed | 1 CRD detected (Certificate) |\n   | Schema Validation | ❌ Failed | 1 error |\n   | Dry-Run | ❌ Failed | 1 error |\n\n   Total Issues: 4 errors, 2 warnings\n\n   ## Detailed Findings\n\n   [List each issue with before\u002Fafter code blocks as shown above]\n\n   ## Next Steps\n\n   1. Fix the 4 errors listed above (deployment will fail without these)\n   2. Consider addressing the 2 warnings for best practices\n   3. Re-run validation after fixes to confirm resolution\n   ```\n\n5. **Do NOT modify files** - this is a reporting tool only\n   - Present all findings clearly\n   - Let the user decide which fixes to apply\n   - User can request fixes after reviewing the report\n\n## Objective Stage Gates (Repeatable)\n\nUse this table to keep stage decisions deterministic:\n\n| Stage | Required | Command | Pass\u002FFail Criteria | Fallback |\n|------|----------|---------|--------------------|----------|\n| 0 Resource Count | Yes | `python3 \"$SKILL_DIR\u002Fscripts\u002Fcount_yaml_documents.py\" \"$TARGET_FILE\"` | Pass when count output is produced and `documents` is recorded. | Use AWK estimator and mark `estimated`. |\n| 1 Tool Check | Yes | `bash \"$SKILL_DIR\u002Fscripts\u002Fsetup_tools.sh\"` | Pass when command runs and tool availability is known. | Continue with available tools and log skips. |\n| 2 YAML Syntax | If `yamllint` available | `yamllint -c \"$SKILL_DIR\u002Fassets\u002F.yamllint\" \"$TARGET_FILE\"` | Pass on exit code `0`; fail on lint errors. | Skip with explicit reason if missing binary. |\n| 3 CRD Detection | If `python3` available | `bash \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd_wrapper.sh\" \"$TARGET_FILE\"` | Pass when JSON output includes `summary`. | Skip CRD extraction and rely on kubeconform clues. |\n| 4 Schema | If `kubeconform` available | kubeconform command from Stage 4 | Pass when kubeconform reports valid resources. | Skip and record as coverage gap if missing binary. |\n| 5 Dry-Run | If `kubectl` available | `kubectl apply --dry-run=server -f \"$TARGET_FILE\"` | Pass on successful server dry-run. | Attempt parse-only client fallback with `--dry-run=client --validate=false`; if discovery still fails, mark stage skipped. |\n| 6 Report | Yes | Report generation | Pass when summary + per-issue snippets + next steps are provided. | No fallback; this stage is mandatory. |\n\n## Fallback Matrix\n\n| Constraint | Action | Report Language |\n|-----------|--------|-----------------|\n| `python3` unavailable | Skip `count_yaml_documents.py` and CRD parser scripts. Use AWK count only. | `Python runtime unavailable; CRD parser skipped, resource count is estimated.` |\n| `yamllint` unavailable | Skip Stage 2; continue with schema\u002Fdry-run stages if available. | `YAML lint skipped because yamllint is not installed.` |\n| `kubeconform` unavailable | Skip Stage 4; run lint and dry-run only. | `Schema validation skipped because kubeconform is not installed.` |\n| `kubectl` unavailable | Skip Stage 5 entirely. | `Dry-run skipped because kubectl is not installed.` |\n| No cluster connectivity | Run server-side first, then attempt parse-only client fallback with `--dry-run=client --validate=false`; if it still fails, skip dry-run and continue. | `Server-side dry-run unavailable due cluster access; parse-only client-side dry-run attempted (schema checks disabled).` |\n| Client dry-run still requires discovery | Treat dry-run as unavailable and rely on lint + schema stages. | `Dry-run skipped (cluster discovery unavailable); lint and schema results used.` |\n| External docs unavailable | Continue local validation and state documentation gap. | `CRD documentation lookup deferred due tooling\u002Fnetwork limitation.` |\n\n## Best Practices Reference\n\nFor detailed Kubernetes YAML best practices, load the reference:\n```\nRead \"$SKILL_DIR\u002Freferences\u002Fk8s_best_practices.md\"\n```\n\nThis reference includes:\n- Metadata and label conventions\n- Resource limits and requests\n- Security context guidelines\n- Probe configurations\n- Common validation issues and fixes\n\n**When to load (ALWAYS load in these cases):**\n- Schema validation fails with type errors (e.g., string vs integer, invalid values)\n- Schema validation reports missing required fields\n- kubeconform reports invalid field values or unknown fields\n- Dry-run fails with validation errors related to resources, probes, or security\n- When explaining why a fix is needed (to provide context from best practices)\n\n## Detailed Validation Workflow Reference\n\nFor in-depth workflow details and error handling strategies, load the reference:\n```\nRead \"$SKILL_DIR\u002Freferences\u002Fvalidation_workflow.md\"\n```\n\nThis reference includes:\n- Detailed command options for each tool\n- Error handling strategies\n- Multi-resource file handling\n- Complete workflow diagram\n- Troubleshooting guide\n\n**When to load (ALWAYS load in these cases):**\n- File contains 3 or more resources (multi-document YAML)\n- Validation produces errors you haven't seen before or can't immediately diagnose\n- Need to understand the complete workflow for debugging\n- Errors span multiple validation stages\n\n## Working with Multiple Resources\n\nWhen a YAML file contains multiple resources (separated by `---`):\n\n1. **Validate the entire file first** with yamllint and kubeconform\n2. **If errors occur, identify which resource** has issues by checking line numbers\n3. **For dry-run**, the file is tested as a unit (Kubernetes processes in order)\n4. **Track issues per-resource** when presenting findings to the user\n\n### Partial Parsing Behavior\n\nWhen a multi-document YAML file has some valid and some invalid documents:\n\n**Expected behavior:**\n- The CRD detection script (`detect_crd.py`) will parse valid documents and skip invalid ones\n- kubeconform will validate resources it can parse and report errors for unparseable ones\n- The validation report should clearly show which documents parsed and which failed\n\n**Example scenario:**\nA file with 3 documents where document 1 has a syntax error:\n- Document 1 (Deployment): Syntax error at line 8\n- Document 2 (Service): Valid\n- Document 3 (Certificate CRD): Valid\n\n**Expected output:**\n- CRD detection: Finds Certificate CRD from document 3\n- kubeconform: Reports error for document 1, validates documents 2 and 3\n- Report: Shows syntax error for document 1, validation results for documents 2 and 3\n\n**In your report:**\n```\n| Document | Resource | Parsing | Validation |\n|----------|----------|---------|------------|\n| 1 | Deployment | ❌ Syntax error (line 8) | Skipped |\n| 2 | Service | ✅ Parsed | ✅ Valid |\n| 3 | Certificate | ✅ Parsed | ✅ Valid |\n```\n\n**Line Number Reference Style:**\n- **Always use file-absolute line numbers** (line numbers relative to the start of the entire file)\n- This matches what yamllint, kubeconform, and kubectl report\n- Example: If a file has 3 documents and the error is in document 2 which starts at line 35, report as \"line 42\" (the absolute line in the file), not \"line 7\" (relative to document start)\n- This consistency makes it easy for users to navigate directly to the error in their editor\n\nThis ensures users get maximum validation feedback even when some documents have issues.\n\n## Error Handling Strategies\n\n### Tool Not Available\n- Run `bash \"$SKILL_DIR\u002Fscripts\u002Fsetup_tools.sh\"` to check availability\n- Provide installation instructions\n- Skip optional stages but document what was skipped\n- Continue with available tools\n\n### Cluster Access Issues\n- Attempt parse-only client-side dry-run with `--dry-run=client --validate=false`\n- Treat this fallback as transport\u002Fparsing signal only (`--validate=false` disables schema\u002Ftype\u002Frequired-field checks)\n- If client dry-run still fails with API discovery\u002Fopenapi errors, skip dry-run and rely on lint\u002Fschema stages\n- Document limitations in validation report\n\n### CRD Documentation Not Found\n- Document that documentation lookup failed\n- Attempt validation with kubeconform CRD schemas\n- Suggest manual CRD inspection:\n  ```bash\n  kubectl get crd \u003Ccrd-name>.group -o yaml\n  kubectl explain \u003Ckind>\n  ```\n\n### Validation Stage Failures\n- Continue to next stage even if one fails\n- Collect all errors before presenting to user\n- Prioritize fixing earlier stage errors first\n\n## Communication Guidelines\n\nWhen presenting validation results:\n\n1. **Be clear and concise** about what was found\n2. **Explain why issues matter** (e.g., \"This will cause pod creation to fail\")\n3. **Provide context** from best practices when relevant\n4. **Group related issues** (e.g., all missing label issues together)\n5. **Use file:line references** for all issues\n6. **Show fix complexity** - Include a complexity indicator in the issue header:\n   - **[Simple]**: Single-line fixes like indentation, typos, or value changes\n   - **[Medium]**: Multi-line changes or adding missing fields\u002Fsections\n   - **[Complex]**: Logic changes, restructuring, or changes affecting multiple resources\n\n   Example format in issue header:\n   ```\n   **Issue 1: deployment.yaml:8 - Wrong indentation (Error) [Simple]**\n   **Issue 2: deployment.yaml:15-25 - Missing security context (Warning) [Medium]**\n   **Issue 3: deployment.yaml - Selector mismatch with Service (Error) [Complex]**\n   ```\n7. **Always provide a comprehensive report** including:\n   - Summary table of all issues by stage\n   - Before\u002Fafter code blocks for each issue\n   - Total count of errors and warnings\n   - Clear next steps for the user\n8. **NEVER offer to apply fixes** - this is strictly a reporting tool\n   - Do not ask \"Would you like me to fix this?\"\n   - Do not use AskUserQuestion for fix confirmations\n   - Present the report and let the user take action\n\n## Performance Optimization\n\n### Parallel Tool Execution\n\nFor improved validation speed, some stages can be executed in parallel:\n\n**Can run in parallel (no dependencies):**\n- `yamllint` (Stage 2) and `detect_crd_wrapper.sh` (Stage 3) can run simultaneously\n- Both tools operate independently on the input file\n- Results from both are needed before proceeding to schema validation\n\n**Example parallel execution:**\n```\n# Run these in parallel (using & and wait, or parallel tool calls):\nyamllint -c \"$SKILL_DIR\u002Fassets\u002F.yamllint\" \"$TARGET_FILE\"\nbash \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd_wrapper.sh\" \"$TARGET_FILE\"\n```\n\n**Must run sequentially:**\n- Stage 0 (Resource Count Check) → Before all other stages\n- Stage 1 (Tool Check) → Before using any tools\n- Stage 4 (Schema Validation) → After CRD detection (needs CRD info for context)\n- Stage 5 (Dry-Run) → After schema validation\n- Stage 6 (Report) → After all validation stages complete\n\n**When to parallelize:**\n- Files with more than 5 resources benefit most from parallel execution\n- For small files (1-2 resources), sequential execution is fine\n\n## Version Awareness\n\nAlways consider Kubernetes version compatibility:\n- Check for deprecated APIs (e.g., `extensions\u002Fv1beta1` → `apps\u002Fv1`)\n- For CRDs, ensure the apiVersion matches what's in the cluster\n- Use `kubectl api-versions` to list available API versions in the cluster\n- Reference version-specific documentation when available\n\n## Test Coverage Guidance\n\nThe `test\u002F` directory contains example files to exercise all validation paths. Use these to verify skill behavior.\n\n### Test Files\n\n| Test File | Purpose | Expected Behavior |\n|-----------|---------|-------------------|\n| `deployment-test.yaml` | Valid standard K8s resource | All stages pass, no errors |\n| `certificate-crd-test.yaml` | Valid CRD resource | CRD detected, Context7 lookup performed, no errors |\n| `comprehensive-test.yaml` | Multi-resource with intentional YAML syntax error | Syntax error detected, partial parsing works, CRD found |\n| `schema-errors-test.yaml` | Valid YAML with intentional schema type errors | yamllint passes; kubeconform fails with 2 JSON-path errors (replicas, containerPort) |\n\n### Validation Paths to Test\n\n1. **Happy Path (All Valid)**\n   - File: `deployment-test.yaml`\n   - Expected: All stages pass, report shows \"0 errors, 0 warnings\"\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fdeployment-test.yaml\nyamllint -c assets\u002F.yamllint test\u002Fdeployment-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fdeployment-test.yaml\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict -ignore-missing-schemas -summary -verbose \\\n  test\u002Fdeployment-test.yaml\nkubectl apply --dry-run=server -f test\u002Fdeployment-test.yaml\n```\n\n2. **CRD Detection Path**\n   - File: `certificate-crd-test.yaml`\n   - Expected: CRD detected, `mcp__context7__resolve-library-id` and `mcp__context7__query-docs` used\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fcertificate-crd-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fcertificate-crd-test.yaml\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict -ignore-missing-schemas -summary -verbose \\\n  test\u002Fcertificate-crd-test.yaml\n```\n\n3. **Syntax Error Path**\n   - File: `comprehensive-test.yaml`\n   - Expected: yamllint catches error, kubeconform reports partial validation, dry-run blocked\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fcomprehensive-test.yaml\nyamllint -c assets\u002F.yamllint test\u002Fcomprehensive-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fcomprehensive-test.yaml\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict -ignore-missing-schemas -summary -verbose \\\n  test\u002Fcomprehensive-test.yaml\nkubectl apply --dry-run=server -f test\u002Fcomprehensive-test.yaml\n```\n\n4. **Multi-Resource Partial Parsing**\n   - File: `comprehensive-test.yaml` (has 3 resources, 1 with syntax error)\n   - Expected: 2\u002F3 resources validated, parse error reported for document 1\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fcomprehensive-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fcomprehensive-test.yaml\n```\n\n5. **Schema Validation Error Path (type mismatches)**\n   - File: `schema-errors-test.yaml`\n   - Expected: yamllint passes (valid YAML), kubeconform fails with 2 JSON-path schema errors\n   - Note: kubeconform reports JSON paths, not line numbers — locate fields manually in the YAML\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\npython3 scripts\u002Fcount_yaml_documents.py test\u002Fschema-errors-test.yaml\nyamllint -c assets\u002F.yamllint test\u002Fschema-errors-test.yaml\nbash scripts\u002Fdetect_crd_wrapper.sh test\u002Fschema-errors-test.yaml\nkubeconform \\\n  -schema-location default \\\n  -schema-location 'https:\u002F\u002Fraw.githubusercontent.com\u002Fdatreeio\u002FCRDs-catalog\u002Fmain\u002F{{.Group}}\u002F{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \\\n  -strict -ignore-missing-schemas -summary -verbose \\\n  test\u002Fschema-errors-test.yaml\n```\n\n6. **No Cluster Access Path**\n   - Any valid file with no kubectl cluster configured\n   - Expected: Server-side dry-run fails; parse-only client-side fallback is attempted (no schema guarantees) and may still fail if API discovery is unavailable\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\nKUBECONFIG=\u002Ftmp\u002Fnonexistent-kubeconfig kubectl apply --dry-run=server -f test\u002Fdeployment-test.yaml\nKUBECONFIG=\u002Ftmp\u002Fnonexistent-kubeconfig kubectl apply --dry-run=client --validate=false -f test\u002Fdeployment-test.yaml\n```\n\n7. **Missing Tools Path**\n   - Test by temporarily removing a tool from PATH\n   - Expected: setup_tools.sh reports missing tools and prints install instructions, validation continues with available tools\n   - Commands:\n```bash\ncd \"$SKILL_DIR\"\nPATH=\"\u002Fusr\u002Fbin:\u002Fbin\" bash scripts\u002Fsetup_tools.sh\n```\n\n### Creating New Test Files\n\nWhen adding test files:\n1. Name files descriptively: `\u003Cscenario>-test.yaml`\n2. Document expected behavior in comments at top of file\n3. Include intentional errors for error-path tests\n4. Test both standard K8s resources and CRDs\n\n### Expected Report Structure\n\nFor any validation, the report should include:\n- [ ] Summary table with issue counts by severity\n- [ ] Stage-by-stage status table (passed\u002Ffailed\u002Fskipped)\n- [ ] Document parsing table (for multi-resource files)\n- [ ] Before\u002Fafter code blocks for each issue\n- [ ] Fix complexity indicators ([Simple], [Medium], [Complex])\n- [ ] File-absolute line numbers\n- [ ] \"Next Steps\" section\n\n## Done Criteria\n\nValidation is complete only when all conditions are true:\n- Stage gates were evaluated in order and every skipped stage includes a reason.\n- Resource count came from `count_yaml_documents.py` (or documented AWK fallback).\n- CRD lookups used `mcp__context7__resolve-library-id` + `mcp__context7__query-docs`, with `web.search_query` fallback only when needed.\n- Report-only boundary was preserved (no edits, no fix-application prompts).\n- Output includes exact commands run, findings by severity, and manual next steps.\n\n## Resources\n\n### scripts\u002F\n\n**detect_crd_wrapper.sh**\n- Wrapper script that handles Python dependency management\n- Automatically creates temporary venv if PyYAML is not available\n- Calls detect_crd.py to parse YAML files\n- Usage: `bash \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd_wrapper.sh\" \"$TARGET_FILE\"`\n\n**detect_crd.py**\n- Parses YAML files to identify Custom Resource Definitions\n- Extracts kind, apiVersion, group, and version information\n- Outputs JSON for programmatic processing\n- Requires PyYAML (handled automatically by wrapper script)\n- Can be called directly: `python3 \"$SKILL_DIR\u002Fscripts\u002Fdetect_crd.py\" \"$TARGET_FILE\"`\n\n**count_yaml_documents.py**\n- Deterministically counts non-empty YAML documents in a multi-doc file\n- Returns JSON with document count and separators\n- Use before Stage 1 to decide whether to load deep workflow reference\n- Usage: `python3 \"$SKILL_DIR\u002Fscripts\u002Fcount_yaml_documents.py\" \"$TARGET_FILE\"`\n\n**setup_tools.sh**\n- Checks for required validation tools\n- Provides installation instructions for missing tools\n- Verifies versions of installed tools\n- Usage: `bash \"$SKILL_DIR\u002Fscripts\u002Fsetup_tools.sh\"`\n\n### references\u002F\n\n**k8s_best_practices.md**\n- Comprehensive guide to Kubernetes YAML best practices\n- Covers metadata, labels, resource limits, security context\n- Common validation issues and how to fix them\n- Load when providing context for validation errors\n\n**validation_workflow.md**\n- Detailed validation workflow with all stages\n- Command options and configurations\n- Error handling strategies\n- Complete workflow diagram\n- Load for complex validation scenarios\n\n### assets\u002F\n\n**.yamllint**\n- Pre-configured yamllint rules for Kubernetes YAML\n- Follows Kubernetes conventions (2-space indentation, line length, etc.)\n- Can be customized per project\n- Usage: `yamllint -c \"$SKILL_DIR\u002Fassets\u002F.yamllint\" \"$TARGET_FILE\"`\n",{"name":5,"description":7},"master","c73386b305dec167db7654e0e6feacb462d4f9dc","assets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator",1,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code","https:\u002F\u002Fgithub.com\u002FAntifragileTech","2026-10-02 14:22:14",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add AntifragileTech\u002Fantifragile-claude-code --skill k8s-yaml-validator",{"tool":48,"command":49},"bunx","bunx skills add AntifragileTech\u002Fantifragile-claude-code --skill k8s-yaml-validator",{"tool":51,"command":52},"pnpm","pnpm dlx skills add AntifragileTech\u002Fantifragile-claude-code --skill k8s-yaml-validator","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002FSKILL.md",true,[56,62,68,74,78,84,88,92,96,100,104,108,112,116],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},".gitignore","OTHER","其他",288,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002F.gitignore",{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"assets\u002F.yamllint","ASSET","资产文件",1642,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Fassets\u002F.yamllint",{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fk8s_best_practices.md","REFERENCE","参考文档",3659,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Freferences\u002Fk8s_best_practices.md",{"path":75,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fvalidation_workflow.md",13884,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Freferences\u002Fvalidation_workflow.md",{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"scripts\u002Fcount_yaml_documents.py","SCRIPT","脚本",2154,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Fscripts\u002Fcount_yaml_documents.py",{"path":85,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":86,"sourceHtmlUrl":87},"scripts\u002Fdetect_crd_wrapper.sh",1005,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Fscripts\u002Fdetect_crd_wrapper.sh",{"path":89,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":90,"sourceHtmlUrl":91},"scripts\u002Fdetect_crd.py",9530,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Fscripts\u002Fdetect_crd.py",{"path":93,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":94,"sourceHtmlUrl":95},"scripts\u002Fsetup_tools.sh",2376,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Fscripts\u002Fsetup_tools.sh",{"path":97,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":98,"sourceHtmlUrl":99},"scripts\u002Ftest_count_yaml_documents.py",3169,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Fscripts\u002Ftest_count_yaml_documents.py",{"path":101,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":102,"sourceHtmlUrl":103},"test\u002Fcertificate-crd-test.yaml",248,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Ftest\u002Fcertificate-crd-test.yaml",{"path":105,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":106,"sourceHtmlUrl":107},"test\u002Fcomprehensive-test.yaml",1063,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Ftest\u002Fcomprehensive-test.yaml",{"path":109,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":110,"sourceHtmlUrl":111},"test\u002Fdeployment-test.yaml",1523,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Ftest\u002Fdeployment-test.yaml",{"path":113,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":114,"sourceHtmlUrl":115},"test\u002Fdocument-counter-edge-cases.yaml",430,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Ftest\u002Fdocument-counter-edge-cases.yaml",{"path":117,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":118,"sourceHtmlUrl":119},"test\u002Fschema-errors-test.yaml",1198,"https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fdevops\u002Fk8s-yaml-validator\u002Ftest\u002Fschema-errors-test.yaml",[121,133,146,159,172,185],{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":30},"01M6DT9Q6VYA615SCXR757TZZ7","writing-skills","Use when creating new skills, editing existing skills, or verifying skills work before deployment","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fwriting-skills\u002FSKILL.md",[],[128,129,130,131,132,23],"writing skills","writing","use","editing","work",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":30},"01M6DT9GFHDNY90P41WGAE1TV0","writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fwriting-plans\u002FSKILL.md",[],[140,141,129,142,143,130,144,145],"plans","writing plans","requirements","task","code","spec",{"skillNo":147,"name":148,"nameZh":6,"description":149,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":30},"01M6DT9C6PFGD86WS3HY7YE3XG","docs:write-concisely","Apply writing rules to any documentation that humans will read. Makes your writing clearer, stronger, and more professional.","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fwrite-concisely\u002FSKILL.md",[],[153,154,155,156,157,158,129],"docs:write concisely","write","docs","read","Rules","documentation",{"skillNo":160,"name":161,"nameZh":6,"description":162,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":30},"01M6DT98AWQ27P0N1CG97WAG66","kaizen:why","Iterative Five Whys root cause analysis drilling from symptoms to fundamentals","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fwhy\u002FSKILL.md",[],[161,166,167,168,169,170,171],"why","kaizen","issue","five whys","analysis","root cause analysis",{"skillNo":173,"name":174,"nameZh":6,"description":175,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":178,"publishedAt":30},"01M6DT93EH25NAX19R3WGE1P53","verification-loop","A comprehensive verification system for Claude Code sessions.","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fverification-loop\u002FSKILL.md",[],[179,180,181,182,144,183,184],"verification loop","verification","loop","sessions","claude code sessions","system",{"skillNo":186,"name":187,"nameZh":6,"description":188,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":189,"categories":190,"keywords":191,"publishedAt":30},"01M6DT90GW7Z7VCN98P9DVYSNC","verification-before-completion","Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always","https:\u002F\u002Fgithub.com\u002FAntifragileTech\u002Fantifragile-claude-code\u002Fblob\u002Fmaster\u002Fassets\u002Fskills\u002Fthinking\u002Fverification-before-completion\u002FSKILL.md",[],[192,180,193,132,130,194,195,196],"verification before completion","commands","evidence","claim","complete"]