> ## Documentation Index
> Fetch the complete documentation index at: https://code.storage/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# repo.listFiles()

> List all files in the repository at a specific ref.

> [!WARNING]
>
> This page documents the earlier Code Storage SDKs: `@pierre/storage`, `pierre-storage`, and
> `code-storage-go`. New code uses the [Pierre SDK](https://code.storage/docs/sdks.md). To move code to the new SDK, use the
> [`pierre-migrate`
> skill](https://github.com/pierrecomputer/skills/tree/main/skills/pierre-migrate).

```typescript TypeScript theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
// List files from default branch
const files = await repo.listFiles();
console.log(files.paths); // Array of file paths

// List files from specific branch or commit
const branchFiles = await repo.listFiles({
  ref: 'feature-branch', // branch name or commit SHA
});
console.log(`Files in ${branchFiles.ref}:`, branchFiles.paths);

// List files from the ephemeral namespace
const ephemeralFiles = await repo.listFiles({
  ref: 'feature/demo-work',
  ephemeral: true,
});
console.log(`Ephemeral files:`, ephemeralFiles.paths);

const page = await repo.listFiles({
  path: 'docs',
  recursive: false,
  limit: 100,
});
console.log(page.entries, page.nextCursor);
```

```python Python theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
# List files from the default branch
files = await repo.list_files(ref="main")
print(files["paths"])  # List of file paths

# List files from a specific branch or commit
branch_files = await repo.list_files(ref="feature-branch")
print(branch_files["paths"])

# List files from the ephemeral namespace
ephemeral_files = await repo.list_files(
    ref="feature/demo-work",
    ephemeral=True,
)
print(ephemeral_files["paths"])

page = await repo.list_files(
    path="docs",
    recursive=False,
    limit=100,
)
print(page["entries"], page.get("next_cursor"))
```

```go Go theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
// List files from the default branch
files, err := repo.ListFiles(context.Background(), storage.ListFilesOptions{
	Ref: "main",
})
fmt.Println(files.Paths)

ephemeral := true
// List files from the ephemeral namespace
ephemeralFiles, err := repo.ListFiles(context.Background(), storage.ListFilesOptions{
	Ref:       "feature/demo-work",
	Ephemeral: &ephemeral,
})
fmt.Println(ephemeralFiles.Paths)

recursive := false
page, err := repo.ListFiles(context.Background(), storage.ListFilesOptions{
	Path:      "docs",
	Recursive: &recursive,
	Limit:     100,
})
fmt.Println(page.Entries, page.NextCursor)
```

## Options

**ref** `string`

Branch name or commit SHA. Defaults to the default branch.

**ephemeral** `boolean`

When `true`, resolves the ref under the ephemeral namespace.

**path** `string`

Repository-relative file or subtree to list. An exact file path returns that file as a single
`blob` entry.

**recursive** `boolean`

For subtree paths, when `false`, returns direct children of `path`.

**cursor** `string`

Pagination cursor from a previous response.

**limit** `number`

Maximum entries to return.

## Response

**paths** `array`

List of file paths in the repository

**ref** `string`

The resolved ref that was listed

**entries** `array`

Structured tree entries returned with the listing.

**entry fields**

**entries\[].path** `string`

Entry path relative to the repository root.

**entries\[].type** `string`

Entry type: `blob`, `tree`, `symlink`, or `submodule`.

**entries\[].mode** `string`

Git file mode.

**nextCursor** `string`

Cursor for the next page. Python: `next_cursor`; Go: `NextCursor`.

**hasMore** `boolean`

Whether additional pages are available. Python: `has_more`; Go: `HasMore`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.