Skip to content
Source
Sign inSign up

Nest and group files

Code and repositories / Read code

Nest and group files in the file list

The root of your repository has many config files, so the file list is long. A .source/settings.json file folds related files under one file and some folders into one row, so the file list stays short.

3 min read

Important

Each person sees nesting and groups only after they turn on Nest and group files in Settings, Profile. The settings file does not change the list for people who keep it off.

1. Create the settings file

Create .source/settings.json at the root of the repository. All keys are optional.

{
  "explorer.fileNesting.enabled": true,
  "explorer.fileNesting.patterns": {
    "package.json": "pnpm-lock.yaml, .npmrc",
    "*.ts": "$(capture).test.ts"
  },
  "explorer.folderGroups": {
    "agent-configs": [".claude", ".cursor", "AGENTS.md", "CLAUDE.md"]
  }
}

The file list ignores the keys that it does not know. So you can copy your .vscode/settings.json into this file.

2. Nest files under a parent file

Set "explorer.fileNesting.patterns". It uses the same format as VS Code.

  • The key is the name of the parent file. It can have one *.
  • The value is a list of names, with commas between them. A name can use * and $(capture).
  • $(capture) is the text that * matched in the key.
KeyValueResult
package.jsonpnpm-lock.yaml, .npmrcpnpm-lock.yaml and .npmrc fold under package.json
*.ts$(capture).test.tsapp.test.ts folds under app.ts

These rules apply to the patterns:

  • Uppercase and lowercase are the same in names. For example, readme* matches README.md and readme.md.
  • Your list replaces the default list. It does not add to it.
  • Nesting has one level. A file that nests under a nested file shows under the top parent file.
  • Folders never nest.

The default list is the file nesting patterns from the VS Code settings of Anthony Fu (antfu/vscode-settings, MIT license).

3. Group files and folders

Set "explorer.folderGroups". The key is the name of the group. The value is a list of exact file or folder names.

{
  "explorer.folderGroups": {
    "agent-configs": [".agent", ".agents", ".claude", ".codex", ".cursor", ".gemini", ".grok", ".intent", ".kiro", ".windsurf", "AGENTS.md", "CLAUDE.md", "GEMINI.md"],
    "ci": [".github", ".circleci"]
  }
}

When 2 or more names of a group are in a folder, they fold into one group row.

Your groups replace the default group agent-configs. To keep it, add it to your list, as in the example above.

The file list with a config group open, which holds .gitignore, tsconfig.json, tsconfig.node.json and vite.config.ts, next to the agent-configs group

4. Push the change

Commit .source/settings.json and push it. The file list reads the settings from the commit that you view. So the change shows after you push the commit.

Each branch uses its own .source/settings.json.

Done

Related files fold under one parent file, and each group takes one row. The file list of your repository is short.

Turn nesting off for the repository

Set "explorer.fileNesting.enabled" to false. Then files do not nest in this repository, also for people who turned nesting on. Groups still fold. The default is true.

{
  "explorer.fileNesting.enabled": false
}

If the file has an error

If .source/settings.json has an error, the file list uses the defaults. A warning line above the list gives the reason. An error occurs when:

  • The file is not valid JSON.
  • A key has a wrong type.
  • The file is larger than 64 KiB.
A warning line above the file list: .source/settings.json is not valid: explorer.fileNesting.enabled: Invalid input: expected boolean, received string