Skip to content

chore(repo): package cleanup audit and context tooling - #773

Closed
njrini99-code wants to merge 5 commits into
mainfrom
codex/cleanup-repomix-knip-supabase-audit
Closed

chore(repo): package cleanup audit and context tooling#773
njrini99-code wants to merge 5 commits into
mainfrom
codex/cleanup-repomix-knip-supabase-audit

Conversation

@njrini99-code

Copy link
Copy Markdown
Owner

Summary

Refs #772.

Packages the cleanup audit and context tooling so Greptile and the rest of the review stack can audit the repo hygiene work as a concrete PR diff.

This PR intentionally keeps the scope to docs, generated-file policy, review/context tooling, and static-analysis configuration. It does not mutate Supabase, close issues, delete source files, or run dependency audit fixes.

What changed

  • Adds the repo freshness baseline and consolidated agent handoff for cleanup, Knip, and Supabase linked lint.
  • Adds cleanup PR sequencing, Supabase linked lint fix planning, and tuned Knip triage docs.
  • Adds Repomix config, wrapper, docs, review prompts, and a GitHub Actions workflow to generate context packs.
  • Adds read-only Git hygiene helpers:
    • npm run git:audit
    • npm run git:clean:dry
    • npm run git:stash:audit
  • Adds Knip and architecture helper scripts to package.json.
  • Tunes knip.json to model CRM migration scripts, native Capacitor packages, and intentional admin fixtures.
  • Corrects scripts/README.md so db:types:check is documented as a regenerating check, not harmless read-only verification.
  • Carries the current generated-file drift for next-env.d.ts and public/sw.js into the PR for review.

Current findings packaged here

  • Generated drift remains in next-env.d.ts and public/sw.js; docs explain the commit-vs-generate policy choice.
  • Tuned Knip baseline is 6 file candidates plus 5 unlisted direct imports.
  • Supabase linked lint follow-up is documented for:
    • public.can_manage_baseball_lift_group referencing missing public.baseball_strength_groups
    • public.baseball_accept_staff_invite referencing missing v_invitation.invitee_email
  • Local Git hygiene findings are documented: stashes, gone merged branches, ignored artifact cleanup, and local commit-graph health.

Repomix

npm run fresh:context passed locally and generated gitignored packs under .repomix/:

  • .repomix/helmv3-compressed.xml
  • .repomix/changed-files-context.xml
  • .repomix/helmv3-db-context.xml

All local Repomix security checks passed.

Validation

Passed locally:

npm run typecheck
npm run lint:ratchet
npm run test:run
npm run docs:check
npm run knowledge:check
npm run fresh:context

Notes:

  • npm run test:run result from local pass: 4,398 passed, 39 skipped.
  • npm run knip, npm run knip:files, and npm run knip:deps intentionally still exit 1 with the tuned baseline documented in docs/audits/KNIP_TRIAGE_2026-07-03.md.

@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
helmv3 Ignored Ignored Preview Jul 3, 2026 7:28pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR adds Repomix context-pack tooling (config, ignore rules, generation script, and a GitHub Actions workflow), dependency-cruiser architecture rules, Knip configuration tuning, git audit/cleanup bash scripts, several dated audit/planning markdown documents, review prompt templates, and small generated-file/documentation updates.

Changes

Repomix context pack tooling and CI

Layer / File(s) Summary
Repomix config and ignore rules
repomix.config.json, .repomixignore, .gitignore
Defines Repomix output/ignore/token settings, comprehensive .repomixignore exclusions, and gitignore entries for generated context pack artifacts.
Context generation script and workflow
scripts/context/repomix.sh, .github/workflows/repomix-context.yml
Adds a Node 22 version-gated wrapper invoking npx repomix, wired into a new workflow that generates docs/db/admin context packs, PR changed-file diffs, or a compressed repo pack, then uploads artifacts.
Architecture and dependency tooling
.dependency-cruiser.cjs, knip.json, package.json, CLAUDE.md
Adds dependency-cruiser warning rules, extends Knip entries/ignores, adds ctx:*/architecture npm scripts and devDependencies, and documents context packs in CLAUDE.md.
Context pack usage docs and review prompts
docs/operations/REPOMIX_CONTEXT_PACKS.md, docs/prompts/repomix/*
Documents the context-pack workflow and adds review prompt templates for changed-files, DB audit, and repo cleanup reviews.

Git audit and cleanup scripts

Layer / File(s) Summary
Git audit, clean-dry, and stash-audit scripts
scripts/git/audit.sh, scripts/git/clean-dry.sh, scripts/git/stash-audit.sh
Adds read-only Git health/branch/stash reporting, dry-run cleanup candidate listing, and stash metadata export scripts.

Cleanup and audit planning documentation

Layer / File(s) Summary
Repo freshness baseline audit
docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md
Records read-only git/GitHub/dependency/verification/Knip/Supabase baseline findings and blockers.
Cleanup PR sequence plan
docs/audits/CLEANUP_PR_SEQUENCE_2026-07-03.md
Defines guardrails, generated-file decisions, a 10-step PR sequence, and branch/stash cleanup commands.
Knip triage findings
docs/audits/KNIP_TRIAGE_2026-07-03.md
Documents unused-file/dependency findings and a recommended Knip follow-up checklist.
Supabase linked lint fix plan
docs/audits/SUPABASE_LINKED_LINT_FIX_PLAN_2026-07-03.md
Outlines investigation/remediation steps for two Supabase linked lint errors.
Agent handoff consolidation doc
docs/audits/AGENT_HANDOFF_CLEANUP_KNIP_SUPABASE_2026-07-03.md
Consolidates the three cleanup tracks with guardrails and a first-task checklist.
Review-context indexing
.greptile/files.json
Registers the new audit/operations docs as preload contexts with scoped globs.

Generated files and docs updates

Layer / File(s) Summary
Generated file and script doc updates
next-env.d.ts, scripts/README.md
Points to the production routes type file and clarifies db:types:check manual-check documentation.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Workflow as repomix-context.yml
  participant Script as repomix.sh
  participant Repomix as repomix
  participant Artifact as .repomix/

  Workflow->>Script: run ctx:docs, ctx:db, ctx:admin
  Workflow->>Script: run changed-files XML on pull_request
  Workflow->>Script: run compressed repo pack on workflow_dispatch
  Script->>Repomix: npx repomix@1.16.0 "$@"
  Repomix->>Artifact: write context files
  Workflow->>Artifact: upload repomix-context
Loading

Suggested labels: ci

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning Uses Conventional Commits, but the scope repo is not one of the required scopes. Retitle with an allowed scope such as docs, ops, ci, or deps, e.g. chore(docs): ....
✅ Passed checks (11 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No Service-Role In Client Bundles ✅ Passed PR diff is docs/tooling only; no changed file outside allowed admin paths references SUPABASE_SERVICE_ROLE_KEY or creates a service-role client.
Rls Coverage On New Tables ✅ Passed PR diff contains no files under supabase/migrations/, so there are no changed migrations to inspect for CREATE TABLE/RLS coverage.
Auth Check In Server Actions ✅ Passed No changed files match src/app//actions//*.ts, so no server-action auth ordering issues are in scope.
Sport-Prefixed Table Names ✅ Passed PASS: The only changed TS file is next-env.d.ts:1-5, which is type refs only and contains no Supabase queries or table names.
No Destructive Writes ✅ Passed PASS: PR diff is docs/config/workflow/scripts only (scripts/git/audit.sh:1-84, scripts/git/stash-audit.sh:1-34); no changed save/submit/sync code performs DELETE+INSERT on a table.
No Edits To Historical Migrations ✅ Passed PR diff has no files under supabase/migrations/, so it does not edit any historical migration at or before 20260527120000.
Conventional Commits ✅ Passed PR title 'chore(repo): package cleanup audit and context tooling' and HEAD subject 'chore(review): address cleanup audit feedback' both match the Conventional Commits regex.
Description check ✅ Passed The description matches the changeset and summarizes the docs, tooling, and config updates.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cleanup-repomix-knip-supabase-audit
  • 🛠️ helm safety pass
  • 🛠️ dashboard ux pass
  • 🛠️ rls test pass

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Package repo cleanup audit docs + Repomix/Knip/git hygiene tooling

✨ Enhancement 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Add Repomix context-pack generation (local + CI) for repeatable AI review bundles.
• Package repo-cleanup audit docs (freshness baseline, Knip triage, Supabase lint plan).
• Add read-only repo hygiene scripts (git audit/clean dry-run/stash manifest) and tune Knip.
Diagram

graph TD
  dev(["Developer"]) --> npm["npm scripts"] --> tools["Repo hygiene tools"] --> out[("Context & audit outputs")]
  npm --> wrap["repomix wrapper"] --> rep{{"Repomix"}} --> out
  out --> prompts["Review prompts/docs"]
  gha["GH Action: Repomix Context"] --> npm
  subgraph Legend
    direction LR
    _user(["User/CI"]) ~~~ _proc["Script/step"] ~~~ _ext{{"External tool"}} ~~~ _store[("Artifacts")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Pin Repomix version (vs @latest via npx)
  • ➕ Reproducible context pack output across machines/CI
  • ➕ Avoids surprise behavior changes from upstream releases
  • ➖ Requires ongoing manual bumps
  • ➖ Still constrained by Node >=22 requirement
2. Vendor Repomix as a devDependency behind an optional workspace/tooling package
  • ➕ Versioned in lockfile; easier to standardize across contributors
  • ➕ Can expose typed config + known CLI flags
  • ➖ Adds dependency surface to the repo and complicates Node engine constraints
  • ➖ May conflict with the stated goal of keeping the app dependency graph clean
3. Run Repomix exclusively in a container (local + CI)
  • ➕ Eliminates local Node version friction
  • ➕ More hermetic and consistent execution
  • ➖ Heavier developer workflow; requires Docker availability
  • ➖ More work to integrate filesystem paths and permissions cleanly

Recommendation: The PR’s approach (wrapper + npx, Node 22 enforced only for the context workflow) is a good fit for “tooling without polluting the app graph.” If pack output stability becomes important, the next incremental improvement would be to pin the Repomix version in the wrapper/workflow while keeping it out of dependencies.

Files changed (23) +1445 / -9

Enhancement (1) +32 / -1
package.jsonAdd scripts for Knip, architecture checks, Repomix packs, and git hygiene +32/-1

Add scripts for Knip, architecture checks, Repomix packs, and git hygiene

• Adds a large set of npm scripts for Knip modes, dependency/architecture checks, Repomix context-pack generation (including 'fresh:context'), and read-only git hygiene helpers. Introduces 'dependency-cruiser' and 'madge' as devDependencies to support the new checks.

package.json

Documentation (11) +970 / -4
CLAUDE.mdDocument Repomix context-pack workflow in agent guidance +6/-0

Document Repomix context-pack workflow in agent guidance

• Adds a short section describing Repomix context packs, where outputs land, and where to start reading ('docs/operations/REPOMIX_CONTEXT_PACKS.md').

CLAUDE.md

AGENT_HANDOFF_CLEANUP_KNIP_SUPABASE_2026-07-03.mdAdd consolidated agent handoff for cleanup, Knip, and Supabase lint +177/-0

Add consolidated agent handoff for cleanup, Knip, and Supabase lint

• Packages the cleanup sequencing, Knip triage, and Supabase linked-lint fix planning into a single handoff. Emphasizes guardrails (no linked DB mutation, no deletes on first Knip pass, no audit-fix automation) and provides a recommended PR order.

docs/audits/AGENT_HANDOFF_CLEANUP_KNIP_SUPABASE_2026-07-03.md

CLEANUP_PR_SEQUENCE_2026-07-03.mdAdd recommended small-PR cleanup sequence and guardrails +66/-0

Add recommended small-PR cleanup sequence and guardrails

• Defines a staged PR plan for audit correction, git hygiene tooling, security patches, Supabase planning/migration, and Knip tuning/deletion batches. Includes explicit notes on 'db:types:check' being regenerative and therefore not a harmless read-only gate.

docs/audits/CLEANUP_PR_SEQUENCE_2026-07-03.md

KNIP_TRIAGE_2026-07-03.mdAdd Knip baseline and deletion rules +61/-0

Add Knip baseline and deletion rules

• Records the tuned Knip baseline, lists unused-file and dependency findings with risk/next checks, and reiterates “no deletion in first pass.” Calls out unlisted dependencies to resolve intentionally.

docs/audits/KNIP_TRIAGE_2026-07-03.md

REPO_FRESHNESS_BASELINE_2026-07-03.mdAdd repo freshness baseline audit and verification results +459/-0

Add repo freshness baseline audit and verification results

• Adds a detailed snapshot of current repo hygiene (git state, stashes/branches, fsck/commit-graph, ignored artifacts), package/security audit summaries, Knip and Supabase linked-lint findings, and which checks were deferred for safety.

docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md

SUPABASE_LINKED_LINT_FIX_PLAN_2026-07-03.mdAdd read-only plan to fix two Supabase linked-lint errors +58/-0

Add read-only plan to fix two Supabase linked-lint errors

• Documents suspected causes and a safe, evidence-first path for resolving two linked-lint errors by fetching live function bodies/columns before writing migrations. Explicitly avoids restoring legacy tables/columns without product confirmation.

docs/audits/SUPABASE_LINKED_LINT_FIX_PLAN_2026-07-03.md

REPOMIX_CONTEXT_PACKS.mdDocument how to generate Repomix context packs safely +68/-0

Document how to generate Repomix context packs safely

• Adds operational docs for ctx:* scripts, Node 22 requirement rationale, and how 'fresh:context' composes docs/knowledge checks with pack generation. Notes that packs are sensitive and '.repomix/' is ignored.

docs/operations/REPOMIX_CONTEXT_PACKS.md

changed-files-review.mdAdd prompt template for changed-files reviews +23/-0

Add prompt template for changed-files reviews

• Adds a structured review prompt for Repomix changed/staged file packs, focusing on regressions, missing tests, and boundary correctness rather than style.

docs/prompts/repomix/changed-files-review.md

db-audit.mdAdd prompt template for database/schema audits +24/-0

Add prompt template for database/schema audits

• Adds a DB audit prompt that stresses evidence-based findings, RLS/service-role risk separation, drift vs generated types, and migration-safe verification commands.

docs/prompts/repomix/db-audit.md

repo-cleanup.mdAdd prompt template for repo cleanup audits +23/-0

Add prompt template for repo cleanup audits

• Adds a cleanup review prompt that discourages unsafe deletions, highlights generated artifact handling, and promotes small reversible patches with explicit verification.

docs/prompts/repomix/repo-cleanup.md

README.mdCorrect db:types:check documentation to reflect regeneration behavior +5/-4

Correct db:types:check documentation to reflect regeneration behavior

• Updates docs to clarify that 'db:types:check' regenerates types and then fails on drift, rather than being a read-only verification. Adds guidance to run it only when a generated diff is acceptable.

scripts/README.md

Other (11) +443 / -4
.dependency-cruiser.cjsAdd dependency-cruiser rules for feature/admin boundaries +71/-0

Add dependency-cruiser rules for feature/admin boundaries

• Introduces dependency-cruiser configuration with warning-level constraints for circular deps, client→server/admin imports, cross-sport imports, shared UI purity, and legacy baseball lift/strength references. Excludes build/test/doc-generated paths to keep the baseline signal-focused.

.dependency-cruiser.cjs

repomix-context.ymlAdd CI workflow to generate and upload Repomix context packs +69/-0

Add CI workflow to generate and upload Repomix context packs

• Adds a GitHub Actions workflow that runs on-demand or on PR changes to context-related files. Generates docs/DB/admin packs and a PR diff-based changed-files pack, then uploads '.repomix/' as an artifact.

.github/workflows/repomix-context.yml

.repomixignoreDefine Repomix ignore policy for secrets, caches, and sensitive docs +98/-0

Define Repomix ignore policy for secrets, caches, and sensitive docs

• Adds a dedicated ignore file to keep secrets, local tool state, large artifacts, and sensitive setup docs out of broad context packs. Explicitly ignores '.repomix/' outputs and other agent folders.

.repomixignore

knip.jsonTune Knip entrypoints/ignores for CRM scripts, fixtures, and Capacitor +13/-2

Tune Knip entrypoints/ignores for CRM scripts, fixtures, and Capacitor

• Models CRM migration scripts as entrypoints, excludes admin test fixtures from unused-file reports, and ignores Capacitor dependencies that are expected to be referenced from native iOS configuration.

knip.json

next-env.d.tsCarry forward Next generated route-types import drift +1/-1

Carry forward Next generated route-types import drift

• Updates the referenced routes types path from '.next/dev/types/...' to '.next/types/...', reflecting current generated output differences between dev and production builds.

next-env.d.ts

sw.jsCarry forward stamped service-worker cache version drift +1/-1

Carry forward stamped service-worker cache version drift

• Updates the service worker cache version string to the current commit-stamped value, reflecting generated artifact drift produced during build/prebuild stamping.

public/sw.js

repomix.config.jsonAdd Repomix config with ignore + security checks enabled +48/-0

Add Repomix config with ignore + security checks enabled

• Adds a repository Repomix configuration with XML output defaults, custom ignore patterns (including sensitive docs/scripts), and security checks enabled for context generation.

repomix.config.json

repomix.shAdd Repomix wrapper enforcing Node 22+ before running npx +22/-0

Add Repomix wrapper enforcing Node 22+ before running npx

• Adds a small bash wrapper that checks for Node presence and enforces Node major >=22 with actionable remediation instructions. Executes 'npx -y repomix@latest' with passed-through arguments.

scripts/context/repomix.sh

audit.shAdd read-only git audit script for repo hygiene baseline +64/-0

Add read-only git audit script for repo hygiene baseline

• Adds a script that prints status/branches, merged branch candidates, stash list, clean dry-runs, object counts, commit-graph verification, and an fsck summary without mutating the repo.

scripts/git/audit.sh

clean-dry.shAdd dry-run cleanup inventory for untracked/ignored artifacts +23/-0

Add dry-run cleanup inventory for untracked/ignored artifacts

• Adds a read-only script to show 'git clean' dry-run output and report sizes for common cache directories to help plan targeted cleanup safely.

scripts/git/clean-dry.sh

stash-audit.shAdd stash manifest generator under docs/audits/generated +33/-0

Add stash manifest generator under docs/audits/generated

• Adds a script that records stash list and per-stash stat files, and writes a markdown manifest for human decisioning. Does not apply/pop/drop stashes.

scripts/git/stash-audit.sh

@coderabbitai coderabbitai Bot added the ci CI, Vercel, test, build, deploy label Jul 3, 2026
@njrini99-code

Copy link
Copy Markdown
Owner Author

@greptileai please review this PR with the updated .greptile/files.json cleanup-audit context. Focus especially on the Repomix workflow/config, Knip baseline changes, generated-file drift docs, Supabase linked-lint plan, and whether the packaged issue/report context is accurate enough for follow-up fixes.

@qodo-code-review

qodo-code-review Bot commented Jul 3, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 97 rules

Grey Divider


Action required

1. npm audit fix --dry-run recorded ✓ Resolved 📎 Requirement gap ⛨ Security
Description
The new repo freshness baseline document states that npm audit fix --dry-run was run. This
violates the requirement to avoid using npm audit fix during this cleanup effort.
Code

docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md[235]

+`npm audit fix --dry-run` was run. It did not change the working tree, but it proposed a large dependency reshuffle:
Relevance

⭐⭐ Medium

No historical evidence enforcing “never run npm audit fix (even --dry-run)” in docs.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1555268 forbids using npm audit fix. The added baseline document explicitly says
npm audit fix --dry-run was run.

Do not run npm audit fix (including --force)
docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md[235-242]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md` states that `npm audit fix --dry-run` was run, but this cleanup effort forbids using `npm audit fix` (including dry runs).

## Issue Context
Compliance requires avoiding `npm audit fix` to prevent broad/unreviewable dependency churn.

## Fix Focus Areas
- docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md[235-248]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. next-env.d.ts drift bundled ✓ Resolved 📎 Requirement gap ⚙ Maintainability
Description
This PR includes generated-file drift updates (next-env.d.ts and public/sw.js) alongside broad
audit/tooling changes, rather than isolating generated-file drift into a narrow PR. This reduces
reviewability and violates the required separation.
Code

next-env.d.ts[3]

+import "./.next/types/routes.d.ts";
Relevance

⭐⭐ Medium

No historical evidence found requiring generated-file drift to be isolated into a separate PR.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1555272 requires generated-file drift to be isolated. This PR changes
next-env.d.ts and public/sw.js while also introducing broad tooling/script changes (e.g., many
new package.json scripts), demonstrating the drift is not separated.

Keep generated-file/audit-output cleanup separate from app behavior changes
next-env.d.ts[1-3]
public/sw.js[19-22]
package.json[57-86]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Generated-file drift changes were included in this PR together with other cleanup/audit/tooling work.

## Issue Context
Compliance requires generated drift (e.g., `next-env.d.ts`, `public/sw.js`) to be handled in a dedicated, narrow PR rather than bundled with other changes.

## Fix Focus Areas
- next-env.d.ts[1-3]
- public/sw.js[19-19]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Broken CI typecheck import ✓ Resolved 🐞 Bug ≡ Correctness
Description
next-env.d.ts imports ./.next/types/routes.d.ts, but .next/ is gitignored and the CI
TypeScript job runs tsc --noEmit without generating .next first, so clean CI runs will fail with
a missing-module error.
Code

next-env.d.ts[3]

+import "./.next/types/routes.d.ts";
Relevance

⭐⭐ Medium

No historical evidence found for rejecting next-env.d.ts importing gitignored .next route types
causing CI tsc failure.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR adds an explicit import to a .next/ file that is not tracked; CI’s TypeScript job runs `tsc
--noEmit` directly after install, so the imported file won’t exist and typecheck will fail.

next-env.d.ts[1-4]
.gitignore[19-22]
package.json[16-24]
.github/workflows/ci.yml[89-110]
tsconfig.json[58-66]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`next-env.d.ts` imports a generated file under `.next/`, but `.next/` is ignored and not present on clean checkouts. CI runs `npm run typecheck` (`tsc --noEmit`) before any `next build/dev` step in the TypeScript job, so the import can break CI.

## Issue Context
- `.next/` is ignored by git.
- `tsconfig.json` already includes `.next/types/**/*.ts` and `.next/dev/types/**/*.ts` when they exist, so the explicit import is unnecessary for type inclusion and creates a hard dependency on a generated file.

## Fix Focus Areas
- next-env.d.ts[1-6]
- tsconfig.json[58-66]
- package.json[16-24]
- .github/workflows/ci.yml[89-110]

## Recommended fix
- Remove the `import "./.next/types/routes.d.ts";` line from `next-env.d.ts`.
- Rely on `tsconfig.json` `include` globs (`.next/types/**/*.ts`, `.next/dev/types/**/*.ts`) to pick up those files when they exist (e.g., after `next dev` / `next build`).

## Verification
- On a clean checkout with no `.next/` directory: `npm ci && npm run typecheck` should pass.
- After a `next build` (which generates `.next/types`): `npm run typecheck` should still pass and include generated types via `tsconfig.json`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. Checkout persists git credentials ✓ Resolved 🐞 Bug ⛨ Security
Description
The new Repomix workflow uses actions/checkout without persist-credentials: false, leaving the
GITHUB_TOKEN in git config for the remainder of the job unlike the hardened baseline used
elsewhere in CI.
Code

.github/workflows/repomix-context.yml[R26-30]

+      - name: Checkout
+        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
+        with:
+          fetch-depth: 50
+
Relevance

⭐⭐⭐ High

CI checkout hardening with persist-credentials:false was accepted previously (PR #420).

PR-#420

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The Repomix workflow’s checkout omits persist-credentials: false, while the existing CI workflow
consistently sets it, indicating this workflow is missing an established security hardening control.

.github/workflows/repomix-context.yml[18-30]
.github/workflows/ci.yml[94-99]
PR-#420

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`.github/workflows/repomix-context.yml` checks out the repository without `persist-credentials: false`. This persists the workflow token in the local git config for the job duration.

## Issue Context
The repo’s main CI workflow explicitly sets `persist-credentials: false` for checkout steps, which is a standard hardening measure.

## Fix Focus Areas
- .github/workflows/repomix-context.yml[25-30]
- .github/workflows/ci.yml[94-99]

## Recommended fix
Add:
```yaml
with:
 fetch-depth: 50
 persist-credentials: false
```
(or keep `fetch-depth` as-is) to the Repomix workflow’s checkout step.

## Verification
- Ensure the workflow still successfully fetches the base ref and generates packs.
- Confirm `git config --local --get-regexp credential` does not show persisted credentials in later steps.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Repomix runs unpinned latest ✓ Resolved 🐞 Bug ⛨ Security
Description
scripts/context/repomix.sh runs npx -y repomix@latest, so CI context pack generation is
non-deterministic over time and can change (or break) without any repo change.
Code

scripts/context/repomix.sh[22]

+npx -y repomix@latest "$@"
Relevance

⭐⭐ Medium

No clear historical pattern rejecting npx tool@latest in repo scripts; supply-chain hardening varies
by context.

PR-#521
PR-#621

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The wrapper explicitly pulls @latest, and the workflow/npm scripts call this wrapper, so CI will
execute unpinned third-party code each run.

scripts/context/repomix.sh[9-22]
package.json[69-86]
.github/workflows/repomix-context.yml[40-48]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Repomix wrapper executes `npx -y repomix@latest`, which pulls whatever Repomix currently publishes as latest at run time. This makes CI behavior non-reproducible and increases supply-chain drift risk.

## Issue Context
This wrapper is invoked by multiple `ctx:*` npm scripts and by the `Repomix Context` GitHub Action job.

## Fix Focus Areas
- scripts/context/repomix.sh[1-22]
- package.json[69-86]
- .github/workflows/repomix-context.yml[40-48]

## Recommended fix
- Replace `repomix@latest` with a pinned version (e.g., `repomix@X.Y.Z`).
- Optional: allow overriding via an environment variable, e.g.:
 - `REPOMIX_VERSION=${REPOMIX_VERSION:-X.Y.Z}`
 - `npx -y "repomix@${REPOMIX_VERSION}" "$@"`
- Document the pinned version update process in `docs/operations/REPOMIX_CONTEXT_PACKS.md`.

## Verification
- Run `npm run ctx:docs`, `npm run ctx:db`, `npm run ctx:admin` locally and in CI to confirm identical Repomix CLI behavior across runs.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md Outdated
Comment thread next-env.d.ts Outdated
Comment thread next-env.d.ts Outdated
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/dev/types/routes.d.ts";
import "./.next/types/routes.d.ts";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

3. Broken ci typecheck import 🐞 Bug ≡ Correctness

next-env.d.ts imports ./.next/types/routes.d.ts, but .next/ is gitignored and the CI
TypeScript job runs tsc --noEmit without generating .next first, so clean CI runs will fail with
a missing-module error.
Agent Prompt
## Issue description
`next-env.d.ts` imports a generated file under `.next/`, but `.next/` is ignored and not present on clean checkouts. CI runs `npm run typecheck` (`tsc --noEmit`) before any `next build/dev` step in the TypeScript job, so the import can break CI.

## Issue Context
- `.next/` is ignored by git.
- `tsconfig.json` already includes `.next/types/**/*.ts` and `.next/dev/types/**/*.ts` when they exist, so the explicit import is unnecessary for type inclusion and creates a hard dependency on a generated file.

## Fix Focus Areas
- next-env.d.ts[1-6]
- tsconfig.json[58-66]
- package.json[16-24]
- .github/workflows/ci.yml[89-110]

## Recommended fix
- Remove the `import "./.next/types/routes.d.ts";` line from `next-env.d.ts`.
- Rely on `tsconfig.json` `include` globs (`.next/types/**/*.ts`, `.next/dev/types/**/*.ts`) to pick up those files when they exist (e.g., after `next dev` / `next build`).

## Verification
- On a clean checkout with no `.next/` directory: `npm ci && npm run typecheck` should pass.
- After a `next build` (which generates `.next/types`): `npm run typecheck` should still pass and include generated types via `tsconfig.json`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread .github/workflows/repomix-context.yml
Comment thread scripts/context/repomix.sh Outdated
@njrini99-code

Copy link
Copy Markdown
Owner Author

@greptileai please rerun on the latest commit. I added the cleanup-audit context, fixed Repomix artifact upload, pinned Repomix, hardened checkout credentials, and removed the generated .next import from next-env.d.ts.

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown

Greptile Summary

This PR packages repo cleanup audit work and adds context-pack tooling. The main changes are:

  • New Repomix config, wrapper script, prompts, docs, and GitHub Actions workflow.
  • New read-only Git hygiene scripts for branch, stash, and clean dry-run audits.
  • Knip and dependency-cruiser configuration for cleanup triage.
  • Audit docs covering generated-file drift, Supabase linked lint planning, and cleanup sequencing.
  • Generated-file drift carried for next-env.d.ts and public/sw.js.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
.github/workflows/repomix-context.yml Adds the context-pack workflow with fork gating, read-only permissions, pinned actions, and artifact upload.
scripts/context/repomix.sh Adds a small Node version check and Repomix wrapper used by the context-pack commands.
scripts/git/audit.sh Adds a read-only Git branch audit helper with baseline branch resolution.
knip.json Tunes Knip cleanup triage for scripts, fixtures, native packages, and known generated surfaces.
repomix.config.json Defines Repomix output, security checks, ignore behavior, and XML generation settings.

Reviews (3): Last reviewed commit: "chore(review): address cleanup audit fee..." | Re-trigger Greptile

Comment thread .github/workflows/repomix-context.yml
Comment thread scripts/git/audit.sh Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/repomix-context.yml:
- Around line 26-29: The Checkout step in the repomix-context workflow keeps git
credentials on disk by default, which is unnecessary for this read-only job.
Update the actions/checkout configuration in the Checkout step to explicitly
disable credential persistence with persist-credentials set to false, since this
job only runs npm ci and repomix and never pushes changes back.
- Around line 51-57: The workflow step currently interpolates github.base_ref
directly inside run:, which creates shell-injection risk and triggers the
security findings. Move the base branch value into env: on the same job step,
then reference that shell variable in both the git fetch and git diff commands
in the repomix context generation step. Keep the existing behavior in the
workflow that runs scripts/context/repomix.sh, but ensure no ${{ }} expression
is expanded inside the shell script itself.
- Around line 3-16: The repomix-context workflow currently allows multiple
overlapping runs for the same pull request, which can pile up on repeated
pushes. Update the workflow in the `on.pull_request` path to add a concurrency
group keyed to the PR ref so newer runs cancel superseded ones, and make sure
`workflow_dispatch` still works cleanly with the same workflow definition.

In `@package.json`:
- Around line 69-86: The new ctx:* scripts in package.json rely on
scripts/context/repomix.sh, but the current engines.node floor still advertises
an older Node range. Update the engines.node entry to match the actual Node 22+
requirement, or explicitly document that Node version enforcement is handled
elsewhere so the lower floor is intentional; use the ctx:repo and fresh:context
script entries as the anchor for locating the affected block.
- Around line 75-85: The new ctx:* scripts added to package.json are not
documented in the workflow guide, so update
docs/operations/REPOMIX_CONTEXT_PACKS.md to enumerate the new script names and
what each pack covers. Use the package.json entries for ctx:db, ctx:baseball,
ctx:golf, ctx:admin, ctx:ui, ctx:tests, ctx:changed, ctx:staged, ctx:docs,
ctx:budget:compressed, and ctx:budget:changed as the source of truth, and keep
the documentation aligned with the existing ctx:repo-style descriptions.
- Line 73: The script named ctx:repo:npx is misleading because it still calls
scripts/context/repomix.sh instead of invoking Repomix through npx. Update the
package.json script so the ctx:repo:npx entry actually uses npx -y
repomix@latest (consistent with the project convention), or rename the script to
match its current wrapper-based behavior; keep the related ctx:repo script
naming and behavior aligned so the intent is clear.

In `@repomix.config.json`:
- Line 2: The Repomix config is using the floating latest schema alias, which
can change behavior without any repo diff. Update the $schema entry in
repomix.config.json to a pinned schema version that matches the repomix@latest
CLI version used by scripts/context/repomix.sh, or remove the schema pointer if
you are switching to a specific tagged version.

In `@scripts/git/stash-audit.sh`:
- Around line 4-6: The stash audit script is not idempotent because stale stash
stat files can remain when the stash count shrinks. Update
`scripts/git/stash-audit.sh` so it cleans up any previously generated
`stash-*-stat.txt` files in `out_dir` before regenerating the current set, or
otherwise removes files beyond the current stash count; keep the logic aligned
with the existing output generation so `README.md` and the files in `out_dir`
always match.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2049f366-1dd4-41f0-94eb-86b5602c94fd

📥 Commits

Reviewing files that changed from the base of the PR and between 8b9986e and 589bd2a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json, !**/package-lock.json
📒 Files selected for processing (24)
  • .dependency-cruiser.cjs
  • .github/workflows/repomix-context.yml
  • .gitignore
  • .repomixignore
  • CLAUDE.md
  • docs/audits/AGENT_HANDOFF_CLEANUP_KNIP_SUPABASE_2026-07-03.md
  • docs/audits/CLEANUP_PR_SEQUENCE_2026-07-03.md
  • docs/audits/KNIP_TRIAGE_2026-07-03.md
  • docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md
  • docs/audits/SUPABASE_LINKED_LINT_FIX_PLAN_2026-07-03.md
  • docs/operations/REPOMIX_CONTEXT_PACKS.md
  • docs/prompts/repomix/changed-files-review.md
  • docs/prompts/repomix/db-audit.md
  • docs/prompts/repomix/repo-cleanup.md
  • knip.json
  • next-env.d.ts
  • package.json
  • public/sw.js
  • repomix.config.json
  • scripts/README.md
  • scripts/context/repomix.sh
  • scripts/git/audit.sh
  • scripts/git/clean-dry.sh
  • scripts/git/stash-audit.sh

Comment thread .github/workflows/repomix-context.yml
Comment thread .github/workflows/repomix-context.yml
Comment thread .github/workflows/repomix-context.yml
Comment thread package.json
Comment on lines +69 to +86
"ctx:repo": "mkdir -p .repomix && bash scripts/context/repomix.sh --output .repomix/helmv3-full.xml --style xml --include-logs --include-logs-count 30 --top-files-len 30",
"ctx:repo:compressed": "mkdir -p .repomix && bash scripts/context/repomix.sh --compress --output .repomix/helmv3-compressed.xml --style xml --include-logs --include-logs-count 30 --top-files-len 30",
"ctx:repo:diff": "mkdir -p .repomix && bash scripts/context/repomix.sh --include-diffs --include-logs --include-logs-count 20 --output .repomix/helmv3-diff-context.xml --style xml --top-files-len 30",
"ctx:repo:md": "mkdir -p .repomix && bash scripts/context/repomix.sh --output .repomix/helmv3-full.md --style markdown --include-logs --include-logs-count 30 --top-files-len 30",
"ctx:repo:npx": "mkdir -p .repomix && bash scripts/context/repomix.sh --output .repomix/helmv3-full.xml --style xml --include-logs --include-logs-count 30",
"ctx:token-tree": "bash scripts/context/repomix.sh --token-count-tree 1000 --no-files --top-files-len 50",
"ctx:db": "mkdir -p .repomix && bash scripts/context/repomix.sh --include \"supabase/migrations/**/*.sql,src/lib/types/database.ts,scripts/db/**/*.sql,scripts/check-migration-ledger.mjs,scripts/check-types-drift.sh,memory/glossary.md,memory/context/golfhelm-database.md\" --output .repomix/helmv3-db-context.xml --style xml --include-logs --include-logs-count 20",
"ctx:baseball": "mkdir -p .repomix && bash scripts/context/repomix.sh --include \"src/app/baseball/**,src/components/baseball/**,src/lib/baseball/**,scripts/baseball/**,memory/context/baseballhelm-features.md,docs/audits/BASEBALLHELM_CANONICAL_SPEC.md\" --output .repomix/baseballhelm-context.xml --style xml --include-logs --include-logs-count 20 --top-files-len 40",
"ctx:golf": "mkdir -p .repomix && bash scripts/context/repomix.sh --include \"src/app/golf/**,src/app/dashboard/**,src/components/golf/**,src/lib/golf/**,memory/context/golfhelm-features.md,memory/projects/golfhelm.md\" --output .repomix/golfhelm-context.xml --style xml --include-logs --include-logs-count 20 --top-files-len 40",
"ctx:admin": "mkdir -p .repomix && bash scripts/context/repomix.sh --include \"src/app/admin/**,src/app/api/admin/**,src/lib/admin/**,src/components/admin/**,.github/workflows/**,docs/audits/**\" --output .repomix/admin-bridge-context.xml --style xml --include-logs --include-logs-count 20 --top-files-len 40",
"ctx:ui": "mkdir -p .repomix && bash scripts/context/repomix.sh --include \"src/app/**/page.tsx,src/components/**/*.tsx,src/app/globals.css,tailwind.config.ts,components.json\" --ignore \"**/*.test.ts,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx\" --output .repomix/ui-context.xml --style xml --top-files-len 40",
"ctx:tests": "mkdir -p .repomix && bash scripts/context/repomix.sh --include \"tests/**,src/**/*.test.ts,src/**/*.test.tsx,src/**/*.spec.ts,src/**/*.spec.tsx,playwright*.config.*,vitest.config.*\" --output .repomix/test-context.xml --style xml --top-files-len 40",
"ctx:changed": "mkdir -p .repomix && git ls-files --modified --others --exclude-standard | bash scripts/context/repomix.sh --stdin --include-diffs --include-logs --include-logs-count 15 --output .repomix/changed-files-context.xml --style xml --top-files-len 40",
"ctx:staged": "mkdir -p .repomix && git diff --cached --name-only | bash scripts/context/repomix.sh --stdin --include-diffs --include-logs --include-logs-count 15 --output .repomix/staged-files-context.xml --style xml --top-files-len 40",
"ctx:docs": "mkdir -p .repomix && bash scripts/context/repomix.sh --include \"CLAUDE.md,memory/**,docs/**/*.md,README.md,.github/workflows/docs-regen.yml,scripts/regen-docs.mjs\" --output .repomix/docs-memory-context.xml --style xml --include-logs --include-logs-count 20",
"ctx:budget:compressed": "mkdir -p .repomix && bash scripts/context/repomix.sh --compress --token-budget 500000 --output .repomix/helmv3-compressed.xml --style xml",
"ctx:budget:changed": "mkdir -p .repomix && git ls-files --modified --others --exclude-standard | bash scripts/context/repomix.sh --stdin --include-diffs --token-budget 200000 --output .repomix/changed-files-context.xml --style xml",
"fresh:context": "npm run docs:check && npm run knowledge:check && npm run ctx:repo:compressed && npm run ctx:changed && npm run ctx:db"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

engines.node (>=20.16.0) doesn't reflect the Node 22+ requirement for the new ctx:* scripts.

14 new ctx:* scripts (lines 69-86) all shell out to scripts/context/repomix.sh. Per project learnings, Repomix context-pack generation requires Node 22+ (e.g. via nvm use 22). The declared engines.node floor is >=20.16.0 (line 93), so npm install/npm run won't warn a contributor on Node 20.16–21.x before they hit an opaque failure inside the wrapper script.

Either bump engines.node to reflect the real floor, or make sure the floor is intentionally decoupled and the wrapper's own version guard (per PR description, "enforcing Node version prerequisites") is the sole enforcement point — in which case this is fine, but worth a one-line comment in package.json so it isn't "fixed" incorrectly later.

Also applies to: 93-93

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` around lines 69 - 86, The new ctx:* scripts in package.json
rely on scripts/context/repomix.sh, but the current engines.node floor still
advertises an older Node range. Update the engines.node entry to match the
actual Node 22+ requirement, or explicitly document that Node version
enforcement is handled elsewhere so the lower floor is intentional; use the
ctx:repo and fresh:context script entries as the anchor for locating the
affected block.

Source: Learnings

Comment thread package.json Outdated
Comment thread package.json
Comment thread repomix.config.json Outdated
Comment thread scripts/git/stash-audit.sh
@njrini99-code njrini99-code changed the title [codex] package cleanup audit and context tooling chore(repo): package cleanup audit and context tooling Jul 3, 2026
@njrini99-code

Copy link
Copy Markdown
Owner Author

Review/fix status as of commit 130bd23 on PR #773.

Collected context from:

Applied in this follow-up commit:

  • Added Repomix workflow concurrency so superseded PR runs cancel.
  • Skipped Repomix context generation for forked PRs to avoid running PR-controlled scripts and uploading PR-controlled artifacts.
  • Kept persist-credentials:false and env-based BASE_REF hardening already present from the prior fix.
  • Made scripts/git/audit.sh detect the default branch/baseline instead of hard-coding main.
  • Made scripts/git/stash-audit.sh idempotent by clearing stale stash stat files before regenerating.
  • Removed floating Repomix schema latest from repomix.config.json while the wrapper pins repomix@1.16.0.
  • Renamed misleading ctx:repo:npx to ctx:repo:no-top-files and documented all context-pack scripts, including budgeted packs.
  • Clarified the Node 22 requirement is enforced by the Repomix wrapper, not by raising the app-wide engines.node floor.
  • Corrected the baseline doc so it no longer records or encourages npm audit fix --dry-run.
  • Reverted the pure public/sw.js cache stamp drift out of this PR.
  • Ignored local .codebase-memory/ graph artifacts so the new MCP index is not accidentally committed.
  • Renamed the PR title to Conventional Commit format.

Validation run locally:

  • npm run typecheck
  • npm run docs:check
  • npm run ctx:docs
  • npm run git:audit
  • npm run git:stash:audit
  • git diff --check
  • JSON parse check for package.json and repomix.config.json
  • bash -n for touched shell scripts

Notes/deferred:

@greptileai please rerun on the latest commit 130bd23.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/operations/REPOMIX_CONTEXT_PACKS.md`:
- Around line 19-23: The Repomix override example is using the wrapper’s current
default version, so it does not demonstrate an actual override. Update the
example under the Repomix version guidance to use a different non-default
candidate value (or a clearly placeholder version) so it matches the description
of testing via REPOMIX_VERSION and can be located in REPOMIX_VERSION and
scripts/context/repomix.sh references.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4b5a689b-6982-4eee-9b74-5ceee2b3f8a6

📥 Commits

Reviewing files that changed from the base of the PR and between 589bd2a and 6d70c57.

📒 Files selected for processing (5)
  • .github/workflows/repomix-context.yml
  • .greptile/files.json
  • docs/operations/REPOMIX_CONTEXT_PACKS.md
  • next-env.d.ts
  • scripts/context/repomix.sh
💤 Files with no reviewable changes (1)
  • next-env.d.ts

Comment on lines +19 to +23
To test a Repomix upgrade before changing the pinned default, set `REPOMIX_VERSION`:

```bash
REPOMIX_VERSION=1.16.0 bash scripts/context/repomix.sh --version
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Make the override example actually test an override.

REPOMIX_VERSION=1.16.0 is the wrapper’s current default, so this sample never exercises the env override described above. Use a different candidate version (or a placeholder) so the example matches the text.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/operations/REPOMIX_CONTEXT_PACKS.md` around lines 19 - 23, The Repomix
override example is using the wrapper’s current default version, so it does not
demonstrate an actual override. Update the example under the Repomix version
guidance to use a different non-default candidate value (or a clearly
placeholder version) so it matches the description of testing via
REPOMIX_VERSION and can be located in REPOMIX_VERSION and
scripts/context/repomix.sh references.

Source: Path instructions

name: Generate context packs
runs-on: ubuntu-latest
# Do not run PR-controlled package scripts for forked pull requests.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Same-Repo PR Execution
This guard skips forked PRs, but same-repository PR branches still run the job with PR-controlled code. A branch can change package.json lifecycle hooks, scripts/context/repomix.sh, or the Repomix config; the workflow then runs npm ci, runs the ctx:* scripts, and uploads .repomix/. That can produce a poisoned or over-broad context artifact before the changed scripts/config are merged. Use base-branch tooling for PR events, require manual dispatch, or disable PR-controlled lifecycle/script execution before generating artifacts.

Context Used: .greptile/config.json (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/repomix-context.yml
Line: 30

Comment:
**Same-Repo PR Execution**
This guard skips forked PRs, but same-repository PR branches still run the job with PR-controlled code. A branch can change `package.json` lifecycle hooks, `scripts/context/repomix.sh`, or the Repomix config; the workflow then runs `npm ci`, runs the `ctx:*` scripts, and uploads `.repomix/`. That can produce a poisoned or over-broad context artifact before the changed scripts/config are merged. Use base-branch tooling for PR events, require manual dispatch, or disable PR-controlled lifecycle/script execution before generating artifacts.

**Context Used:** .greptile/config.json ([source](https://app.greptile.com/helm/-/custom-context?memory=04251bf8-c7c3-42b7-859d-0ed056d5ef5e))

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code

Comment thread scripts/git/audit.sh
Comment on lines +16 to +18
else
baseline_ref="HEAD"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Reject Missing Baseline
When neither the local nor remote default branch exists, this falls back to HEAD and still prints merged/non-merged cleanup guidance. In a detached or shallow checkout, git branch --merged HEAD answers a different question than “merged into the default branch”, so the audit can list branches as cleanup candidates even though they were never merged into the intended baseline. This path should stop and ask for an explicit baseline instead of producing deletion guidance from HEAD.

Suggested change
else
baseline_ref="HEAD"
fi
else
echo "Unable to resolve a default branch ref. Pass the baseline branch explicitly, for example: npm run git:audit -- main." >&2
exit 1
fi
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/git/audit.sh
Line: 16-18

Comment:
**Reject Missing Baseline**
When neither the local nor remote default branch exists, this falls back to `HEAD` and still prints merged/non-merged cleanup guidance. In a detached or shallow checkout, `git branch --merged HEAD` answers a different question than “merged into the default branch”, so the audit can list branches as cleanup candidates even though they were never merged into the intended baseline. This path should stop and ask for an explicit baseline instead of producing deletion guidance from `HEAD`.

```suggestion
else
  echo "Unable to resolve a default branch ref. Pass the baseline branch explicitly, for example: npm run git:audit -- main." >&2
  exit 1
