ai-project-maintainer 0.3.0

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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -0
  3. package/ai-project-maintainer/SKILL.md +62 -0
  4. package/ai-project-maintainer/agents/openai.yaml +6 -0
  5. package/ai-project-maintainer/references/ci-guardrails.md +55 -0
  6. package/ai-project-maintainer/references/database.md +60 -0
  7. package/ai-project-maintainer/references/electron-desktop.md +43 -0
  8. package/ai-project-maintainer/references/incident-response.md +52 -0
  9. package/ai-project-maintainer/references/local-gate.md +117 -0
  10. package/ai-project-maintainer/references/security.md +48 -0
  11. package/ai-project-maintainer/references/tool-router.md +53 -0
  12. package/ai-project-maintainer/scripts/audit-plan.mjs +155 -0
  13. package/ai-project-maintainer/scripts/bootstrap-local-tools.ps1 +109 -0
  14. package/ai-project-maintainer/scripts/check-syntax.mjs +41 -0
  15. package/ai-project-maintainer/scripts/ci-smoke-gate.mjs +26 -0
  16. package/ai-project-maintainer/scripts/cli.mjs +165 -0
  17. package/ai-project-maintainer/scripts/doctor.mjs +80 -0
  18. package/ai-project-maintainer/scripts/init-audit.mjs +105 -0
  19. package/ai-project-maintainer/scripts/init-project.mjs +229 -0
  20. package/ai-project-maintainer/scripts/lib/check-registry.mjs +68 -0
  21. package/ai-project-maintainer/scripts/lib/checks.mjs +337 -0
  22. package/ai-project-maintainer/scripts/lib/command-runner.mjs +130 -0
  23. package/ai-project-maintainer/scripts/lib/intake.mjs +172 -0
  24. package/ai-project-maintainer/scripts/lib/policy.mjs +150 -0
  25. package/ai-project-maintainer/scripts/lib/project-detect.mjs +111 -0
  26. package/ai-project-maintainer/scripts/lib/report.mjs +227 -0
  27. package/ai-project-maintainer/scripts/probe-project.mjs +218 -0
  28. package/ai-project-maintainer/scripts/report-summary.mjs +25 -0
  29. package/ai-project-maintainer/scripts/run-local-gate.mjs +147 -0
  30. package/docs/CI-GITHUB-ACTIONS.zh-CN.md +83 -0
  31. package/docs/DEMO.md +81 -0
  32. package/docs/DEMO.zh-CN.md +81 -0
  33. package/docs/GITHUB-LAUNCH-CHECKLIST.md +77 -0
  34. package/docs/INSTALL.zh-CN.md +112 -0
  35. package/docs/INTAKE-SCHEMA.zh-CN.md +105 -0
  36. package/docs/POLICY-AND-EXCEPTIONS.zh-CN.md +96 -0
  37. package/docs/PRODUCTION-AUDIT.zh-CN.md +89 -0
  38. package/docs/PROMOTION.md +116 -0
  39. package/docs/UPGRADE-ROADMAP.zh-CN.md +47 -0
  40. package/docs/demo-output/security-report.md +57 -0
  41. package/docs/superpowers/plans/2026-06-29-ci-dogfooding.md +200 -0
  42. package/package.json +21 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xixifusi1213-gif
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # AI Project Maintainer
2
+
3
+ ![AI coding](https://img.shields.io/badge/built%20for-AI%20coding-111827)
4
+ ![Production audit](https://img.shields.io/badge/gate-production%20audit-0f766e)
5
+ ![Account free](https://img.shields.io/badge/default-account%20free-2563eb)
6
+ [![CI](https://github.com/xixifusi1213-gif/ai-project-maintainer/actions/workflows/ci.yml/badge.svg)](https://github.com/xixifusi1213-gif/ai-project-maintainer/actions/workflows/ci.yml)
7
+
8
+ **A production-readiness gate for AI-coded projects.**
9
+
10
+ AI can generate code fast. This tool helps you keep the project maintainable after that: collect project evidence, plan the audit, run deterministic gates, let Codex fix blockers, and rerun until the release is defensible.
11
+
12
+ [See the demo](docs/DEMO.md) · [中文演示](docs/DEMO.zh-CN.md) · [Production audit docs](docs/PRODUCTION-AUDIT.zh-CN.md)
13
+
14
+ It is not another scanner wrapper. It turns AI coding maintenance into a repeatable loop:
15
+
16
+ ```text
17
+ project profile -> audit plan -> local/CI gate -> evidence report -> AI fixes -> rerun
18
+ ```
19
+
20
+ ## Why This Exists
21
+
22
+ AI coding makes it easy to ship code that looks complete but quietly misses production basics:
23
+
24
+ - no business-flow tests
25
+ - no secret/dependency/security gate
26
+ - no database migration review
27
+ - no release approval or rollback evidence
28
+ - no monitoring/logging/alerting proof
29
+ - no clear owner-approved exceptions
30
+
31
+ `ai-project-maintainer` makes those gaps visible before they become production surprises.
32
+
33
+ ## The 3-Minute Flow
34
+
35
+ ```powershell
36
+ # 1. Add local and CI guardrails
37
+ npx ai-project-maintainer init "E:\my-project" --profile oss --ci github
38
+
39
+ # 2. Create the production audit intake templates
40
+ npx ai-project-maintainer init-audit "E:\my-project"
41
+
42
+ # 3. Generate the project-specific audit plan
43
+ npx ai-project-maintainer audit-plan "E:\my-project" --output reports/audit-plan.json
44
+
45
+ # 4. Run the production gate
46
+ npx ai-project-maintainer gate "E:\my-project" --production --strict --release --output reports/security-report.json
47
+ ```
48
+
49
+ No npm publication is required for GitHub Actions. The generated workflow clones this repository and runs the Node scripts directly.
50
+
51
+ ## What It Checks
52
+
53
+ | Area | Evidence produced |
54
+ | --- | --- |
55
+ | Tests and release scripts | test/E2E/build/dist failures |
56
+ | Secrets | Gitleaks findings |
57
+ | Dependencies | npm/pnpm/yarn audit, Trivy, OSV-Scanner |
58
+ | Static security | Semgrep blocking findings |
59
+ | Supply chain | Syft SBOM, Grype scan |
60
+ | CI security | actionlint, zizmor |
61
+ | IaC | Checkov, Trivy config |
62
+ | Electron apps | dangerous webPreferences, preload/IPC/file-read risks |
63
+ | Database projects | migration, backup, rollback, review-tool gaps |
64
+ | Production readiness | monitoring, logs, metrics, alerts, release approval, incident runbook |
65
+
66
+ ## Production Audit, Not Just Scanning
67
+
68
+ V3 adds an intake-driven audit layer:
69
+
70
+ ```text
71
+ .ai-maintainer/project-profile.yml
72
+ .ai-maintainer/evidence-sources.yml
73
+ .ai-maintainer/business-flows.yml
74
+ .ai-maintainer/risk-policy.yml
75
+ .ai-maintainer/threat-model.md
76
+ .ai-maintainer/release-checklist.yml
77
+ .ai-maintainer/incident-runbook.md
78
+ .ai-maintainer/db-migration-policy.yml
79
+ .ai-maintainer/observability-checklist.yml
80
+ ```
81
+
82
+ The user supplies business facts and evidence locations. The tool decides which checks apply and labels every item clearly:
83
+
84
+ ```text
85
+ PASS checked and OK
86
+ FAIL checked and failed
87
+ WARN risky but not blocking by default
88
+ GAP missing evidence
89
+ N/A not applicable to this project
90
+ USER_DECISION maintainer judgment required
91
+ ```
92
+
93
+ By default, `GAP` is reported but does not fail the gate. To make missing production evidence a hard release blocker:
94
+
95
+ ```yaml
96
+ production:
97
+ block_on_coverage_gaps: true
98
+ ```
99
+
100
+ ## Reports
101
+
102
+ Each run writes:
103
+
104
+ ```text
105
+ reports/security-report.json
106
+ reports/security-report.md
107
+ reports/security-report.sarif
108
+ reports/sbom.cdx.json
109
+ ```
110
+
111
+ Reports include:
112
+
113
+ - PASS/FAIL summary
114
+ - blockers and warnings
115
+ - production evidence gaps
116
+ - user decisions still needed
117
+ - tool versions and commands
118
+ - exception usage
119
+ - SARIF for GitHub Code Scanning
120
+ - open source maintenance score
121
+
122
+ ## Use With Codex
123
+
124
+ Install as a Codex skill:
125
+
126
+ ```powershell
127
+ git clone https://github.com/xixifusi1213-gif/ai-project-maintainer.git
128
+ cd .\ai-project-maintainer
129
+ Copy-Item -Recurse .\ai-project-maintainer "$env:USERPROFILE\.codex\skills\ai-project-maintainer"
130
+ ```
131
+
132
+ Then ask Codex:
133
+
134
+ ```text
135
+ $ai-project-maintainer generate a production audit plan for this project, run the production gate, fix blockers, and rerun until it passes.
136
+ ```
137
+
138
+ ## Source Checkout Commands
139
+
140
+ If you are using the repository directly instead of npm:
141
+
142
+ ```powershell
143
+ node .\ai-project-maintainer\scripts\doctor.mjs
144
+ node .\ai-project-maintainer\scripts\init-project.mjs "E:\my-project" --profile oss --ci github
145
+ node .\ai-project-maintainer\scripts\init-audit.mjs "E:\my-project"
146
+ node .\ai-project-maintainer\scripts\audit-plan.mjs "E:\my-project" --output reports/audit-plan.json
147
+ node .\ai-project-maintainer\scripts\run-local-gate.mjs "E:\my-project" --production --strict --release --output reports/security-report.json
148
+ node .\ai-project-maintainer\scripts\report-summary.mjs "E:\my-project\reports\security-report.json"
149
+ ```
150
+
151
+ ## What This Is Not
152
+
153
+ This tool does not prove absolute security, replace human risk ownership, or eliminate final audits for high-stakes systems.
154
+
155
+ It is designed for the practical middle ground: a personal developer or small team using AI coding, with enough process to maintain a serious project without manually checking every item from scratch.
156
+
157
+ ## Documentation
158
+
159
+ - [Demo](docs/DEMO.md)
160
+ - [中文演示](docs/DEMO.zh-CN.md)
161
+ - [Production audit workflow](docs/PRODUCTION-AUDIT.zh-CN.md)
162
+ - [Intake schema](docs/INTAKE-SCHEMA.zh-CN.md)
163
+ - [Install guide](docs/INSTALL.zh-CN.md)
164
+ - [GitHub Actions guide](docs/CI-GITHUB-ACTIONS.zh-CN.md)
165
+ - [Policy and exceptions](docs/POLICY-AND-EXCEPTIONS.zh-CN.md)
166
+ - [Promotion kit](docs/PROMOTION.md)
167
+
168
+ ## Development
169
+
170
+ ```powershell
171
+ npm install
172
+ npm test
173
+ npm run check
174
+ npm pack --dry-run
175
+ ```
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: ai-project-maintainer
3
+ description: Orchestrates local and CI safety gates for AI-coded projects across tests, application code, Electron desktop risk, database migrations, network/cloud/IaC security, secrets, dependency risk, Kubernetes, and production incident triage. Use when asked to make a reusable security gate, review or maintain an AI coding project, reduce manual checks, audit PRs or diffs, inspect database or network security risks, set up CI/CD guardrails, download local security tools, or investigate production incidents.
4
+ ---
5
+
6
+ # AI Project Maintainer
7
+
8
+ ## Operating Rules
9
+
10
+ - Treat AI-generated code as untrusted until checked by deterministic tools, tests, and targeted review.
11
+ - Start with repository orientation before running broad scans: inspect git status, recent diffs, project layout, lockfiles, migration files, infra files, and CI config.
12
+ - Prefer evidence-producing checks over generic advice. Every finding should include the file or command evidence, risk, fix, and verification.
13
+ - Default to account-free local gates. Require accounts only for platform evidence: Bytebase projects, cloud/Kubernetes runtime state, staging DAST targets, or observability/incident systems.
14
+ - Use specialized installed skills when they match: `codex-security:security-diff-scan` for diffs, `codex-security:security-scan` for broader security review, and `codex-security:fix-finding` only after a finding is validated.
15
+ - Do not run destructive actions, production writes, schema changes, exploit payloads, or internet-facing active scans without explicit user approval and a named scope.
16
+ - If a tool is not installed, continue with available checks and report the smallest useful tool gap instead of blocking the review.
17
+
18
+ ## Quick Start
19
+
20
+ 1. Check the local environment with `node <this-skill>/scripts/doctor.mjs` or `npx ai-project-maintainer doctor`.
21
+ 2. Initialize a project with `node <this-skill>/scripts/init-project.mjs <repo> --profile oss --ci github` or `npx ai-project-maintainer init <repo> --profile oss --ci github`.
22
+ 3. For production-oriented review, initialize intake with `node <this-skill>/scripts/init-audit.mjs <repo>` or `npx ai-project-maintainer init-audit <repo>`.
23
+ 4. Generate the audit plan with `node <this-skill>/scripts/audit-plan.mjs <repo> --output reports/audit-plan.json` or `npx ai-project-maintainer audit-plan <repo> --output reports/audit-plan.json`.
24
+ 5. For a reusable local safety gate, run `node <this-skill>/scripts/run-local-gate.mjs <repo> --strict --release --output reports/security-report.json` or `npx ai-project-maintainer gate <repo> --strict --release --output reports/security-report.json`.
25
+ 6. For production evidence review, run `node <this-skill>/scripts/run-local-gate.mjs <repo> --production --strict --release --output reports/security-report.json` or `npx ai-project-maintainer gate <repo> --production --strict --release --output reports/security-report.json`.
26
+ 7. Summarize an existing report with `node <this-skill>/scripts/report-summary.mjs <repo>/reports/security-report.json` or `npx ai-project-maintainer summary <repo>/reports/security-report.json`.
27
+ 8. If required local tools are missing on Windows, run `powershell -ExecutionPolicy Bypass -File <this-skill>/scripts/bootstrap-local-tools.ps1 -Tools gitleaks,trivy,semgrep,checkov`.
28
+ 9. Run `node <this-skill>/scripts/probe-project.mjs <repo>` when you only need classification and tool availability.
29
+ 10. Read only the relevant references:
30
+ - Local account-free gate: `references/local-gate.md`
31
+ - Database and migrations: `references/database.md`
32
+ - Electron desktop apps: `references/electron-desktop.md`
33
+ - Code, network, cloud, IaC, dependency, and secret security: `references/security.md`
34
+ - Production incidents and SRE triage: `references/incident-response.md`
35
+ - CI/CD guardrails and maintenance automation: `references/ci-guardrails.md`
36
+ - Tool selection details: `references/tool-router.md`
37
+ 11. Build a short execution plan from the detected risk surfaces and the audit plan.
38
+ 12. Run the least invasive checks first, then deeper checks only where evidence points.
39
+ 13. Return findings first, ordered by severity, with commands/tests already run.
40
+
41
+ ## Modes
42
+
43
+ - **PR or diff review**: Review changed files first. Route changed migrations to database checks, changed infra to IaC/network checks, changed auth/API code to security checks, and changed deploy files to incident-risk checks.
44
+ - **Local safety gate**: Run `run-local-gate.mjs` in strict mode. Use this as the default reusable gate for personal projects before release.
45
+ - **Repository baseline**: Establish current risk posture across secrets, dependencies, static analysis, migrations, IaC, containers, and CI gates.
46
+ - **Electron desktop review**: Inspect preload IPC, BrowserWindow webPreferences, file-system permissions, update trust, navigation controls, shell opening, and multi-window data consistency.
47
+ - **Database migration review**: Focus on lock risk, backfill safety, rollback, compatibility windows, and online migration tools.
48
+ - **Network or cloud security review**: Focus on exposed services, auth boundaries, IAM, CORS, SSRF, TLS, Kubernetes policies, and IaC drift.
49
+ - **Production incident triage**: Stay read-only. Build a timeline from deploys, migrations, metrics, logs, traces, Kubernetes events, and alerts.
50
+ - **Guardrail setup**: Add or propose CI checks only after identifying the repo's package manager, CI provider, and deployment path.
51
+ - **Production audit readiness**: If `.ai-maintainer/project-profile.yml` is missing, run `init-audit` and ask the maintainer to fill business and evidence facts. Then run `audit-plan`, followed by `gate --production`. Treat `GAP` as missing evidence, not proof of safety.
52
+
53
+ ## Output Contract
54
+
55
+ Use this structure unless the user asks otherwise:
56
+
57
+ 1. Findings: severity `P0` to `P3`, evidence, impact, concrete fix, and verification.
58
+ 2. Checks run: commands or skills used and whether they passed, failed, or were unavailable.
59
+ 3. Coverage gaps: important areas not checked and why.
60
+ 4. Next guardrails: the smallest durable automation that would prevent recurrence.
61
+
62
+ For incidents, replace "Findings" with "Current assessment" and include timeline, blast radius, suspected trigger, mitigation options, and rollback safety notes.
@@ -0,0 +1,6 @@
1
+ interface:
2
+ display_name: "AI Project Maintainer"
3
+ short_description: "Reusable local and CI safety gates for AI-coded projects."
4
+ default_prompt: "Use $ai-project-maintainer to run a strict local safety gate for this project and explain any blockers."
5
+ policy:
6
+ allow_implicit_invocation: true
@@ -0,0 +1,55 @@
1
+ # CI Guardrails
2
+
3
+ Use this reference when the user wants durable automation instead of repeated manual review.
4
+
5
+ ## Principle
6
+
7
+ Guardrails should be small, fast, and relevant to the repo. Add blocking checks for high-confidence failures and non-blocking reports for noisy scanners until tuned.
8
+
9
+ ## Minimum Useful Stack
10
+
11
+ For most repos:
12
+
13
+ - Secret scan: Gitleaks or Trivy secret scan.
14
+ - Dependency and image scan: Trivy or native package audit.
15
+ - Static app security: Semgrep auto rules and repo tests.
16
+ - IaC/cloud scan when infra files exist: Checkov or Trivy config.
17
+ - Database migration lint when migrations exist: Squawk/Atlas/strong_migrations/gh-ost/pt-online-schema-change depending on database.
18
+
19
+ ## PR Gates
20
+
21
+ Block PRs for:
22
+
23
+ - Committed secrets.
24
+ - Critical reachable dependency vulnerabilities in production code.
25
+ - Unsafe database migrations likely to lock or rewrite hot tables.
26
+ - Public exposure or privilege escalation in IaC/Kubernetes.
27
+ - Failing tests or type checks in changed service boundaries.
28
+
29
+ Warn but do not block initially for:
30
+
31
+ - Low-confidence SAST findings.
32
+ - Dev-only vulnerabilities.
33
+ - Legacy baseline issues unrelated to the PR.
34
+
35
+ ## Deployment Gates
36
+
37
+ Before production deploy:
38
+
39
+ - Confirm migrations have a rollback or forward-fix plan.
40
+ - Confirm schema/app compatibility for rolling deploys.
41
+ - Confirm images are scanned and signed if the org uses signing.
42
+ - Confirm observability exists for the changed path: logs, metrics, traces, and alerts.
43
+ - Confirm feature flags or rollback commands for high-risk releases.
44
+
45
+ ## Incident Feedback Loop
46
+
47
+ After every incident, add one guardrail that would have detected or prevented it:
48
+
49
+ - Migration lint or staging dry run for DB incidents.
50
+ - Synthetic checks or SLO alerts for user-visible breakage.
51
+ - Policy-as-code for cloud/network misconfigurations.
52
+ - Regression tests for the failed path.
53
+ - Runbook automation for known remediation.
54
+
55
+ Do not add broad tools just to add tools. Tie each new check to a risk surfaced by the project.
@@ -0,0 +1,60 @@
1
+ # Database Review
2
+
3
+ Use this reference when the repo has SQL files, ORM migrations, schema definitions, migration tools, or the user mentions database risk.
4
+
5
+ ## Review Goals
6
+
7
+ - Prevent downtime from locks, table rewrites, long transactions, blocking backfills, and incompatible app/schema deploy order.
8
+ - Preserve rollback options and data integrity.
9
+ - Separate migration safety from application query correctness.
10
+
11
+ ## High-Risk Migration Patterns
12
+
13
+ Flag and verify these patterns:
14
+
15
+ - Adding `NOT NULL` columns with defaults on large existing tables.
16
+ - Creating non-concurrent indexes on hot Postgres tables.
17
+ - Dropping, renaming, or changing types of columns used by deployed code.
18
+ - Large backfills inside a schema migration transaction.
19
+ - Adding foreign keys or constraints without staged validation.
20
+ - Rewriting large tables with `ALTER TABLE` operations.
21
+ - Deleting data during deploy instead of after a compatibility window.
22
+ - Mixing app logic changes and irreversible schema/data changes in one deploy.
23
+ - Missing rollback, down migration, or forward-only recovery plan.
24
+
25
+ ## PostgreSQL Routing
26
+
27
+ - Use Squawk for raw SQL or Postgres migration linting.
28
+ - Use Atlas for schema diff and migration lint when Atlas config or migration dirs exist.
29
+ - Use pgroll when zero-downtime, expand/contract, or rollback-safe Postgres migrations are needed.
30
+ - In Rails, use `strong_migrations` patterns when `db/migrate` exists.
31
+
32
+ Prefer staged changes:
33
+
34
+ 1. Expand schema compatibly.
35
+ 2. Deploy code that reads/writes both old and new shape if needed.
36
+ 3. Backfill in small batches outside the deploy transaction.
37
+ 4. Validate constraints concurrently or in staged form.
38
+ 5. Contract after old code is gone.
39
+
40
+ ## MySQL Routing
41
+
42
+ - Use gh-ost or Percona `pt-online-schema-change` for online schema changes on large tables.
43
+ - Watch for metadata locks, long-running transactions, replication lag, and unsafe DDL.
44
+ - Require a rollback or forward-fix plan for destructive changes.
45
+
46
+ ## ORM-Specific Checks
47
+
48
+ - Prisma/Drizzle/TypeORM/Knex: inspect generated SQL, not only the migration source.
49
+ - Django/Alembic/Flyway/Liquibase: verify transaction behavior, lock behavior, and migration ordering.
50
+ - Rails: check `strong_migrations` compatibility and avoid data backfills inside migration files.
51
+
52
+ ## Output Shape
53
+
54
+ For each migration risk, report:
55
+
56
+ - Affected table or migration file.
57
+ - Lock/rewrite/compatibility risk.
58
+ - Safer migration sequence.
59
+ - Tool coverage used or missing.
60
+ - Verification: local migration test, shadow DB diff, staging dry run, or CI lint.
@@ -0,0 +1,43 @@
1
+ # Electron Desktop Review
2
+
3
+ Use this reference when `electron` appears in dependencies, `BrowserWindow` is used, or files such as `main.js`, `preload.js`, or `renderer.js` exist.
4
+
5
+ ## Blockers
6
+
7
+ Block release for:
8
+
9
+ - `nodeIntegration: true` in renderer windows.
10
+ - `contextIsolation: false`.
11
+ - `webSecurity: false` or `allowRunningInsecureContent: true`.
12
+ - IPC APIs that read, write, delete, execute, or open arbitrary caller-supplied paths.
13
+ - Preload APIs that expose broad filesystem, shell, child process, or network capabilities without per-operation authorization.
14
+ - Auto-update flows that trust a remote hash from the same mutable location as the update metadata.
15
+
16
+ ## Review Checklist
17
+
18
+ - Main process owns privileged actions. Renderers request narrow operations.
19
+ - File import/export paths come from a main-process dialog or a short-lived path token created by the main process.
20
+ - IPC validates sender frame/origin, input schema, allowed path roots, and operation intent.
21
+ - `shell.openExternal` only opens validated `https:` URLs from allowlisted domains.
22
+ - Navigation and new-window handlers deny untrusted destinations.
23
+ - Preload exposes small, named commands instead of raw filesystem or shell primitives.
24
+ - Updates are signed or verified with a trust root not controlled by the update metadata source.
25
+ - Multi-window writes use revision checks, merge-by-scope, or conflict rejection in the main process.
26
+
27
+ ## Useful Tests
28
+
29
+ - Renderer cannot read an arbitrary local file through import IPC.
30
+ - Renderer cannot write outside approved export locations.
31
+ - Main process rejects IPC from unexpected sender frames where feasible.
32
+ - Two windows saving stale snapshots cannot overwrite newer data without conflict detection.
33
+ - Update metadata without valid integrity/signature fails closed.
34
+
35
+ ## Output Standard
36
+
37
+ For Electron findings, include:
38
+
39
+ - Exact exposed API or `BrowserWindow` setting.
40
+ - Attack precondition such as XSS, malicious import data, or compromised update metadata.
41
+ - Privilege gained by renderer code.
42
+ - Main-process authorization fix.
43
+ - Regression test to prove the privilege path is closed.
@@ -0,0 +1,52 @@
1
+ # Incident Response
2
+
3
+ Use this reference when the user reports an outage, degraded service, suspicious production behavior, alert storm, data issue, or asks for SRE/root-cause help.
4
+
5
+ ## Safety Rules
6
+
7
+ - Stay read-only unless the user explicitly asks for a mitigation and confirms the target environment.
8
+ - Preserve evidence before cleanup.
9
+ - Prefer reversible mitigations: rollback, traffic shift, feature flag disable, rate limit, queue pause, or read-only mode.
10
+ - Do not run destructive database, Kubernetes, or cloud commands as part of diagnosis.
11
+
12
+ ## Triage Flow
13
+
14
+ 1. Define the incident window, affected service, symptoms, and customer impact.
15
+ 2. Build a timeline: deploys, config changes, database migrations, infra changes, traffic changes, alerts, and dependency events.
16
+ 3. Check blast radius: which regions, tenants, endpoints, queues, jobs, or database tables are affected.
17
+ 4. Correlate signals: logs, metrics, traces, Kubernetes events, rollout history, error budgets, and saturation metrics.
18
+ 5. Identify likely trigger and immediate mitigation.
19
+ 6. Record follow-up guardrails that would have caught the issue before production.
20
+
21
+ ## Tool Routing
22
+
23
+ - Kubernetes: use `kubectl` read-only commands, k8sgpt, Kubescape, or HolmesGPT.
24
+ - Observability: query Prometheus/Grafana/Loki/ELK/Jaeger/Datadog/Sentry only when credentials or tools are already available.
25
+ - AI SRE: use HolmesGPT or OpenSRE to correlate logs, metrics, traces, and runbooks when configured.
26
+ - Database incidents: read `database.md` and look for recent migrations, locks, slow queries, deadlocks, replication lag, and connection pool exhaustion.
27
+ - Network incidents: read `security.md` and inspect ingress, DNS, certificates, firewall/security-group changes, service mesh, and egress policy.
28
+
29
+ ## Useful Read-Only Commands
30
+
31
+ Adapt to the cluster and namespace:
32
+
33
+ ```bash
34
+ kubectl get pods,deploy,svc,ingress -A
35
+ kubectl get events -A --sort-by=.lastTimestamp
36
+ kubectl rollout history deployment/<name> -n <namespace>
37
+ kubectl logs deployment/<name> -n <namespace> --since=30m
38
+ k8sgpt analyze
39
+ holmes ask "What changed before this alert and what is the most likely root cause?"
40
+ ```
41
+
42
+ ## Incident Output
43
+
44
+ Return:
45
+
46
+ - Current assessment and confidence.
47
+ - Timeline with concrete timestamps where available.
48
+ - Blast radius.
49
+ - Most likely trigger and competing hypotheses.
50
+ - Immediate mitigation options with rollback risk.
51
+ - Evidence still needed.
52
+ - Preventive guardrails for CI, deploy, monitoring, or database migration.
@@ -0,0 +1,117 @@
1
+ # Local Safety Gate
2
+
3
+ Use this reference when the user wants an account-free reusable gate for personal projects.
4
+
5
+ ## What Works Without Accounts
6
+
7
+ These checks can run fully locally when the CLI tools are installed:
8
+
9
+ - Project tests: package-manager scripts such as `test`, `test:e2e`, `build`, and `dist`.
10
+ - Dependency audit: `npm audit --omit=dev` and equivalent package-manager audits where available.
11
+ - Secret scan: Gitleaks or Trivy secret scanner.
12
+ - Filesystem vulnerability/config scan: Trivy.
13
+ - Static app scan: Semgrep, when installed or available through Docker/WSL/Python tooling.
14
+ - IaC scan: Checkov or Trivy config scan.
15
+ - SQL migration lint: Squawk, Atlas, or framework-specific migration tests.
16
+ - Electron baseline: local pattern checks plus manual review of IPC and update paths.
17
+
18
+ Accounts are optional. They are only needed for platform-backed evidence: Bytebase SQL review workflows, cloud IAM state, Kubernetes live cluster state, staging DAST, or incident observability.
19
+
20
+ ## Default Gate Command
21
+
22
+ Check the current machine first:
23
+
24
+ ```bash
25
+ node <skill>/scripts/doctor.mjs
26
+ ```
27
+
28
+ Initialize a project once:
29
+
30
+ ```bash
31
+ node <skill>/scripts/init-project.mjs <repo>
32
+ ```
33
+
34
+ Run this for release decisions:
35
+
36
+ ```bash
37
+ node <skill>/scripts/run-local-gate.mjs <repo> --strict --release --output reports/security-report.json
38
+ ```
39
+
40
+ Use non-strict mode during adoption:
41
+
42
+ ```bash
43
+ node <skill>/scripts/run-local-gate.mjs <repo>
44
+ ```
45
+
46
+ Strict mode treats missing relevant tools as failures. Non-strict mode reports missing tools as coverage gaps.
47
+
48
+ Summarize a saved report:
49
+
50
+ ```bash
51
+ node <skill>/scripts/report-summary.mjs <repo>/reports/security-report.json
52
+ ```
53
+
54
+ ## Adoption Loop
55
+
56
+ 1. Run the gate.
57
+ 2. Fix blocking findings.
58
+ 3. Re-run until pass.
59
+ 4. Add project-specific tests for any bug class found manually.
60
+ 5. Promote stable checks into CI.
61
+
62
+ ## Blocking Standard
63
+
64
+ Block release for:
65
+
66
+ - Failing tests, E2E, build, or release packaging.
67
+ - Committed secrets or high-confidence secret scan findings.
68
+ - High or critical production dependency vulnerabilities without a documented exception.
69
+ - Electron `nodeIntegration: true`, `contextIsolation: false`, `webSecurity: false`, or unrestricted IPC file/system access.
70
+ - Unsafe database migrations: likely lock/table rewrite, destructive incompatible change, or missing rollback for risky schema changes.
71
+ - IaC/Kubernetes settings that expose admin surfaces, plaintext secrets, privileged containers, broad IAM, or public ingress without controls.
72
+
73
+ Warn, tune, or document exceptions for:
74
+
75
+ - Dev-only vulnerabilities.
76
+ - Low-confidence static-analysis findings.
77
+ - Historical baseline issues outside the current change.
78
+ - Missing tools during the first adoption pass.
79
+
80
+ ## Local Tool Bootstrap
81
+
82
+ On Windows, the bundled bootstrap script can download account-free CLI binaries where GitHub release assets are available:
83
+
84
+ ```powershell
85
+ powershell -ExecutionPolicy Bypass -File <skill>\scripts\bootstrap-local-tools.ps1 -Tools gitleaks,trivy,squawk
86
+ ```
87
+
88
+ If `uv` is available, the same script can try Python-tool installs:
89
+
90
+ ```powershell
91
+ powershell -ExecutionPolicy Bypass -File <skill>\scripts\bootstrap-local-tools.ps1 -Tools semgrep,checkov
92
+ ```
93
+
94
+ If Semgrep or Checkov cannot install on the current Windows environment, keep them as coverage gaps and rely on Codex security review plus project tests until Python, Docker, or WSL is ready.
95
+
96
+ ## Policy And Exceptions
97
+
98
+ Project policy lives in:
99
+
100
+ ```text
101
+ .ai-maintainer/policy.yml
102
+ .ai-maintainer/exceptions.yml
103
+ ```
104
+
105
+ Exceptions must include `id`, `check`, `reason`, `expires`, and `owner`. Expired or incomplete exceptions are blocking failures. Exceptions only downgrade the matching finding, not an entire tool category.
106
+
107
+ ## Trivy Database Availability
108
+
109
+ Trivy needs a vulnerability database on first run. The gate uses GHCR first:
110
+
111
+ ```powershell
112
+ $env:TRIVY_DB_REPOSITORY="ghcr.io/aquasecurity/trivy-db:2"
113
+ $env:TRIVY_JAVA_DB_REPOSITORY="ghcr.io/aquasecurity/trivy-java-db:1"
114
+ $env:TRIVY_TIMEOUT="90s"
115
+ ```
116
+
117
+ If the database cannot download, strict mode must fail because dependency and image vulnerability coverage is unavailable. Re-run from a network that can reach the configured OCI registry, or set those environment variables to an internal mirror.
@@ -0,0 +1,48 @@
1
+ # Security Review
2
+
3
+ Use this reference for application, network, cloud, IaC, dependency, container, and secret security checks.
4
+
5
+ ## AI-Coding Risk Hotspots
6
+
7
+ AI-generated code commonly introduces plausible-looking but unsafe shortcuts. Prioritize:
8
+
9
+ - Auth bypasses, missing authorization checks, tenant isolation mistakes, and IDOR.
10
+ - Overbroad CORS, public debug endpoints, permissive admin routes, and missing CSRF protections.
11
+ - SSRF through user-controlled URLs, webhooks, image fetchers, importers, or proxy endpoints.
12
+ - SQL/NoSQL injection from string-built queries or unsafe ORM escape hatches.
13
+ - Unsafe file upload, path traversal, zip extraction, and untrusted document parsing.
14
+ - Disabled TLS verification, weak JWT validation, hardcoded secrets, and secret logging.
15
+ - Excessive IAM permissions, public buckets, open security groups, and unauthenticated internal services.
16
+ - Docker/Kubernetes privileged mode, hostPath mounts, root containers, and exposed dashboards.
17
+
18
+ ## Check Sequence
19
+
20
+ 1. Secrets: run Gitleaks or Trivy secret scan first; never display secret values.
21
+ 2. Dependencies and images: run Trivy or equivalent package audit and separate production/runtime findings from dev-only noise.
22
+ 3. Static analysis: run Semgrep auto rules, CodeQL if configured, and any repo-native lint/security tests.
23
+ 4. IaC and cloud config: run Checkov, Trivy config, Conftest/OPA, or Kubescape depending on files present.
24
+ 5. Targeted manual review: inspect auth boundaries, request validation, dataflow into dangerous sinks, and changed deploy/network files.
25
+ 6. DAST: use ZAP or Nuclei only for an explicitly scoped local/staging target.
26
+
27
+ ## Network and Cloud Review
28
+
29
+ For Terraform, Helm, Kubernetes, Docker Compose, or cloud config, identify:
30
+
31
+ - Internet-exposed ingress/load balancers and whether auth/TLS/WAF is present.
32
+ - Security group or firewall rules with `0.0.0.0/0` or overly broad ports.
33
+ - IAM wildcard actions/resources and cross-account trust.
34
+ - Lack of Kubernetes NetworkPolicy in multi-tenant or internet-facing namespaces.
35
+ - Secret material in manifests, env vars, logs, or image layers.
36
+ - Missing resource limits, health checks, pod disruption budgets, or rollout safety.
37
+
38
+ ## Finding Standard
39
+
40
+ Report only actionable findings. Each security finding needs:
41
+
42
+ - Asset or code path affected.
43
+ - Attack path or failure mode.
44
+ - Exploit preconditions.
45
+ - Concrete fix.
46
+ - Verification command, test, or policy.
47
+
48
+ Mark speculative concerns as coverage gaps, not findings.