npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

files-to-prompt-js

v1.0.1

Published

Concatenate a directory full of files into a single prompt for use with LLMs

Downloads

7

Readme

files-to-prompt-js

A TypeScript implementation of files-to-prompt, a tool to concatenate a directory full of files into a single prompt for use with LLMs.

Installation

npm install -g files-to-prompt-js

Usage

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

files-to-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 <extension>: Only include files with the specified extension. Can be used multiple times.

    files-to-prompt path/to/directory -e txt -e md
  • --include-hidden: Include files and folders starting with . (hidden files and directories).

    files-to-prompt path/to/directory --include-hidden
  • --ignore <pattern>: Specify one or more patterns to ignore. Can be used multiple times. Patterns may match file names and directory names, unless you also specify --ignore-files-only. Pattern syntax uses glob, which supports *, ?, [anychar], [!notchars] and [?] for special character literals.

    files-to-prompt path/to/directory --ignore "*.log" --ignore "temp*"
  • --ignore-files-only: Include directory paths which would otherwise be ignored by an --ignore pattern.

    files-to-prompt path/to/directory --ignore-files-only --ignore "*dir*"
  • --ignore-gitignore: Ignore .gitignore files and include all files.

    files-to-prompt path/to/directory --ignore-gitignore
  • -c/--cxml: Output in Claude XML format.

    files-to-prompt path/to/directory --cxml
  • -m/--markdown: Output as Markdown with fenced code blocks.

    files-to-prompt path/to/directory --markdown
  • -o/--output <file>: Write the output to a file instead of printing it to the console.

    files-to-prompt path/to/directory -o output.txt
  • -n/--line-numbers: Include line numbers in the output.

    files-to-prompt path/to/directory -n

    Example output:

    files_to_prompt/cli.ts
    ---
      1  import { Command } from 'commander';
      2  import fs from 'fs';
      3  import { processPaths } from './core';
      ...
  • -0/--null: Use NUL character as separator when reading paths from stdin. Useful when filenames may contain spaces.

    find . -name "*.ts" -print0 | files-to-prompt --null

Reading from stdin

The tool can also read paths from standard input. This can be used to pipe in the output of another command:

# Find files modified in the last day
find . -mtime -1 | files-to-prompt

When using the --null (or -0) option, paths are expected to be NUL-separated (useful when dealing with filenames containing spaces):

find . -name "*.txt" -print0 | files-to-prompt --null

You can mix and match paths from command line arguments and stdin:

# Include files modified in the last day, and also include README.md
find . -mtime -1 | files-to-prompt README.md

Claude XML Output

Anthropic has provided specific guidelines for optimally structuring prompts to take advantage of Claude's extended context window.

To structure the output in this way, use the optional --cxml flag, which will produce output like this:

<documents>
<document index="1">
<source>my_directory/file1.txt</source>
<document_content>
Contents of file1.txt
</document_content>
</document>
<document index="2">
<source>my_directory/file2.txt</source>
<document_content>
Contents of file2.txt
</document_content>
</document>
</documents>

Markdown Output

The --markdown option will output the files as fenced code blocks, which can be useful for pasting into Markdown documents.

files-to-prompt path/to/directory --markdown

The language tag will be guessed based on the filename.

If the code itself contains triple backticks the wrapper around it will use one additional backtick.

Example output:

myfile.ts
```typescript
function myFunction(): string {
    return "Hello, world!";
}
```
other.js
```javascript
function myFunction() {
    return "Hello, world!";
}
```
file_with_triple_backticks.md
````markdown
This file has its own
```
fenced code blocks
```
Inside it.
````

Development

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Run linter
npm run lint

# Format code
npm run format

License

Apache 2.0