Skip to content

stark-ai-de/agent-skills / skills/claude-operations/claude-memory-curator

claude-memory-curator

Verified

Audit and safely curate Claude Code instructions, rules, auto memory, and memory settings. Use when reviewing stale or misplaced Claude Code context, not Claude app memory or API memory stores.

scripts/memory-source-discovery.mjs

View on GitHub
import fs from "node:fs";
import path from "node:path";

const ignoredDirectories = new Set([
  ".git",
  ".hg",
  ".svn",
  ".next",
  ".turbo",
  "dist",
  "build",
  "coverage",
  "node_modules",
]);

export function isDirectory(value) {
  try {
    return fs.statSync(value).isDirectory();
  } catch {
    return false;
  }
}

export function isFile(value) {
  try {
    return fs.statSync(value).isFile();
  } catch {
    return false;
  }
}

export function walk(dir, predicate = () => true) {
  const files = [];

  function visit(current) {
    let entries;
    try {
      entries = fs.readdirSync(current, { withFileTypes: true });
    } catch {
      return;
    }

    for (const entry of entries) {
      const fullPath = path.join(current, entry.name);
      if (entry.isDirectory()) {
        if (!ignoredDirectories.has(entry.name)) visit(fullPath);
      } else if (entry.isFile() && predicate(fullPath)) {
        files.push(fullPath);
      }
    }
  }

  if (isDirectory(dir)) visit(dir);
  return files.sort();
}

export function collectAncestorAgentFiles(repo) {
  const files = [];
  let directory = path.dirname(path.resolve(repo));

  while (true) {
    const candidate = path.join(directory, "AGENTS.md");
    if (isFile(candidate)) files.push(candidate);

    const parent = path.dirname(directory);
    if (parent === directory) break;
    directory = parent;
  }

  return files;
}

export function collectProjectFiles(repo) {
  return [
    ...collectAncestorAgentFiles(repo),
    path.join(repo, "CLAUDE.md"),
    path.join(repo, ".claude", "CLAUDE.md"),
    path.join(repo, "CLAUDE.local.md"),
    path.join(repo, ".claude", "settings.json"),
    path.join(repo, ".claude", "settings.local.json"),
    ...walk(repo, (file) => {
      const name = path.basename(file);
      const relative = path.relative(repo, file).split(path.sep);
      const isProjectRule = relative.some(
        (part, index) => part === ".claude" && relative[index + 1] === "rules",
      );
      return (
        (isProjectRule && file.endsWith(".md")) ||
        name === "CLAUDE.md" ||
        name === "CLAUDE.local.md" ||
        (name === "AGENTS.md" && !path.relative(repo, file).split(path.sep).includes(".agents"))
      );
    }),
  ];
}
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall