Skip to content

docs: Add documentation for the src prompts command #1155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/cli/references/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Most commands require that the user first [authenticate](quickstart#connect-to-s
* [`login`](references/login)
* [`lsif`](references/lsif)
* [`orgs`](references/orgs)
* [`prompts`](references/prompts)
* [`repos`](references/repos)
* [`scout`](references/scout)
* [`search`](references/search)
Expand Down
37 changes: 37 additions & 0 deletions docs/cli/references/prompts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# src prompts

<p className="subtitle">`src prompts` is a tool that manages prompt library prompts and tags in a Sourcegraph instance.</p>

## Usage

```
'src prompts' is a tool that manages prompt library prompts and tags in a Sourcegraph instance.

Usage:

src prompts command [command options]

The commands are:

list lists prompts
get get a prompt by ID
create create a prompt
update update a prompt
delete delete a prompt
export export prompts to a JSON file
import import prompts from a JSON file
tags manage prompt tags (use "src prompts tags [command] -h" for more info)

Use "src prompts [command] -h" for more information about a command.
```

## Sub-commands

* [list](prompts/list)
* [get](prompts/get)
* [create](prompts/create)
* [update](prompts/update)
* [delete](prompts/delete)
* [export](prompts/export)
* [import](prompts/import)
* [tags](prompts/tags)
81 changes: 81 additions & 0 deletions docs/cli/references/prompts/create.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# src prompts create

Create a new prompt in your Sourcegraph instance.

## Usage

```bash
src prompts create [flags]
```

## Examples

```bash
# Create a basic prompt (uses current user as owner)
src prompts create \
-name="go-error-handling" \
-description="Best practices for Go error handling" \
-content="Write a Go function that properly handles errors..."

# Create a prompt with tags
src prompts create \
-name="python-optimization" \
-description="Python performance optimization tips" \
-content="Optimize this Python code for better performance..." \
-tags="UHJvbXB0VGFnOjE=,UHJvbXB0VGFnOjI="

# Create a draft prompt
src prompts create \
-name="draft-prompt" \
-description="Work in progress prompt" \
-content="This prompt is still being developed..." \
-draft

# Create a recommended prompt with auto-submit
src prompts create \
-name="recommended-prompt" \
-description="A recommended prompt for common use" \
-content="This is a recommended prompt..." \
-recommended \
-auto-submit

# Create a secret prompt for INSERT mode
src prompts create \
-name="secret-insert-prompt" \
-description="Secret prompt for code insertion" \
-content="Insert code here..." \
-visibility="SECRET" \
-mode="INSERT"

# Create a prompt with explicit owner (optional)
src prompts create \
-name="team-shared-prompt" \
-description="A prompt shared with a specific owner" \
-content="This prompt has an explicit owner..." \
-owner="VXNlcjox"
```

## Flags

| Flag | Description |
|------|-------------|
| `-name` | The prompt name (required) |
| `-description` | Description of the prompt (required) |
| `-content` | The prompt template text content (required) |
| `-owner` | The ID of the owner (user or organization) (optional, defaults to current user) |
| `-tags` | Comma-separated list of tag IDs |
| `-draft` | Whether the prompt is a draft (default: false) |
| `-visibility` | Visibility of the prompt: PUBLIC or SECRET (default: "PUBLIC") |
| `-auto-submit` | Whether the prompt should be automatically executed in one click (default: false) |
| `-mode` | Mode to execute prompt: CHAT, EDIT, or INSERT (default: "CHAT") |
| `-recommended` | Whether the prompt is recommended (default: false) |

### API flags

| Flag | Description |
|------|-------------|
| `-dump-requests` | Log GraphQL requests and responses to stdout |
| `-get-curl` | Print the curl command for executing this query and exit (WARNING: includes printing your access token!) |
| `-insecure-skip-verify` | Skip validation of TLS certificates against trusted chains |
| `-trace` | Log the trace ID for requests. See https://docs.sourcegraph.com/admin/observability/tracing |
| `-user-agent-telemetry` | Include the operating system and architecture in the User-Agent sent with requests to Sourcegraph (default: true) |
32 changes: 32 additions & 0 deletions docs/cli/references/prompts/delete.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# src prompts delete

Delete a prompt from your Sourcegraph instance.

## Usage

```bash
src prompts delete <prompt-id>
```

## Examples

```bash
# Delete a prompt by ID
src prompts delete UHJvbXB0OjE=

# The command will confirm successful deletion
src prompts delete UHJvbXB0OjE=
# Output: Prompt deleted successfully.
```

## Flags

### API flags

| Flag | Description |
|------|-------------|
| `-dump-requests` | Log GraphQL requests and responses to stdout |
| `-get-curl` | Print the curl command for executing this query and exit (WARNING: includes printing your access token!) |
| `-insecure-skip-verify` | Skip validation of TLS certificates against trusted chains |
| `-trace` | Log the trace ID for requests. See https://docs.sourcegraph.com/admin/observability/tracing |
| `-user-agent-telemetry` | Include the operating system and architecture in the User-Agent sent with requests to Sourcegraph (default: true) |
46 changes: 46 additions & 0 deletions docs/cli/references/prompts/export.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# src prompts export

Export prompts to a JSON file.

## Usage

```bash
src prompts export [flags]
```

## Examples

```bash
# Export all prompts to stdout
src prompts export

# Export all prompts to a file
src prompts export -o prompts-backup.json

# Export with pretty formatting
src prompts export -o prompts-backup.json -format=pretty

# Export prompts with specific tags
src prompts export -o go-prompts.json -tags="go,golang"

# Export prompts with multiple tag filters
src prompts export -o filtered-prompts.json -tags="python,data-science,ml"
```

## Flags

| Flag | Description |
|------|-------------|
| `-o` | Output file path (defaults to stdout if not specified) |
| `-tags` | Comma-separated list of tag names to filter by |
| `-format` | JSON format: 'pretty' or 'compact' (default: 'compact') |

### API flags

| Flag | Description |
|------|-------------|
| `-dump-requests` | Log GraphQL requests and responses to stdout |
| `-get-curl` | Print the curl command for executing this query and exit (WARNING: includes printing your access token!) |
| `-insecure-skip-verify` | Skip validation of TLS certificates against trusted chains |
| `-trace` | Log the trace ID for requests. See https://docs.sourcegraph.com/admin/observability/tracing |
| `-user-agent-telemetry` | Include the operating system and architecture in the User-Agent sent with requests to Sourcegraph (default: true) |
28 changes: 28 additions & 0 deletions docs/cli/references/prompts/get.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# src prompts get

Get details about a specific prompt by ID.

## Usage

```bash
src prompts get <prompt-id>
```

## Examples

```bash
# Get prompt by ID
src prompts get UHJvbXB0OjE=
```

## Flags

### API flags

| Flag | Description |
|------|-------------|
| `-dump-requests` | Log GraphQL requests and responses to stdout |
| `-get-curl` | Print the curl command for executing this query and exit (WARNING: includes printing your access token!) |
| `-insecure-skip-verify` | Skip validation of TLS certificates against trusted chains |
| `-trace` | Log the trace ID for requests. See https://docs.sourcegraph.com/admin/observability/tracing |
| `-user-agent-telemetry` | Include the operating system and architecture in the User-Agent sent with requests to Sourcegraph (default: true) |
47 changes: 47 additions & 0 deletions docs/cli/references/prompts/import.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# src prompts import

Import prompts from a JSON file.

## Usage

```bash
src prompts import [flags]
```

## Examples

```bash
# Import prompts from a file (uses current user as owner)
src prompts import -i prompts.json

# Import prompts with a specific owner
src prompts import -i prompts.json -owner="VXNlcjox"

# Perform a dry run without creating any prompts
src prompts import -i prompts.json -dry-run

# Skip existing prompts with the same name
src prompts import -i prompts.json -skip-existing

# Combine flags for validation and skipping
src prompts import -i prompts.json -dry-run -skip-existing
```

## Flags

| Flag | Description |
|------|-------------|
| `-i` | Input file path (required) |
| `-owner` | The ID of the owner for all imported prompts (defaults to current user) |
| `-dry-run` | Validate without importing |
| `-skip-existing` | Skip prompts that already exist (based on name) |

### API flags

| Flag | Description |
|------|-------------|
| `-dump-requests` | Log GraphQL requests and responses to stdout |
| `-get-curl` | Print the curl command for executing this query and exit (WARNING: includes printing your access token!) |
| `-insecure-skip-verify` | Skip validation of TLS certificates against trusted chains |
| `-trace` | Log the trace ID for requests. See https://docs.sourcegraph.com/admin/observability/tracing |
| `-user-agent-telemetry` | Include the operating system and architecture in the User-Agent sent with requests to Sourcegraph (default: true) |
79 changes: 79 additions & 0 deletions docs/cli/references/prompts/list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# src prompts list

List all prompts in your Sourcegraph instance.

## Usage

```bash
src prompts list [flags]
```

## Examples

```bash
# List all prompts
src prompts list

# Search prompts by name, description, or content
src prompts list -query="error handling"

# Filter prompts by tag IDs
src prompts list -tags="UHJvbXB0VGFnOjE=,UHJvbXB0VGFnOjI="

# List prompts for a specific owner
src prompts list -owner="VXNlcjox"

# List only recommended prompts
src prompts list -recommended-only

# List built-in prompts only
src prompts list -builtin-only

# Include built-in prompts with user prompts
src prompts list -include-builtin

# Exclude draft prompts
src prompts list -include-drafts=false

# List prompts owned by viewer or their organizations
src prompts list -affiliated

# Paginate through results
src prompts list -limit=10 -after="cursor"

# Select specific columns to display
src prompts list -c id,name,description,visibility

# Output results as JSON
src prompts list -json

# Complex filtering example
src prompts list -query="Go" -recommended-only -include-drafts=false -json
```

## Flags

| Flag | Description |
|------|-------------|
| `-query` | Search prompts by name, description, or content |
| `-owner` | Filter by prompt owner (a namespace, either a user or organization) |
| `-tags` | Comma-separated list of tag IDs to filter by |
| `-affiliated` | Filter to only prompts owned by the viewer or viewer's organizations |
| `-recommended-only` | Whether to include only recommended prompts |
| `-builtin-only` | Whether to include only builtin prompts |
| `-include-builtin` | Whether to include builtin prompts |
| `-include-drafts` | Whether to include draft prompts (default: true) |
| `-limit` | Maximum number of prompts to list (default: 100) |
| `-after` | Cursor for pagination (from previous page's endCursor) |
| `-c` | Comma-separated list of columns to display. Available: id,name,description,draft,visibility,mode,tags (default: "id,name,visibility,tags") |
| `-json` | Output results as JSON for programmatic access |

### API flags

| Flag | Description |
|------|-------------|
| `-dump-requests` | Log GraphQL requests and responses to stdout |
| `-get-curl` | Print the curl command for executing this query and exit (WARNING: includes printing your access token!) |
| `-insecure-skip-verify` | Skip validation of TLS certificates against trusted chains |
| `-trace` | Log the trace ID for requests. See https://docs.sourcegraph.com/admin/observability/tracing |
| `-user-agent-telemetry` | Include the operating system and architecture in the User-Agent sent with requests to Sourcegraph (default: true) |
Loading