Skip to content

doc-generator includes gitignored build/cache dirs in CLAUDE.md / AGENTS.md / GEMINI.md tree #1

Description

@drknowhow

Bug

When running c3 init . --force (or any flow that regenerates project-instruction docs), the auto-generated project tree in CLAUDE.md, AGENTS.md, and GEMINI.md includes directories that are listed in .gitignore and shouldn't be part of the distributed project structure.

Reproduction

  1. Have any of these dirs present locally:
    • .pytest_cache/
    • .ruff_cache/
    • .vscode/
    • *.egg-info/ (e.g. from pip install -e .)
  2. Run python cli/c3.py init . --force --ide claude --mcp-mode direct.
  3. Inspect the regenerated CLAUDE.md (or AGENTS.md / GEMINI.md).

Expected

The project-tree section should show only files/dirs that would be part of a clean distribution — i.e., respect .gitignore.

Actual

Stale cache/build artifacts appear in the tree:

  .pytest_cache/
    .gitignore
    CACHEDIR.TAG
    README.md
    v/
  .ruff_cache/
    .gitignore
    CACHEDIR.TAG
    0.15.12/
  .vscode/
    mcp.json
    settings.json
  ...
  code_context_control.egg-info/
    SOURCES.txt
    dependency_links.txt
    entry_points.txt
    ...

These then ship to end users via the project-instruction docs, polluting their initial impression of the project structure.

Additional symptom

The doc generator also appears to cache the directory listing somewhere (likely via services/file_memory.py or services/claude_md.py). Even after deleting .ruff_cache/ and code_context_control.egg-info/ from disk and re-running c3 init --force, the stale entries persist in the regenerated docs. So the fix needs to address both:

  1. The walker that builds the tree should respect .gitignore patterns.
  2. The file-memory cache should invalidate (or at least re-scan) when directories listed in it no longer exist on disk.

Likely fix location

  • services/claude_md.py — the doc generator (probably builds the tree section)
  • services/file_memory.py — the cache that holds the directory listings

A minimal patch would teach the tree-walker to read .gitignore and skip matched paths. The standard library pathspec package handles this exactly, or a small hand-rolled implementation since we already only need the simple pattern subset (.dir/, *.ext).

Workaround

Edit the generated docs by hand to strip the offending lines (what was done for v2.28.0 — see the post-release commit at 73b3708).

Severity

Low — cosmetic only, but visible to every user who runs c3 init.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions