codebase-guard
A tag-indexed issue library. Run this to either archive a newly solved issue (Librarian mode) or audit code changes against existing issue tags (Reviewer mode).
SKILL.mdskills/codebase-guard/SKILL.md
GitHubUnified Codebase Guard Router
You have two operational roles within this skill. Determine which role to execute based on the user's prompt.
MODE 1: The Librarian (Write & Index)
Trigger: Activated when the user asks to archive, log, or save a newly discovered issue/bug from the current session.
Protocol:
MODE 1: The Librarian (Write & Index)
Trigger: Activated when the user asks to archive, log, or save a newly discovered issue/bug from the current session.
Protocol:
- Analyze: Extract the core architectural failure, symptoms, and resolution from the current chat history. Do not focus on local variable names or specific files; identify the core technical pattern.
- Deduplication Check (CRITICAL STEP):
- Open and read
./INDEX.mdcompletely. - Scan the
TagsandIssue Summarycolumns for any existing rules addressing the same foundational problem (e.g., if archiving a hardcoded API endpoint, check if there is an existing rule for hardcoded environments, configuration coupling, or magic strings). - Deep Review: If a potential match is found, open that specific
./issues/ISSUE-[Number].mdfile to evaluate its full description.
- Open and read
- Branching Decision:
- Scenario A: Conceptual Overlap (Amending Mode)
If the current bug is simply a new symptom or variation of an existing rule, do not create a new file or increment the index. Instead:
- Open the existing
./issues/ISSUE-[Number].mdfile. - Add a new generalized category under the
## Symptomssection describing this new variation. - If the fix introduces a new edge case, update the
## Working Fix / Mitigationsection. - Stop execution and inform the user: "This issue matches ISSUE-XXX. I have updated that rule's symptoms to include this scenario rather than creating a duplicate."
- Open the existing
- Scenario B: Genuinely Unique (Creation Mode)
If no existing rule in
INDEX.mdstructurally matches this failure:- Generate a new sequential number (e.g.,
005). - Write a new abstract markdown file to
./issues/ISSUE-[Number].md. - Append a single new row to
./INDEX.mdwith the new Number, Tags, and an abstract Summary. - Report the new Issue Number to the user.
- Generate a new sequential number (e.g.,
- Scenario A: Conceptual Overlap (Amending Mode)
If the current bug is simply a new symptom or variation of an existing rule, do not create a new file or increment the index. Instead:
- Write Atomic Issue File: Create a new standalone markdown file inside
./issues/ISSUE-[Number].mdusing these strict generalization constraints:- Title: Use high-level architectural terms, not specific feature names.
- Description: Explain the underlying structural vulnerability. Avoid mentioning specific project-level domain objects unless as a generic example.
- Symptoms: Group by logical behavior rather than concrete codebase paths. Never include specific file paths (like
*.vuefiles) or literal year constants (like2023) in the core rules. Use placeholder descriptions instead. - Anti-Pattern Code Blocks: Convert the specific code into generic, abstract code blocks. Use generic object/property names (e.g.,
record.nameoritem.label) so the pattern matcher recognizes the syntax shape rather than the literal tokens. - Remediation Code Blocks: Show how to rewrite the abstract pattern safely using proper architectural patterns (e.g., schema fields, utility parsers).
- Update Index: Append a single row to the table in
./INDEX.mddocumenting only the new Issue Number, its tags, and a generalized summary. - Report: Provide the user with the new Issue Number and summary of what was archived.
MODE 2: The Reviewer (Tag-Matched Audit)
Trigger: Activated when the user asks to review, audit, or check code changes, staging environments, or PRs.
Protocol:
- Identify Target Tags: Inspect the code changes in the active workspace to deduce the relevant technical domains (e.g., changing a Zod schema implies
validationandapi). - Consult INDEX.md: Open
./INDEX.mdand scan the tags column. Filter out and collect the Issue Numbers that match the target tags. - Load Target Issues: Dynamically construct the file path for each matched number as
./issues/ISSUE-[Number].md. Open and read only those specific files. - Verify Delta: Check the workspace code changes against the "Anti-Pattern" section of each loaded issue file.
- Report Violations Only (Strict Silence for Non-Matches):
- If a violation is found:
- Identify the exact file name and line numbers where the issue occurs.
- Explain the Contextual Manifestation: Clearly describe how and why the user's specific code implementation replicates the historical bug.
- If NO violations are found:
- Do not output anything. Skip any mention of the clean files, passed rules, or success summaries. Produce absolute silence for any rule or file that passes cleanly.
- If a violation is found: