MAESTRO: Prevent CLAUDE.md generation in unsafe directories (PR #929 concept)

Add exclusion list for directories where CLAUDE.md generation breaks
toolchains: res/ (Android aapt2), .git/, build/, node_modules/,
__pycache__/. Closes issue #912. Credit to @jayvenn21.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-02-06 01:35:31 -05:00
parent e424d85a93
commit ab3d4ca865
4 changed files with 181 additions and 47 deletions
+26
View File
@@ -257,6 +257,27 @@ export function formatTimelineForClaudeMd(timelineText: string): string {
return lines.join('\n').trim();
}
/**
* Built-in directory names where CLAUDE.md generation is unsafe or undesirable.
* e.g. Android res/ is compiler-strict (non-XML breaks build); .git, build, node_modules are tooling-owned.
*/
const EXCLUDED_UNSAFE_DIRECTORIES = new Set([
'res',
'.git',
'build',
'node_modules',
'__pycache__'
]);
/**
* Returns true if folder path contains any excluded segment (e.g. .../res/..., .../node_modules/...).
*/
function isExcludedUnsafeDirectory(folderPath: string): boolean {
const normalized = path.normalize(folderPath);
const segments = normalized.split(path.sep);
return segments.some(segment => EXCLUDED_UNSAFE_DIRECTORIES.has(segment));
}
/**
* Check if a folder is a project root (contains .git directory).
* Project root CLAUDE.md files should remain user-managed, not auto-updated.
@@ -331,6 +352,11 @@ export async function updateFolderClaudeMdFiles(
logger.debug('FOLDER_INDEX', 'Skipping project root CLAUDE.md', { folderPath });
continue;
}
// Skip known-unsafe directories (e.g. Android res/, .git, build, node_modules)
if (isExcludedUnsafeDirectory(folderPath)) {
logger.debug('FOLDER_INDEX', 'Skipping unsafe directory for CLAUDE.md', { folderPath });
continue;
}
// Skip folders where CLAUDE.md was read/modified in this observation (issue #859)
if (foldersWithActiveClaudeMd.has(folderPath)) {
logger.debug('FOLDER_INDEX', 'Skipping folder with active CLAUDE.md to avoid race condition', { folderPath });