# Where Is the OpenClaude Repo Map Cache Stored?

> Discover where the OpenClaude repo map cache is stored. Find the exact path in the Gitlawb/openclaude repository to manage your cache effectively.

- Repository: [Gitlawb/openclaude](https://github.com/Gitlawb/openclaude)
- Tags: internals
- Published: 2026-09-06

---

**The OpenClaude repo map cache is stored in `${OPENCLAUDE_CONFIG_DIR}/cache/repo-map` when the environment variable is set, or `${HOME}/.openclaude/cache/repo-map` by default, as determined by the `getCacheDir()` function in [`src/context/repoMap/cache.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/context/repoMap/cache.ts).**

Understanding where the OpenClaude repo map cache is stored helps you manage disk space, debug persistence issues, or share cache across environments. In the **Gitlawb/openclaude** repository, the cache location follows a deterministic path resolution strategy based on your configuration directory. This guide breaks down the exact file paths and logic governing where repository maps persist on disk.

## Default Cache Location and Environment Override

The system resolves the cache directory by checking for the `OPENCLAUDE_CONFIG_DIR` environment variable at runtime.

- **If set**: Cache resides at `${OPENCLAUDE_CONFIG_DIR}/cache/repo-map`
- **If unset**: Cache defaults to `${HOME}/.openclaude/cache/repo-map`

This logic is implemented in [`src/context/repoMap/cache.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/context/repoMap/cache.ts). The `getCacheDir()` function constructs the final absolute path by appending `cache/repo-map` to the base configuration directory returned by `getConfigDir()`.

## How the Cache Path Is Constructed

### Resolving the Configuration Directory

The underlying `getConfigDir()` utility, defined in [`src/utils/openclaudePaths.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/utils/openclaudePaths.ts), handles environment variable detection. When `OPENCLAUDE_CONFIG_DIR` is undefined, the function falls back to the standard home directory location `~/.openclaude`.

### Building the Cache Directory

In [`src/context/repoMap/cache.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/context/repoMap/cache.ts), the `getCacheDir()` function assembles the complete path:

```ts
import { getConfigDir } from '../../utils/openclaudePaths';
import path from 'path';

export function getCacheDir(): string {
  const configDir = getConfigDir();
  return path.join(configDir, 'cache', 'repo-map');
}

```

## Accessing and Customizing the Cache Location

You can retrieve the cache location programmatically or override it via environment variables before launching the CLI.

**Programmatic retrieval:**

```ts
import { getCacheDir } from './src/context/repoMap/cache';

const cacheDir = getCacheDir();
console.log(`Repo-map cache stored at: ${cacheDir}`);

```

**Command-line override:**

```bash
export OPENCLAUDE_CONFIG_DIR=/mnt/fast-storage/openclaude
openclaude repomap

# Cache will be written to /mnt/fast-storage/openclaude/cache/repo-map

```

## Source Code Verification

The repository contains verification logic in [`src/context/repoMap/repoMap.test.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/context/repoMap/repoMap.test.ts), where the test suite confirms that the cache directory matches the path supplied via process arguments or environment configuration.

Additionally, the `repomap` command implementation in [`src/commands/repomap/repomap.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/commands/repomap/repomap.ts) exposes the current cache location to users through the following output:

```ts
console.log(`  Cache directory: ${cacheStats.cacheDir}`);

```

## Summary

- The **OpenClaude repo map cache** location depends on the `OPENCLAUDE_CONFIG_DIR` environment variable.
- Default storage path is `${HOME}/.openclaude/cache/repo-map` when the variable is unset.
- The `getCacheDir()` function in [`src/context/repoMap/cache.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/context/repoMap/cache.ts) assembles the final path by joining the config directory with `cache/repo-map`.
- You can relocate the cache by setting `OPENCLAUDE_CONFIG_DIR` before running the CLI.
- Unit tests in [`src/context/repoMap/repoMap.test.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/context/repoMap/repoMap.test.ts) validate the path resolution logic against expected values.

## Frequently Asked Questions

### What environment variable controls the OpenClaude repo map cache location?

Set `OPENCLAUDE_CONFIG_DIR` to any absolute path. The cache automatically resolves to `${OPENCLAUDE_CONFIG_DIR}/cache/repo-map`. If the variable is undefined, the system defaults to `~/.openclaude/cache/repo-map` according to the logic in [`src/utils/openclaudePaths.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/utils/openclaudePaths.ts).

### How can I programmatically retrieve the cache directory path?

Import `getCacheDir` from [`src/context/repoMap/cache.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/context/repoMap/cache.ts) and call the function. It returns a string containing the absolute path to the repo-map cache directory based on your current environment configuration.

### Where does OpenClaude store the cache if I don't set any environment variables?

Without configuration, OpenClaude stores the cache in your home directory at `~/.openclaude/cache/repo-map`. The `getConfigDir()` function in [`src/utils/openclaudePaths.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/utils/openclaudePaths.ts) provides this fallback when `OPENCLAUDE_CONFIG_DIR` is not present.

### Which source file defines the cache directory construction logic?

The `getCacheDir()` function defined in [`src/context/repoMap/cache.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/context/repoMap/cache.ts) constructs the cache path. It relies on `getConfigDir()` from [`src/utils/openclaudePaths.ts`](https://github.com/Gitlawb/openclaude/blob/main/src/utils/openclaudePaths.ts) to determine the base configuration directory before appending the `cache/repo-map` segment.