An open API service indexing awesome lists of open source software.

https://github.com/setkyar/prompt


https://github.com/setkyar/prompt

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# prompt

A Go port of Simon Willison's [files-to-prompt](https://github.com/simonw/files-to-prompt) tool, created with the assistance of Claude AI using File Server MCP. This CLI tool concatenates a directory full of files into a single prompt for use with LLMs. This tool will help users easily prepare code repositories and directories for prompting large language models (LLMs).

### Development

This Go version was created with the assistance of Claude AI using File Server MCP. It maintains feature parity with the original Python tool while leveraging Go's advantages like static typing and simple deployment (single binary execution).

### Differences from the original

- Implemented in Go instead of Python
- Simplified installation (single binary)
- Same command-line interface and functionality
- Added detailed debug output capabilities

## Installation

```bash
go install github.com/setkyar/prompt@latest
```

Or clone the repository and build it:

```bash
git clone https://github.com/setkyar/prompt.git
cd prompt
go build
```

## Usage

To use `prompt`, provide the path to one or more files or directories you want to process:

```bash
prompt path/to/file_or_directory [path/to/another/file_or_directory ...]
```

This will output the contents of every file, with each file preceded by its relative path and separated by `---`.

### Options

- `-e/--extension `: Only include files with the specified extension. Can be used multiple times.

```bash
prompt path/to/directory -e txt -e md
```

- `--include-hidden`: Include files and folders starting with `.` (hidden files and directories).

```bash
prompt path/to/directory --include-hidden
```

- `--ignore `: Specify one or more patterns to ignore. Can be used multiple times.
```bash
prompt path/to/directory --ignore "*.log" --ignore "temp*"
```

- `--ignore-files-only`: Include directory paths which would otherwise be ignored by an `--ignore` pattern.

```bash
prompt path/to/directory --ignore-files-only --ignore "*dir*"
```

- `--ignore-gitignore`: Ignore `.gitignore` files and include all files.

```bash
prompt path/to/directory --ignore-gitignore
```

- `-c/--cxml`: Output in Claude XML format.

```bash
prompt path/to/directory --cxml
```

- `-m/--markdown`: Output as Markdown with fenced code blocks.

```bash
prompt path/to/directory --markdown
```

- `-o/--output `: Write the output to a file instead of printing it to the console.

```bash
prompt path/to/directory -o output.txt
```

- `-n/--line-numbers`: Include line numbers in the output.

```bash
prompt path/to/directory -n
```

- `-0/--null`: Use NUL character as separator when reading paths from stdin. Useful when filenames may contain spaces.

```bash
# Find Go files, concatenate them with prompt, and pipe to Claude
find ./path -name "*.go" -print0 | prompt --null --cxml | anthropic claude
```

### Example Output Formats

#### Default Format

```
path/to/file.go
---
package main

func main() {
// Code here
}
---
```

#### Claude XML Format

```xml

path/to/file.go

package main

func main() {
// Code here
}

```

#### Markdown Format

````
path/to/file.go
```go
package main

func main() {
// Code here
}
```
````

## Reading from stdin

The tool can also read paths from standard input:

```bash
# Find Go files and process them
find . -name "*.go" | prompt
```

When using the `--null` (or `-0`) option, paths are expected to be NUL-separated:

```bash
find . -name "*.go" -print0 | prompt --null
```

## Acknowledgments

This project is a direct port of Simon Willison's excellent [files-to-prompt](https://github.com/simonw/files-to-prompt) Python tool. All credit for the original concept, design, and functionality goes to Simon.

Special thanks to Claude AI by Anthropic for assistance in writing and debugging the Go code through File Server MCP.

## License

This project is licensed under the Apache License 2.0, the same license as the original Python tool.