# Search

Find code, symbol definitions, issues and pull requests from the web app or the CLI, and know what each search covers.

## Find something

```sh
sailfork search code "fn merge_pull"
sailfork search symbols merge_pull
sailfork search issues login is:open label:bug -R fenil/ocean-landing
sailfork search prs is:merged author:@me -R fenil/ocean-landing
```

Code and symbol search work on the repository of your clone, or on the one `-R owner/repo` names. Issue and pull request search always need a repository.

## Search code

`sailfork search code <QUERY>` searches the text of files on a branch head.

```sh
sailfork search code "TODO" --path crates/cli --lang Rust --limit 50
sailfork search code "impl\s+Drop" --regex --ref feat/tide
sailfork search code "oauth" --all-repos --json --jq '.files[].path'
```

| Flag | What it does |
| --- | --- |
| `--path <TEXT>` | Only files whose path contains this. |
| `--lang <LANGUAGE>` | Only this language, as the results name it. Not case-sensitive. |
| `--ref <BRANCH>` | Search this branch's head instead of the default branch. A branch the repository lacks matches nothing. |
| `--regex` | Treat the query as a regular expression. |
| `--case` | Match case. Without it, case is ignored. |
| `--limit <N>` | Most files to print, 1 to 100. Default 20. |
| `--all-repos` | Search every repository you can read, not only one. |

Query rules:

- A query is 1 to 256 characters on one line.
- Text is matched literally. A space is part of the text, not an "and".
- `--regex` uses Rust regular expression syntax. It runs in linear time and has no backreferences. A pattern that matches the empty string is refused.
- Results rank files whose path matches first, then files with an exact-case match.

### What is searched

- Only the head of a branch: the default branch, or the one `--ref` names. Every branch of a repository is indexed, up to 256 by default (the default branch first, then by name), and a deleted branch drops out.
- Only text files. Binaries, files over 1 MiB, vendored and build directories (`node_modules`, `vendor`, `dist`, `build`, `target` and similar), lockfiles, `*.min.*` and `*.d.ts` are left out.
- A push is searchable within about 2 seconds.
- A private repository shows up only for people who can read it.
- A query that runs past 2 seconds fails with 503. Narrow it with `--path`, `--lang` or a repository, or lengthen the text.

If more files match than `--limit`, the CLI says so on stderr.

## Search symbols

Find where functions, types and other names are defined, by name.

```sh
sailfork search symbols Config --kind struct --path crates/server
sailfork search symbols handler --ref v1.2.0 --json --jq '.symbols[] | "\(.path):\(.line)"'
```

The query is part of a name, not case-sensitive. Exact-case matches come first, then any-case, then prefixes, then shorter names.

| Flag | What it does |
| --- | --- |
| `--kind <KIND>` | `function`, `method`, `struct`, `enum`, `union`, `trait`, `interface`, `class`, `type`, `module`, `macro`, `const` or `static`. |
| `--path <TEXT>` | Only files whose path contains this. |
| `--ref <REF>` | A branch, tag or commit. Default: the default branch. |
| `--limit <N>` | Most definitions to print, 1 to 200. Default 30. |

Rust, TypeScript, JavaScript, Python and Go (and the script of Svelte and Vue files) are parsed with tree-sitter. Other languages use line patterns, so results are looser. Symbols cover the files code search indexes, minus files over 512 KiB, and follow a push within a few seconds. While a repository's index is catching up, the CLI says results may be missing or stale.

## Search issues and pull requests

```sh
sailfork search issues login is:open label:bug -R acme/site
sailfork search issues "author:@me status:in-progress" -R acme/site
sailfork search prs is:merged author:ana base:main -R acme/site
sailfork search prs redirect -R acme/site --limit 10
```

Plain words match the title and description. Qualifiers are `key:value` words, and each takes one value:

| Search | Qualifiers |
| --- | --- |
| `search issues` | `is:open`, `is:closed`, `author:`, `label:`, `assignee:`, `status:`, `priority:` |
| `search prs` | `is:open`, `is:draft`, `is:merged`, `is:closed`, `author:`, `head:`, `base:` |

`author:@me` means you. `status:` takes the issue statuses (`triage`, `ready`, `in-progress`, `in-review`, `done`, `canceled`, `duplicate`) and `priority:` takes `urgent`, `high`, `medium`, `low` or `none`. Without `is:`, both states are searched. `--limit` is the most rows to print, 30 by default.

An unknown qualifier fails with the ones that are known, for example `unknown qualifier color: for issues; known: is, author, label, assignee, status, priority`. There is no search across repositories for issues and pull requests. Pass `-R`.

For filtering without search words, `sailfork issue list` and `sailfork pr list` have flags of their own: see [Issues](https://sailfork.com/docs/issues#views-and-filters) and [Pull requests](https://sailfork.com/docs/pull-requests#commands). `sailfork pr list --file crates/server/src/ci/` finds the pull requests that change a path.

## Search in the web app

Press Command-K (Control-K on Windows and Linux) anywhere in the app to open the command menu. Type to jump to a page or repository. From two characters on, it also searches code: matching repositories, file paths and lines of code, up to eight results. Inside a repository it searches that repository only. The last row, **See all results for ...**, opens the full search page.

The search page at `/search` searches code in every repository you can read, or one you pick:

- **Repository** and **Language** filters list what the results contain.
- **Match case** makes the match case-sensitive.
- The count shows files found and the time taken. Results show 50 files at most, and a `+` after the count means more matched.
- `/search?q=tide&ref=feat/tide` searches a branch.

The page has no regular expression option. Use `sailfork search code --regex` for that.

Issues and pull requests have their own find boxes: **Find an issue** on the Issues page, and **Find a pull request** on the Pull requests page.

## From a script

`GET /api/search` takes `q`, `repo`, `path`, `lang`, `limit`, `regex`, `case` and `ref`. Bad input is 422 and a query that passes its 2 second budget is 503. Symbols have their own routes. See [the API reference](https://sailfork.com/docs/api). The `search_code` tool of the `repos` toolset in the [MCP server](https://sailfork.com/docs/mcp) searches code for an agent.

## Who can search

Code search shows public repositories to anyone and private ones only to people who can read them. Issue and pull request reads need no sign-in on a public repository. A token needs the `repo:read` scope.

---

Every docs page: https://sailfork.com/llms.txt
