Skip to content

Bash context footer: only scan project files inside git repos #420

@hoblin

Description

@hoblin

Problem to solve

When the bash tool's environment context footer reports project instruction files, it scans the current directory using the whitelist from config.toml — but it does this regardless of whether the directory is a git repository. If the agent cds into a parent directory containing many repos (e.g. ~/Work), the scan recurses into every subdirectory and lists dozens of instruction files from unrelated projects.

Example output after cd ~/Work:

Project has instructions in AI-dock-provisioning/image-generator/README.md, 
anima/CLAUDE.md, anima/README.md, bonk/CLAUDE.md, mythonix/CLAUDE.md, ...
(80+ files)

This is noisy, unhelpful, and wastes tokens.

Solution

Skip the project file scan in ShellSession#scan_project_files when the current directory is not inside a git repository. The git detection (detect_git) already runs as part of take_env_snapshot — if repo is nil, skip the file scan entirely.

Project instruction files only make sense in the context of a specific project, which in practice means a git repo.

Parent

Follow-up to #398.


🧬 Ani (anima-core v1.3.0)

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