@sallmarta/eye-hate-agent 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +56 -304
  2. package/bin/eha.js +203 -118
  3. package/docs/templates/project-docs-template/index.md +208 -0
  4. package/docs/templates/project-docs-template/technical-guidelines/index.md +81 -0
  5. package/docs/templates/reusable-prompts/00-project-docs-bootstrap.md +40 -0
  6. package/docs/{vibes → templates}/reusable-prompts/00-project-docs-parity.md +4 -6
  7. package/docs/{vibes → templates}/reusable-prompts/00-project-docs-refresh.md +11 -11
  8. package/docs/{vibes → templates}/reusable-prompts/01-sdd-execute.md +1 -1
  9. package/docs/{vibes → templates}/reusable-prompts/02-sdd-discuss.md +3 -3
  10. package/{.agents/rules/agent.md → docs/templates/rules/agent-rules.md} +7 -12
  11. package/docs/{vibes → templates}/skills/api-design/SKILL.md +14 -25
  12. package/docs/{vibes/skills/full-verification → templates/skills/code-audit}/SKILL.md +36 -54
  13. package/docs/templates/skills/db-schema-design/SKILL.md +120 -0
  14. package/docs/templates/skills/devops-ci-cd/SKILL.md +99 -0
  15. package/docs/templates/skills/observability/SKILL.md +99 -0
  16. package/docs/{vibes/skills/parity → templates/skills/parity-audit}/SKILL.md +26 -52
  17. package/docs/templates/skills/refactor/SKILL.md +100 -0
  18. package/docs/templates/skills/security-audit/SKILL.md +149 -0
  19. package/docs/{vibes/skills/analysis → templates/skills/system-analysis}/SKILL.md +19 -41
  20. package/docs/{vibes/skills/test-authoring → templates/skills/system-tester}/SKILL.md +28 -46
  21. package/docs/templates/skills/ui-ux-design/SKILL.md +102 -0
  22. package/docs/templates/skills/wireframing/SKILL.md +88 -0
  23. package/package.json +4 -6
  24. package/src/engine/index.js +9 -12
  25. package/src/engine/install.js +67 -165
  26. package/src/engine/runtime-adapters.js +266 -50
  27. package/src/engine/skill-registry.js +72 -0
  28. package/src/engine/state.js +29 -7
  29. package/src/engine/workflow-registry.js +14 -23
  30. package/.claude/commands/eha/README.md +0 -3
  31. package/.claude/commands/eha/eha-bootstrap.md +0 -9
  32. package/.claude/commands/eha/eha-discuss.md +0 -9
  33. package/.claude/commands/eha/eha-execute.md +0 -9
  34. package/.claude/commands/eha/eha-parity.md +0 -9
  35. package/.claude/commands/eha/eha-refresh.md +0 -9
  36. package/.claude/commands/eha/eha-verify.md +0 -9
  37. package/.claude/rules/agent-rules.md +0 -64
  38. package/.github/instructions/agent-rules.instructions.md +0 -63
  39. package/.github/instructions/eha-workflows.instructions.md +0 -21
  40. package/docs/eyehateagent-contract.md +0 -475
  41. package/docs/eyehateagent-maintenance.md +0 -103
  42. package/docs/project-docs/changelog.md +0 -299
  43. package/docs/project-docs/foundation/architecture.md +0 -117
  44. package/docs/project-docs/foundation/status.md +0 -32
  45. package/docs/project-docs/foundation/workflow.md +0 -63
  46. package/docs/project-docs/index.md +0 -20
  47. package/docs/project-docs/testing.md +0 -73
  48. package/docs/vibes/project-docs-template/foundation/architecture.md +0 -79
  49. package/docs/vibes/project-docs-template/foundation/changelog.md +0 -53
  50. package/docs/vibes/project-docs-template/foundation/feature-inventory.md +0 -46
  51. package/docs/vibes/project-docs-template/foundation/phases.md +0 -60
  52. package/docs/vibes/project-docs-template/foundation/prd.md +0 -69
  53. package/docs/vibes/project-docs-template/foundation/status.md +0 -57
  54. package/docs/vibes/project-docs-template/foundation/workflow.md +0 -59
  55. package/docs/vibes/project-docs-template/getting-started.md +0 -52
  56. package/docs/vibes/project-docs-template/index.md +0 -66
  57. package/docs/vibes/project-docs-template/operations/ci-cd.md +0 -56
  58. package/docs/vibes/project-docs-template/operations/compliance.md +0 -46
  59. package/docs/vibes/project-docs-template/operations/governance.md +0 -46
  60. package/docs/vibes/project-docs-template/operations/observability.md +0 -53
  61. package/docs/vibes/project-docs-template/operations/production-runbook.md +0 -62
  62. package/docs/vibes/project-docs-template/operations/security.md +0 -49
  63. package/docs/vibes/project-docs-template/technical/api-contract.md +0 -49
  64. package/docs/vibes/project-docs-template/technical/database.md +0 -59
  65. package/docs/vibes/project-docs-template/technical/error-handling.md +0 -54
  66. package/docs/vibes/project-docs-template/technical/internationalization.md +0 -46
  67. package/docs/vibes/project-docs-template/technical/testing.md +0 -57
  68. package/docs/vibes/project-docs-template/technical/ui-ux.md +0 -68
  69. package/docs/vibes/project-docs-template/technical-guidelines/index.md +0 -52
  70. package/docs/vibes/reusable-prompts/00-project-docs-bootstrap.md +0 -59
  71. package/docs/vibes/skills/code-audit/SKILL.md +0 -170
  72. package/docs/vibes/skills/project-elevation/SKILL.md +0 -157
  73. package/docs/vibes/skills/test-authoring/references/patterns.md +0 -116
  74. package/docs/vibes/skills/test-authoring/references/test-types.md +0 -52
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: "devops-ci-cd"
3
+ description: "Project-aware expert-role for CI/CD pipeline design and implementation. Reads project docs first, enforces build caching, security gates, test execution, and deployment safety."
4
+ argument-hint: "Describe the workflow, pipeline, or deployment stage to build or review"
5
+ ---
6
+
7
+ # DevOps CI/CD
8
+
9
+ Produces a **project-aware, expert-level CI/CD pipeline implementation** by reading the repository's project docs first, then applying robust deployment engineering practices.
10
+
11
+ This skill is reusable across CI providers (GitHub Actions, GitLab CI, Jenkins) and deployment targets (AWS, GCP, Vercel, Kubernetes).
12
+
13
+ It should **not** assume a specific CI provider or deployment strategy until the project docs confirm them.
14
+
15
+ ## Required Project Inputs
16
+
17
+ | Document | Why it matters |
18
+ | --- | --- |
19
+ | `docs/project-docs/operations/ci-cd.md` | Defines the required CI provider, branch protection rules, required jobs, and deployment environments. |
20
+ | `docs/project-docs/development/testing.md` | Defines which test suites must run and their coverage thresholds. |
21
+ | `docs/project-docs/operations/security.md` | Defines required security scanning tools (SAST, DAST, dependency checks). |
22
+
23
+ If the repository lacks the CI/CD docs needed for deployment, call that out and create or update the missing docs instead of blindly writing deployment scripts.
24
+
25
+ ## When to Use
26
+
27
+ Use this skill when building or reviewing one of these boundary types.
28
+
29
+ | Boundary type | Typical artifacts |
30
+ | --- | --- |
31
+ | Continuous Integration (CI) | Build scripts, linter checks, test runners, Docker builds. |
32
+ | Continuous Deployment (CD) | Terraform/Pulumi execution, environment promotion, artifact publishing. |
33
+ | Security & Compliance | Dependabot configuration, secret scanning, static analysis gates. |
34
+ | Pipeline Optimization | Caching strategies, matrix builds, job parallelization. |
35
+
36
+ ## Procedure
37
+
38
+ ### Step 1 — Identify the Pipeline Engine and Target
39
+ Extract from `ci-cd.md`:
40
+ - The CI platform (e.g., GitHub Actions).
41
+ - The deployment target (e.g., AWS ECS).
42
+ - Authentication mechanisms (e.g., OIDC vs long-lived secrets).
43
+
44
+ ### Step 2 — Define the Build Matrix and Caching
45
+ - Ensure language-specific dependencies (node_modules, pip cache, go mod cache) are aggressively cached to reduce build times.
46
+ - If building Docker images, implement layer caching.
47
+
48
+ ### Step 3 — Enforce Testing and Security Gates
49
+ Consult `testing.md` and `security.md`:
50
+ - The pipeline MUST block merges if linters or tests fail.
51
+ - The pipeline MUST block merges if critical security vulnerabilities are detected.
52
+
53
+ ### Step 4 — Implement Safe Deployment Strategies
54
+ If deploying to production:
55
+ - Ensure the pipeline respects environment segregation.
56
+ - Implement rollback capabilities or canary/blue-green deployment steps if specified in `ci-cd.md`.
57
+ - Never hardcode secrets in the pipeline file; always use the CI provider's secrets manager.
58
+
59
+ ### Step 5 — Verify Pipeline Robustness
60
+ Ensure the pipeline:
61
+ - Only triggers on appropriate branches or tags.
62
+ - Has reasonable timeout limits to prevent hung jobs.
63
+ - Cleans up temporary artifacts after execution.
64
+
65
+ ## Quality Check
66
+
67
+
68
+ Use this checklist when reviewing an existing CI/CD configuration:
69
+
70
+ - Are dependencies and build outputs being cached?
71
+ - Are secrets injected securely via environment variables?
72
+ - Does a failing test or linter correctly fail the entire job?
73
+ - Is the deployment step locked down to specific branches or environments?
74
+ - Are timeouts explicitly defined to prevent runaway costs?
75
+
76
+ ## Anti-Pattern
77
+
78
+ - Hardcoding API keys or passwords directly in the YAML file.
79
+ - Writing a pipeline that deploys to production from any branch.
80
+ - Skipping tests to make the pipeline run faster.
81
+ - Downloading dependencies without verifying lockfiles.
82
+
83
+ ## Output Contract
84
+
85
+ When using this skill, the output should include:
86
+
87
+ 1. the project docs consulted
88
+ 2. the proposed pipeline architecture (triggers, jobs, steps)
89
+ 3. the caching and optimization strategies used
90
+ 4. the security and testing gates enforced
91
+ 5. the final pipeline YAML or script
92
+
93
+ ## Neutral Prompt Shape
94
+ `@agent use devops-ci-cd on [Target Pipeline/Workflow] focusing on [Specific Optimizations/Security Gates].`
95
+
96
+ ## Example Prompt
97
+ - "Create a GitHub Actions workflow that implements the CI caching strategy."
98
+ - "Review this Jenkinsfile for security issues and hardcoded secrets."
99
+ - "Design a deployment pipeline that supports blue-green rollout."
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: "observability"
3
+ description: "Project-aware expert-role for system observability and SRE engineering. Reads project docs first, enforces structured logging, tracing context injection, PII masking rules, and actionable metric generation."
4
+ argument-hint: "Describe the component, service, or workflow to instrument with observability"
5
+ ---
6
+
7
+ # Observability
8
+
9
+ Produces a **project-aware, expert-level observability implementation** by reading the repository's project docs first, then applying Site Reliability Engineering (SRE) standards for logging, metrics, and tracing.
10
+
11
+ This skill is reusable across logging frameworks (Winston, Logback, Zap), tracing standards (OpenTelemetry), and telemetry backends (Prometheus, Datadog, ELK).
12
+
13
+ It should **not** assume a specific logging library or metric format until the project docs confirm them.
14
+
15
+ ## Required Project Inputs
16
+
17
+ | Document | Why it matters |
18
+ | --- | --- |
19
+ | `docs/project-docs/operations/observability.md` | Defines the required logging frameworks, metric standards, alerting thresholds, and tracing architectures. |
20
+ | `docs/project-docs/operations/compliance.md` | Defines PII (Personally Identifiable Information) masking and data retention rules. |
21
+ | `docs/project-docs/foundation/architecture.md` | Defines how context (e.g., request IDs, user IDs) flows across service boundaries. |
22
+
23
+ If the repository lacks the observability docs needed to understand the current stack, call that out and create or update the missing docs instead of inventing arbitrary logging formats.
24
+
25
+ ## When to Use
26
+
27
+ Use this skill when tasked with improving system visibility or instrumenting code.
28
+
29
+ | Boundary type | Typical artifacts |
30
+ | --- | --- |
31
+ | Application Logging | Structured JSON logs, error stack traces, context injection. |
32
+ | Distributed Tracing | Spans, span contexts, OpenTelemetry configuration. |
33
+ | Application Metrics | Counters, gauges, histograms (e.g., request latency, error rates). |
34
+ | Alerting & Dashboards | Prometheus rules, Datadog monitors, Grafana dashboard JSON. |
35
+
36
+ ## Procedure
37
+
38
+ ### Step 1 — Extract Standards
39
+ Extract from `observability.md`:
40
+ - The approved logging library.
41
+ - Required log levels (e.g., `DEBUG` in dev, `INFO` in prod).
42
+ - Required structured fields (e.g., `requestId`, `tenantId`).
43
+
44
+ ### Step 2 — Enforce Compliance and PII Masking
45
+ Extract from `compliance.md`:
46
+ - Identify fields that MUST NEVER be logged (e.g., passwords, credit card numbers, raw request bodies).
47
+ - Implement redaction/masking at the logger configuration level if possible.
48
+
49
+ ### Step 3 — Instrument Tracing Context
50
+ When instrumenting a request flow:
51
+ - Ensure trace IDs (like `x-b3-traceid` or OpenTelemetry headers) are parsed at the entry point.
52
+ - Ensure the trace ID is attached to ALL subsequent log emissions and downstream HTTP calls.
53
+
54
+ ### Step 4 — Define Actionable Metrics
55
+ Instead of generic logs, emit actionable metrics for:
56
+ - Throughput (requests per second).
57
+ - Error rates (4xx vs 5xx).
58
+ - Latency/Duration (histograms of processing time).
59
+
60
+ ### Step 5 — Standardize Error Handling
61
+ When logging exceptions:
62
+ - Always log the full stack trace for unhandled errors.
63
+ - Do not swallow errors (e.g., `catch (e) { log(e.message) }` loses the stack trace).
64
+ - Ensure the log distinguishes between client errors (validation) and server errors (crashes).
65
+
66
+ ## Quality Check
67
+
68
+ Use this checklist when reviewing observability code:
69
+
70
+ - Are logs structured (JSON) rather than plain text strings?
71
+ - Is context (like Request ID) present in every log entry for a transaction?
72
+ - Are sensitive fields (tokens, passwords, PII) explicitly redacted?
73
+ - Are metrics using standardized naming conventions (e.g., snake_case for Prometheus)?
74
+ - Are errors logged with stack traces and sufficient context to debug without guessing?
75
+
76
+ ## Anti-Pattern
77
+
78
+ - `console.log()` or equivalent generic print statements in production code.
79
+ - Logging the entire raw HTTP Request or Response object.
80
+ - Silently swallowing exceptions without logging them.
81
+ - Emitting high-cardinality data (like User IDs) as metric labels/tags instead of log fields.
82
+
83
+ ## Output Contract
84
+
85
+ When using this skill, the output should include:
86
+
87
+ 1. the project docs consulted
88
+ 2. the instrumentation code (logging, tracing, or metrics)
89
+ 3. the structured payload shape being emitted
90
+ 4. the PII masking and security constraints verified
91
+ 5. how the new telemetry can be validated (e.g., local mock server, stdout check)
92
+
93
+ ## Neutral Prompt Shape
94
+ `@agent use observability on [Target Service/Component] focusing on [Specific Metrics/Logs].`
95
+
96
+ ## Example Prompt
97
+ - "Instrument this service with structured logging and trace context."
98
+ - "Review this controller to ensure PII is masked before logging."
99
+ - "Design Prometheus metrics for this asynchronous background job."
@@ -1,34 +1,30 @@
1
1
  ---
2
- name: parity
2
+ name: "parity-audit"
3
3
  description: "Expert-role parity check across project docs, platform instruction surfaces, skills, reusable prompts, workflows, quick-reference material, and implementation evidence when authority depends on the current codebase. Use when checking whether the template system still agrees with itself or when preparing cleanup after major changes."
4
4
  argument-hint: "Describe the scope to audit: full repository, docs only, reusable prompt system, platform instruction surfaces and skills, or a specific workstream"
5
5
  ---
6
6
 
7
- # Parity — Project-Aware
7
+ # Parity Audit
8
8
 
9
- Performs an **expert repository-wide drift audit** to find contradictions, stale summaries, duplicated ownership, code-vs-doc authority conflicts, and historical artifacts that should be classified rather than confused with active truth.
9
+ Performs an expert repository-wide drift audit to find contradictions, stale summaries, duplicated ownership, code-vs-doc authority conflicts, and historical artifacts that should be classified rather than confused with active truth.
10
10
 
11
11
  This skill is the reusable complement to the parity reusable prompt. Use it when the task is analytical rather than generative.
12
12
 
13
- ---
14
-
15
13
  ## Required Project Inputs
16
14
 
17
15
  | Document | Why it matters |
18
16
  | --- | --- |
19
- | `docs/eyehateagent-contract.md` | Ownership map and canonical doc contract |
17
+ | EHA Rules | Ownership map and canonical doc taxonomy |
20
18
  | `docs/project-docs/foundation/prd.md` | Active project identity and scope |
21
19
  | `docs/project-docs/foundation/architecture.md` | Active stack and architecture truth |
22
- | `docs/project-docs/technical/testing.md` | Active verification truth |
20
+ | `docs/project-docs/development/testing.md` | Active verification truth |
23
21
  | `docs/project-docs/foundation/status.md` | Active roadmap and current-state truth |
24
22
  | Platform instruction surfaces | Automatic behavior layer |
25
23
  | Skills and reusable prompts | Reusable procedure and generation layers |
26
24
  | Workflow, handoff, and historical docs | Potentially valid references or stale artifacts |
27
25
  | Relevant code, tests, configs, and runtime-facing artifacts | Evidence for whether active docs still match the current repository |
28
26
 
29
- ---
30
-
31
- ## When To Use
27
+ ## When to Use
32
28
 
33
29
  | Trigger | Example request |
34
30
  | --- | --- |
@@ -37,10 +33,6 @@ This skill is the reusable complement to the parity reusable prompt. Use it when
37
33
  | Template maintenance | "Audit platform instruction surfaces and skills after changing the contract" |
38
34
  | Handoff preparation | "Find contradictions before handing this repo to another maintainer" |
39
35
 
40
- Use `full-verification` instead when the user asks for a broad verification entry point and repository drift is only one possible verification path.
41
-
42
- Typical audit targets include:
43
-
44
36
  Check for disagreement across:
45
37
 
46
38
  - project identity and naming
@@ -53,13 +45,11 @@ Check for disagreement across:
53
45
  - rule expectations vs documented workflow
54
46
  - active docs vs current code, tests, configs, or runtime-facing behavior when authority is disputed
55
47
 
56
- ---
57
-
58
48
  ## Procedure
59
49
 
60
50
  ### Step 1 — Establish the source of truth
61
51
 
62
- Use the project docs defined by `docs/eyehateagent-contract.md` as the default source of truth for documentation ownership unless the repository explicitly states otherwise.
52
+ Use the active EHA rules as the default source of truth for documentation ownership unless the repository explicitly states otherwise.
63
53
 
64
54
  ### Step 2 — Compare dependent layers
65
55
 
@@ -99,29 +89,7 @@ Determine whether the mismatch affects:
99
89
 
100
90
  Recommend which owning file or layer should be updated. Do not spread the same fact across more files than necessary.
101
91
 
102
- ---
103
-
104
- ## Output Contract
105
-
106
- For each finding, include:
107
-
108
- 1. severity
109
- 2. fact in conflict
110
- 3. source-of-truth location
111
- 4. conflicting location
112
- 5. classification
113
- 6. why it matters
114
- 7. recommended owner to update
115
- 8. whether user direction is required before deciding the fix path
116
-
117
- End with:
118
-
119
- 1. highest-priority drift items
120
- 2. acceptable historical artifacts that should not be treated as blockers
121
-
122
- ---
123
-
124
- ## Quality Checks
92
+ ## Quality Check
125
93
 
126
94
  - Do not confuse reference material with active truth
127
95
  - Do not propose fixing both sides of a contradiction when one side clearly owns the fact
@@ -129,9 +97,7 @@ End with:
129
97
  - Keep the audit actionable, not just descriptive
130
98
  - Do not assume docs or code win when authority for the disputed fact is not explicit
131
99
 
132
- ---
133
-
134
- ## Anti-Patterns
100
+ ## Anti-Pattern
135
101
 
136
102
  - Treating summary files as the owner when the contract defines a different source of truth
137
103
  - Reporting drift without naming the owning file or layer that should change
@@ -139,20 +105,28 @@ End with:
139
105
  - Duplicating the same fact across multiple layers as a fix for drift
140
106
  - Assuming implementation drift or documentation drift without checking whether the repository defines authority for that fact
141
107
 
142
- ---
108
+ ## Output Contract
143
109
 
144
- ## Natural Prompt Shapes
110
+ For each finding, include:
145
111
 
146
- - "Check whether the docs and repository still agree."
147
- - "Audit this repo for drift after the latest changes."
148
- - "Find contradictions across docs, platform instruction surfaces, skills, and prompts."
149
- - "Tell me which mismatches are real blockers versus harmless leftovers."
112
+ 1. severity
113
+ 2. fact in conflict
114
+ 3. source-of-truth location
115
+ 4. conflicting location
116
+ 5. classification
117
+ 6. why it matters
118
+ 7. recommended owner to update
119
+ 8. whether user direction is required before deciding the fix path
150
120
 
151
- ---
121
+ End with:
122
+ 1. highest-priority drift items
123
+ 2. acceptable historical artifacts that should not be treated as blockers
152
124
 
153
- ## Example Requests
125
+ ## Neutral Prompt Shape
126
+ `@agent use parity-audit on [Target Scope/Repo] focusing on [Specific Conflicts/Docs].`
154
127
 
128
+ ## Example Prompt
155
129
  - "Audit the repository for contradictions after the latest template changes"
156
130
  - "Check whether reusable prompts and skills still match the contract"
157
131
  - "Find stale summaries in the project docs"
158
- - "Classify which mismatches are blockers versus historical artifacts"
132
+ - "Classify which mismatches are blockers versus historical artifacts"
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: "refactor"
3
+ description: "Project-aware expert-role for code refactoring. Reads project docs first, enforces TDD, and restructures code to reduce cyclomatic complexity and improve maintainability without altering external behavior."
4
+ argument-hint: "Describe the function, file, or module to refactor"
5
+ ---
6
+
7
+ # Refactor
8
+
9
+ Produces a project-aware, expert-level refactoring plan and execution by reading the repository's project docs first, then applying strict structural improvements.
10
+
11
+ This skill is reusable across any programming language. It focuses on reducing technical debt, splitting monolithic structures, and improving testability. It should not assume a specific framework or design pattern until the project docs confirm them.
12
+
13
+ ## Required Project Inputs
14
+
15
+ | Document | Why it matters |
16
+ | --- | --- |
17
+ | `docs/project-docs/foundation/architecture.md` | Defines the acceptable patterns, boundaries, and coupling rules for the project. |
18
+ | `docs/project-docs/development/testing.md` | Defines the required testing frameworks and test coverage expectations. |
19
+ | `docs/project-docs/technical-guidelines/index.md` | Provides language-specific linting, style, or idiom rules. |
20
+
21
+ If the repository lacks the testing docs needed for safe refactoring, call that out and create or update the missing docs instead of refactoring blindly.
22
+
23
+ ## When to Use
24
+
25
+ Use this skill when tasked with improving existing code without changing its feature set.
26
+
27
+ | Boundary type | Typical artifacts |
28
+ | --- | --- |
29
+ | Function / Method | Reducing cyclomatic complexity, extracting pure functions, eliminating nested conditionals. |
30
+ | Class / Module | Applying SOLID principles, injecting dependencies, splitting god classes. |
31
+ | File / Directory | Reorganizing imports, breaking large files into logical cohesive units. |
32
+ | Naming & Style | Standardizing variable names, updating to project idioms. |
33
+
34
+ ## Procedure
35
+
36
+ ### Step 1 — Identify the Architecture Constraints
37
+ Extract from `architecture.md`:
38
+ - Domain boundaries and allowed dependency directions.
39
+ - Prescribed patterns (e.g., Use Repositories for data access, use Services for business logic).
40
+
41
+ ### Step 2 — Read Existing Tests
42
+ Extract from the codebase:
43
+ - Are there existing unit or integration tests for the target code?
44
+ - If NO: **Stop.** You must write tests to establish a baseline before changing any structural code.
45
+
46
+ ### Step 3 — Analyze the Target Code
47
+ Evaluate the target code for:
48
+ - High cyclomatic complexity (too many if/else branches).
49
+ - Side effects hidden within otherwise pure logic.
50
+ - Tight coupling to infrastructure or external dependencies.
51
+ - Duplicated logic.
52
+
53
+ ### Step 4 — Formulate the Refactoring Plan
54
+ Design the new structure:
55
+ - Extract pure functions for testability.
56
+ - Introduce dependency injection where hardcoded dependencies exist.
57
+ - Replace complex conditionals with polymorphism, lookup tables, or guard clauses.
58
+
59
+ ### Step 5 — Test-Driven Execution
60
+ 1. Ensure the baseline tests pass.
61
+ 2. Apply the refactoring incrementally.
62
+ 3. Continuously verify that tests pass after each structural change.
63
+
64
+ ### Step 6 — Preserve Documentation
65
+ Ensure all existing comments and docstrings are preserved unless the new structure explicitly invalidates them. In that case, update them accurately.
66
+
67
+ ## Quality Check
68
+
69
+ Use this checklist when reviewing refactored code:
70
+
71
+ - Has the external API or behavior of the function/module changed? (It shouldn't).
72
+ - Is the new code easier to unit test?
73
+ - Were dependency rules from `architecture.md` respected?
74
+ - Were original comments preserved or updated?
75
+ - Did the refactoring introduce any new dependencies?
76
+
77
+ ## Anti-Pattern
78
+
79
+ - Refactoring code without baseline tests.
80
+ - Over-engineering (e.g., introducing a complex Factory pattern for a simple two-branch conditional).
81
+ - Changing feature behavior or fixing bugs silently during a refactor.
82
+ - Silently deleting developer comments or context notes.
83
+
84
+ ## Output Contract
85
+
86
+ When using this skill, the output should include:
87
+
88
+ 1. the project docs consulted
89
+ 2. the identified code smells / issues in the target code
90
+ 3. the baseline testing strategy used
91
+ 4. the step-by-step refactoring changes applied
92
+ 5. verification that all external behavior remains identical
93
+
94
+ ## Neutral Prompt Shape
95
+ `@agent use refactor on [Target Function/File] focusing on [Specific Architecture/Simplicity Goal].`
96
+
97
+ ## Example Prompt
98
+ - "Refactor this god class into smaller cohesive services."
99
+ - "Reduce the cyclomatic complexity of this function."
100
+ - "Reorganize the imports and structure of this legacy file."
@@ -0,0 +1,149 @@
1
+ ---
2
+ name: "security-audit"
3
+ description: "Project-aware expert-role for security and vulnerability auditing. Reads project docs first, enforces strict boundary controls, OWASP Top 10 mitigation, authentication, and data privacy rules across the codebase."
4
+ argument-hint: "Point to the code, file, module, or change to audit"
5
+ ---
6
+
7
+ # Security Audit
8
+
9
+ Produces a project-aware, **expert-level security audit** by reading the repository's project docs first, then applying rigorous threat modeling and vulnerability analysis to the current architecture.
10
+
11
+ This skill is reusable across application logic, API boundaries, infrastructure configurations, and data persistence layers. It should not assume specific compliance frameworks (like SOC2 or HIPAA) until the project docs explicitly confirm them.
12
+
13
+ ## Required Project Inputs
14
+
15
+ | Document | Why it matters |
16
+ | --- | --- |
17
+ | `docs/project-docs/operations/security-compliance.md` | Defines the actual threat model, acceptable risk, security gates, PII masking, data retention, and regulatory requirements. |
18
+ | `docs/project-docs/foundation/architecture.md` | Defines trust boundaries, network zones, and where authentication/authorization is enforced. |
19
+ | `docs/project-docs/development/api-contract.md` | Clarifies the expected payload shapes and validation rules to prevent injection attacks. |
20
+
21
+ If the repository lacks the security docs needed for a proper audit, call that out and establish baseline security assumptions before reviewing code.
22
+
23
+ ## When to Use
24
+
25
+ Use this skill when tasked with identifying vulnerabilities or ensuring code meets security standards.
26
+
27
+ | Boundary type | Typical artifacts |
28
+ | --- | --- |
29
+ | Authentication / Authorization | JWT validation, role-based access control (RBAC), session management. |
30
+ | API / Input Validation | Preventing SQL injection, XSS, CSRF, and mass assignment vulnerabilities. |
31
+ | Data Privacy / Cryptography | Encryption at rest/transit, hashing algorithms, secret management. |
32
+ | Infrastructure Security | Dockerfile security, IAM permissions, network exposure. |
33
+
34
+ ## Procedure
35
+
36
+ ### Step 1 — Understand intent
37
+
38
+ - What is this code supposed to do?
39
+ - What inputs, outputs, and side effects should it have?
40
+ - Which boundary does it sit behind?
41
+ - What project rules apply here?
42
+
43
+ ### Step 2 — Check correctness risks
44
+
45
+ Look for:
46
+
47
+ - runtime crashes
48
+ - missing validation
49
+ - broken assumptions around nullability or absence
50
+ - incorrect state transitions
51
+ - failure to handle empty, partial, duplicate, or delayed inputs
52
+ - unsafe retry or transaction behavior
53
+ - concurrency or sequencing defects
54
+ - schema or serialization mismatches
55
+
56
+ ### Step 3 — Check boundary violations
57
+
58
+ Use `architecture.md` to inspect:
59
+
60
+ - layer or module import violations
61
+ - leaked internal types across boundaries
62
+ - controllers or UI doing business logic that belongs elsewhere
63
+ - repositories or services depending on the wrong layer
64
+ - transport or persistence details leaking into durable domain concepts when the project forbids that
65
+ - identify where untrusted input enters the system (e.g., public APIs, webhooks, file uploads).
66
+ - identify where trust is explicitly verified (e.g., API gateways, auth middlewares).
67
+
68
+ ### Step 4 — Audit Authentication and Session State
69
+ Evaluate auth mechanisms against `security-compliance.md`:
70
+ - Are tokens securely stored (e.g., HttpOnly cookies instead of LocalStorage)?
71
+ - Are session timeouts and revocation mechanisms implemented?
72
+ - Is authorization checked on every privileged action, not just at the UI level?
73
+
74
+ Also look for:
75
+
76
+ - duplicated logic
77
+ - unused or unreachable branches
78
+ - stale abstractions
79
+ - helper functions with no callers
80
+ - repeated literal values that should be owned centrally
81
+ - duplicated normalization or mapping logic that should be shared
82
+
83
+ ### Step 5 — Check Secret Management and Cryptography
84
+ Ensure: No hardcoded secrets, passwords, or API keys exist in the codebase. Sensitive data is hashed using strong algorithms (e.g., Argon2, bcrypt) with salts. Data in transit is strictly TLS-enforced.
85
+
86
+ ### Step 6 — Verify Compliance and PII Handling
87
+ Consult `security-compliance.md`: Ensure PII is not leaked into application logs, error messages, or third-party analytics tools. Verify data retention constraints are implemented.
88
+
89
+ ### Step 7 — Prioritize findings
90
+
91
+ Classify findings by severity:
92
+
93
+ - critical
94
+ - high
95
+ - medium
96
+ - low
97
+
98
+ Each finding should include:
99
+
100
+ - location
101
+ - issue
102
+ - why it matters
103
+ - concrete corrective direction
104
+
105
+ ## Quality Check
106
+
107
+ - Are all inputs crossing a trust boundary rigorously validated?
108
+ - Are secrets injected via environment variables rather than hardcoded?
109
+ - Are dependencies checked for known CVEs?
110
+ - Does the code adhere to the Principle of Least Privilege?
111
+ - Are error messages stripped of internal stack traces before returning to the client?
112
+ - No finding without evidence from the target artifact
113
+ - No severity inflation
114
+ - No style nitpicks disguised as bugs
115
+ - No architecture complaint without reference to actual project boundaries
116
+ - No recommendation that ignores project stage or available validation
117
+
118
+ ## Anti-Pattern
119
+
120
+ - Relying exclusively on client-side validation for security.
121
+ - Concatenating SQL queries with user input.
122
+ - Logging raw request bodies that might contain passwords or PII.
123
+ - Implementing custom cryptography instead of using proven industry standards.
124
+ - Assuming an internal network is completely trustworthy without zero-trust checks.
125
+ - Calling something dead code without checking workspace usage
126
+ - Calling something a bug without defining the failure condition
127
+ - Criticizing a pattern that the project explicitly chose in `architecture.md`
128
+ - Recommending wide rewrites before testing a local fix or a smaller boundary change
129
+
130
+ ## Output Contract
131
+
132
+ When using this skill, the output should include:
133
+ 1. the project docs consulted and assumed threat model
134
+ 2. identified vulnerabilities categorized by OWASP standard
135
+ 3. severity rating (Critical, High, Medium, Low) for each finding
136
+ 4. exploitability and impact analysis
137
+ 5. specific, actionable remediation steps for each finding
138
+
139
+ ## Neutral Prompt Shape
140
+ `@agent use security-audit on [Target Component/API] focusing on [Specific Threat/Vulnerability].`
141
+
142
+ ## Example Prompt
143
+ - "Audit this new authentication controller for session management flaws."
144
+ - "Review this file upload endpoint for security risks."
145
+ - "Perform a security audit on this database migration script."
146
+ - "Review this code for bugs, risks, and boundary issues."
147
+ - "Audit this module like a strict senior reviewer."
148
+ - "Check whether this implementation has correctness or security problems."
149
+ - "Find dead code, logic flaws, and maintainability risks in this change."