anthropics / anthropics/claude-code-action

Add capability to keep generated files out of the context window

Offen
#431 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement p3
Vorherrschende Sprache
TypeScript
Sterne
8.9k
Forks
2.1k
Ø Merge
3 T. 9 Std.
Gemergte PRs (30 T.)
10

Beschreibung

# Problem

The AI currently receives all changed files in its context, including generated files marked with linguist-generated=true in .gitattributes. This leads to:

- Unnecessary token consumption from generated files (e.g., **/go/**/*.generated.go)
- Reduced context space for human-authored code
- AI potentially analyzing/reviewing generated code that shouldn't be modified

# Current Behavior

The formatChangedFilesWithSHA function in src/github/data/formatter.ts processes all files without filtering:

```
export function formatChangedFilesWithSHA(
changedFiles: GitHubFileWithSHA[],
): string {
return changedFiles
.map(
(file) =>
`- ${file.path} (${file.changeType}) +${file.additions}/-${file.deletions} SHA: ${file.sha}`,
)
.join("\n");
}
```

# Proposed Solution

Add filtering to exclude files marked as generated in .gitattributes before formatting. This could be implemented by:

1. Option A: Parse .gitattributes and filter files with linguist-generated=true
2. Option B: Use GitHub's Linguist API data if available
3. Option C: Add a configuration option to specify file patterns to exclude

Example .gitattributes patterns that should be filtered:

```
*.generated.go linguist-generated=true
**/dist/** linguist-generated=true
**/build/** linguist-generated=true
*.min.js linguist-generated=true
```

Expected Outcome

- Reduced token usage in AI prompts
- AI focuses on human-authored code for reviews and analysis
- More efficient use of context window
- Optional: Configuration to override this behavior when generated file analysis is needed

Implementation Areas

- src/github/data/formatter.ts - Add filtering logic
- src/github/data/fetcher.ts - Filter earlier in the pipeline
- Consider adding user configuration option for this feature

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.