fi
```

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/git/audit.sh (1)

63-85: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

status=$? correctly captures the fsck exit code — verified, no bug.

Since git fsck --full is the condition of the if, set -e doesn't apply to it, and $? at the top of the else block is preserved from that condition per bash semantics. Confirmed correct.

One minor robustness note: mktemp/rm -f (lines 65, 84) has no trap for cleanup on interrupt (e.g. Ctrl-C mid-fsck) — the temp file would leak on SIGINT. Low stakes for a local dev-only audit script, optional to harden with trap 'rm -f "$tmp"' EXIT.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/git/audit.sh` around lines 63 - 85, The fsck summary flow in audit.sh
leaves the mktemp file behind if the script is interrupted before rm -f runs.
Update the temporary-file cleanup around the git fsck --full block by adding an
EXIT trap (and restoring any prior trap if needed) so the file created for awk
parsing is always removed, even on SIGINT or early exit; use the tmp variable
and the existing fsck summary block as the place to wire this in.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/git/audit.sh`:
- Line 33: The merged-branch filter in the audit script is using `grep -v
"^$default_branch$"` with a regex pattern, so branch names containing
metacharacters can be matched incorrectly. Update the `git branch --merged`
pipeline in `audit.sh` to do a literal exact-name exclusion for `default_branch`
(for example by using a fixed-string exact match option) so `Merged Non-Baseline
Branches` only excludes the intended branch name.

---

Outside diff comments:
In `@scripts/git/audit.sh`:
- Around line 63-85: The fsck summary flow in audit.sh leaves the mktemp file
behind if the script is interrupted before rm -f runs. Update the temporary-file
cleanup around the git fsck --full block by adding an EXIT trap (and restoring
any prior trap if needed) so the file created for awk parsing is always removed,
even on SIGINT or early exit; use the tmp variable and the existing fsck summary
block as the place to wire this in.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ecf83708-8632-472b-8075-4e4916143954

📥 Commits

Reviewing files that changed from the base of the PR and between 6d70c57 and 130bd23.

📒 Files selected for processing (8)
  • .github/workflows/repomix-context.yml
  • .gitignore
  • docs/audits/REPO_FRESHNESS_BASELINE_2026-07-03.md
  • docs/operations/REPOMIX_CONTEXT_PACKS.md
  • package.json
  • repomix.config.json
  • scripts/git/audit.sh
  • scripts/git/stash-audit.sh
💤 Files with no reviewable changes (1)
  • repomix.config.json

Comment thread scripts/git/audit.sh

echo
echo "## Merged Non-Baseline Branches"
git branch --merged "$baseline_ref" | sed 's/^[* ]*//' | grep -v "^$default_branch$" || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Unescaped regex in grep -v can under-filter branch names.

grep -v "^$default_branch$" treats $default_branch as a BRE pattern, not a literal string. Any branch name containing regex metacharacters (., +, *, [, etc. — common in names like release.1.2) will have those chars match unintended characters, causing the filter to incorrectly include/exclude branches from the "Merged Non-Baseline Branches" report.

🛠️ Proposed fix — literal fixed-string match
-git branch --merged "$baseline_ref" | sed 's/^[* ]*//' | grep -v "^$default_branch$" || true
+git branch --merged "$baseline_ref" | sed 's/^[* ]*//' | grep -vFx "$default_branch" || true

As per path instructions: "Bash scripts: ... quote all expansions" — the variable is quoted as a string, but the regex-interpolation gap defeats the intent of an exact literal match here.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
git branch --merged "$baseline_ref" | sed 's/^[* ]*//' | grep -v "^$default_branch$" || true
git branch --merged "$baseline_ref" | sed 's/^[* ]*//' | grep -vFx "$default_branch" || true
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/git/audit.sh` at line 33, The merged-branch filter in the audit
script is using `grep -v "^$default_branch$"` with a regex pattern, so branch
names containing metacharacters can be matched incorrectly. Update the `git
branch --merged` pipeline in `audit.sh` to do a literal exact-name exclusion for
`default_branch` (for example by using a fixed-string exact match option) so
`Merged Non-Baseline Branches` only excludes the intended branch name.

Source: Path instructions

njrini99-code added a commit that referenced this pull request Jul 3, 2026
npm run knip:deps (tuned in #773) reports 3 unlisted-dependency
findings — all genuinely imported, just missing from package.json
because they were only ever resolved transitively:

- @radix-ui/react-compose-refs — imported directly by Fairway's tabs
  component (src/components/fairway/controls/tabs.tsx).
- fflate — imported directly by the Baseball XLSX/PDF stat-import
  adapters (src/lib/baseball/adapters/{xlsx,pdf}-reader.ts).
- postcss-load-config — referenced as a JSDoc type import in
  postcss.config.mjs (devDependency: build-time only, not runtime).

Verified via grep before adding (all three have real, non-test
production usages except the type-only postcss-load-config import).
Versions pinned to what npm already resolves transitively today, so
this is a manifest correction, not a version bump.

Co-authored-by: Fable Integrator <fable@helm.local>
Co-authored-by: Cursor <cursoragent@cursor.com>
@njrini99-code

Copy link
Copy Markdown
Owner Author

Closing as superseded by the split stabilization PRs that are now on main: generated-file policy (#778), dependency declarations (#779), dead-file cleanup (#780), git hygiene (#781), issue ledger (#782), plus the follow-up dependency/action PRs. This omnibus branch still carries unresolved review concerns around PR-controlled Repomix execution, generated-file drift bundling, and git-audit robustness, so merging it now would reduce reviewability rather than improve production readiness.

@njrini99-code
njrini99-code deleted the codex/cleanup-repomix-knip-supabase-audit branch July 20, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI, Vercel, test, build, deploy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant