Generate a Snippet
How to Use Parrot to generate a code snippet using a rule set.
The most powerful feature of Parrot is the ability to generate new code snippets dynamically using AI. Behind the scenes, Parrot currently uses Anthropic’s Claude Sonnet 3.5 model to generate your snippets.
To generate a new snippet, head over to the Create Snippet page and select the “Generate” tab (the default when creating new snippets).
First, give your snippet a name and then select the language/framework that will be used to generate the snippet.
Next, optionally select the Rule Set that you’d like to use for the generation.
After you’ve selected a rule set, next, optionally select a project to add the snippet to (recommended for keeping things organized and making your snippets shareable with a project team).
Finally, provide a prompt to generate the snippet. Your prompt should:
- Use as specific language as possible. The generated result will only be as accurate as the prompt you provide. While you can get a good result with a simple prompt, the more detailed your expectaitons, the better.
- Use proper grammar and spelling. While the AI is pretty good about handling typos, if your prompt is difficult to reason through, it can have a negative effect on the result.
- If possible, provide examples of other code that can be used as a reference or starting point. For example, if you have a function written in Python that you’d like to use in Node.js, provide the Python code as an example, specifying that you’d like that code rewritten to work with JavaScript/Node.js.
Once you’ve written your prompt, assuming that you have enough credits for generation (Parrot will provide an estimate of the tokens required to generate the snippet), click the “Start Generating” button at the bottom of the form.
After this, Parrot will start generating your snippet, redirecting you to the snippet editor.
Once your snippet is generated, you will see one or more code blocks for the snippet, followed by example usage for the code in the snippet and documentation describing how the snippet is implemented.
Iterating on a Snippet
While the ideal outcome is that the generated snippet fits your needs on the first try, often, you will need to provide additional prompting after the first generation.
From the snippet editor, you can provide additional instructions and re-generate the snippet via the input at the bottom of the snippet editor. Type in your iteration instructions and then click the “Iterate” button to re-generate the snippet.
At the top of the editor, you can use the arrows next to the version label to toggle between versions of your snippet.