Skip to content

docs(governance): thin-proxy CLAUDE.md refactor#76

Open
CodeMonkeyCybersecurity wants to merge 4 commits intomainfrom
docs/75-claude-md-thin-proxy-refactor
Open

docs(governance): thin-proxy CLAUDE.md refactor#76
CodeMonkeyCybersecurity wants to merge 4 commits intomainfrom
docs/75-claude-md-thin-proxy-refactor

Conversation

@CodeMonkeyCybersecurity
Copy link
Owner

Summary

  • Replaces the 1833-line CLAUDE.md monolith with a 75-line thin proxy (check-claude-md-size.sh confirms: within budget)
  • Adds prompts/ git submodule so governance contracts are available via @prompts/ @imports
  • Extracts domain-specific patterns into 4 path-scoped .claude/rules/ files that load only when touching relevant code
Rule file Loads on Content
go-patterns.md **/*.go Architecture, constants, logging, idempotency, retry
cli-patterns.md cmd/**/*.go cmd/pkg separation, flag validation, human-centric input
secrets-vault.md pkg/vault/**, pkg/consul/** Vault/Consul, token auth hierarchy
debugging.md cmd/debug/** Diagnostic logging, evidence collection

Test plan

Refs: #75, cybermonkey/prompts#564

🤖 Generated with Claude Code

Replace 1833-line CLAUDE.md monolith with 75-line thin proxy that
@imports governance contracts from cybermonkey/prompts submodule.

Changes:
- Add prompts/ git submodule (ssh://git@vhost7:9001/cybermonkey/prompts.git)
- CLAUDE.md: 1833 lines → 75 lines (within 200-line budget)
- .claude/rules/go-patterns.md: architecture, constants, logging, idempotency
- .claude/rules/cli-patterns.md: cmd/pkg separation, flag validation, human-centric input
- .claude/rules/secrets-vault.md: Vault/Consul patterns, token auth hierarchy
- .claude/rules/debugging.md: diagnostic logging, evidence collection

Path-scoped rules load only when touching relevant files, preventing
context saturation that caused agents to ignore most of the old CLAUDE.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Mar 14, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2dce1688c0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +91 to +92
if err != nil {
continue

Choose a reason for hiding this comment

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

P2 Badge Report hashing failures instead of silently skipping files

If fileSHA256 fails (for example due to permission errors, deleted files during scan, or transient I/O issues), the loop just continues and still prints a successful archive summary. That produces an incomplete manifest/archive without any warning, which is a data-loss scenario for a backup command because users cannot tell which transcripts were dropped.

Useful? React with 👍 / 👎.

Comment on lines +184 to +188
b, err := os.ReadFile(path)
if err != nil {
return false
}
h := strings.ToLower(string(b))

Choose a reason for hiding this comment

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

P2 Badge Avoid loading entire JSON files during candidate detection

Candidate discovery reads each matching .json file fully into memory and then allocates another full-size lowercase copy before checking a few substrings. With the default recursive ~/Dev source, encountering large JSON artifacts can cause major memory spikes or OOM, making the archive command fail before copying anything.

Useful? React with 👍 / 👎.

dest = expandHome(dest)

if !dryRun {
if err := os.MkdirAll(dest, 0o755); err != nil {

Check failure

Code scanning / gosec

Expect directory permissions to be 0750 or less Error

Expect directory permissions to be 0750 or less
if err != nil {
return fmt.Errorf("marshal manifest: %w", err)
}
if err := os.WriteFile(manifestPath, b, 0o644); err != nil {

Check failure

Code scanning / gosec

Expect WriteFile permissions to be 0600 or less Error

Expect WriteFile permissions to be 0600 or less
if !hasPathClue && !strings.Contains(base, "chat") && !strings.Contains(base, "conversation") && !strings.Contains(base, "session") && !strings.Contains(base, "transcript") {
return false
}
b, err := os.ReadFile(path)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
}

func fileSHA256(path string) (string, int64, error) {
f, err := os.Open(path)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
}

func copyArchiveFile(src, dst string) error {
in, err := os.Open(src)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
}
defer in.Close()

out, err := os.Create(dst)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant