Pieces for Developers is the first developer tool in the world to ingest an entire code base and return hyper-specific, highly reusable code snippets entirely offline and on-device.
What is Snippet Discovery?#
Snippet Discovery allows you to create code snippets from the code you've already written in a specific project, directory, or file. This automated process is useful when:
- Getting Started with the Pieces Desktop App and you don't have snippets yet
- Onboarding onto a new project and wanting to get some of the most useful snippets into your Pieces repo
- Forking a repository and gathering any reference docs mentioned or related to the project
- and many other use cases!
Running Snippet Discovery#
To run Snippet Discovery:
This allows you to select a single file or multiple files. Once the File Picker opens, select a single file and press 'Open' or hold
⌘/CTRLwhile you select multiple files.
Select a Folder:
When selecting a folder, you can only select one at a time. Since there is an unknown number of files, it is best to select the directory closest to the code that you're using. For example, instead of using a
/src/views, it may be better to use the non-nested
/srcto attach more holistic context.
Selecting Gists requires you to be signed in to GitHub. If you are not signed in when you select this option, you will receive a notification to sign in.
Drag and Drop:
When you drag code into the Pieces Desktop App while on the list or gallery view, it will be added as a single asset. However, if you drag an entire file or directory into Pieces while Snippet Discovery is open, it will perform snippet discovery on the file or directory you just added.
Why should you run Snippet Discovery?#
Running Snippet Discovery on a local source repository has huge benefits:
- Discover highly reusable snippets, resulting in less time spent rewriting the same code from scratch over and over
- Drive code standardization within and across projects
- Discover reference snippets and share them with your team or use them to onboard new developers faster than ever