Purpose of this document: illustrate the user and developer value of the
/snippetcommand in an application based on Pythia-webview2.
This document does not cover plugin installation or registration in the host application.
Important
The /snippet command is available only when the corresponding plugin is installed and loaded by the host application.
Without this plugin, the command is not interpreted by Pythia-webview2 and should be considered unavailable in the runtime environment.
- 1. Why a
/snippetcommand? - 2. What this command demonstrates
- 3. Command surface
- 4. Progressive discovery
- 5. Common point of confusion:
reviewandtldrare independent - 6. Naming and normalization
- 7. Content handling
- 8. Snippet size
- 9. Persistence
- 10. Rename and delete
- 11. Export / import
- 12. Degraded import
- 13. Command registry validation
- 14. Suggested walkthrough
- 15. What the developer should observe
- 16. Limits and possible extensions
- 17. Summary
An application that integrates an LLM quickly accumulates recurring prompts:
- request a code review;
- produce a short summary;
- rephrase an answer;
- generate a technical note;
- prepare a developer-facing message;
- apply a stable business instruction before pasting variable content.
The /snippet command turns these recurring prompts into local, persistent shortcuts that can be managed directly from the prompt input field.
Instead of typing this repeatedly:
You are a senior Delphi reviewer. Be concise.
the user can save it once:
/snippet save review "You are a senior Delphi reviewer. Be concise."
and reuse it later:
/snippet use review
The prompt input field is then pre-filled with the snippet content. The user stays in control: they can edit, extend, or send the prompt manually.
/snippet is intentionally simple from the user’s point of view, but it is interesting from an integration point of view:
- it demonstrates a Pythia command with multiple actions;
- it manipulates persistent state;
- it writes into the prompt input field;
- it provides clear user feedback: success, warning, error;
- it illustrates centralized argument validation;
- it exposes documented tokenizer limits;
- it shows JSON import/export that remains useful to a developer.
This is therefore not only a convenience command. It is a compact example of what a developer can add to a Pythia-webview2 application to improve prompt workflows.
/snippet save <name> "<content>"
/snippet use <name>
/snippet show <name>
/snippet list
/snippet rename <oldName> <newName>
/snippet delete <name>
/snippet import <jsonFile>
/snippet export <jsonFile>
| Command | Purpose |
|---|---|
/snippet save name "content" |
Saves or replaces a snippet. |
/snippet use name |
Injects the snippet content into the prompt input field. |
/snippet show name |
Displays the snippet content in the chat without modifying the input field. |
/snippet list |
Lists available snippets. |
/snippet rename old new |
Renames an existing snippet. |
/snippet delete name |
Deletes a snippet. |
/snippet export file.json |
Exports the current storage to a JSON file. |
/snippet import file.json |
Imports and merges snippets from a JSON file. |
When no snippet exists yet:
/snippet list
Expected result:
No snippet stored
This message is useful because it confirms that the command is active and that the storage is empty.
/snippet save review "You are a senior Delphi reviewer. Be concise."
Expected result: success, with creation of the storage file if needed.
Then:
/snippet save tldr "Summarize the following in 3 bullet points."
There are now two independent snippets:
review;tldr.
An equivalent JSON file may look like this:
{
"review": "You are a senior Delphi reviewer. Be concise.",
"tldr": "Summarize the following in 3 bullet points."
}/snippet list
Expected result: a Markdown list of available names.
Example:
**Snippets**
- review
- tldrThe list intentionally shows names only. To inspect the content, use /snippet show.
/snippet show review
Expected result: a block displayed in the chat.
Example:
**review**
~~~
You are a senior Delphi reviewer. Be concise.
~~~The content is displayed inside a ~~~ fenced block so it stays readable even if the snippet contains Markdown or code.
/snippet use review
Expected result: the prompt input field is pre-filled with:
You are a senior Delphi reviewer. Be concise.
This is the central behavior of the command.
use does not submit the prompt automatically. It also does not concatenate the snippet with the text already present. It simply places the snippet content into the input field, then lets the user edit or send it.
With this storage:
{
"review": "You are a senior Delphi reviewer. Be concise.",
"tldr": "Summarize the following in 3 bullet points."
}the command:
/snippet use review
loads only the value associated with review.
It does not load tldr, and it does not load the entire JSON file.
Conversely:
/snippet use tldr
loads only:
Summarize the following in 3 bullet points.
The JSON file is therefore a snippet library, not an automatically composed prompt.
Snippet names are normalized:
- leading and trailing whitespace is removed;
- case is ignored;
- storage uses lowercase keys.
Therefore:
/snippet save Review "AAA"
/snippet save REVIEW "BBB"
/snippet show review
will display BBB, because Review, REVIEW, and review all refer to the same normalized key.
The following characters are rejected in snippet names:
. [ ] / \
Invalid examples:
/snippet save my.name "x"
/snippet save my[0] "x"
/snippet save my/name "x"
/snippet save my\name "x"
These restrictions keep the JSON storage simple and avoid ambiguity with path syntax or JSON-reading conventions.
Multi-word content must be wrapped in quotes:
/snippet save x "one two three"
Without quotes:
/snippet save x one two three
the command receives too many arguments and fails with an arity error.
Windows paths are preserved:
/snippet save path "C:\Temp\file.txt"
The snippet contains exactly:
C:\Temp\file.txt
The tokenizer does not support escape sequences such as \".
The following command is therefore a known limitation:
/snippet save quote "he said \"hello\""
Content containing literal quotes should instead be imported from JSON, or handled by a future tokenizer improvement.
This limitation is deliberately documented: it avoids presenting the command as a full mini-language when it is meant to remain a fast prompt utility.
Two thresholds are applied per snippet:
| Size | Behavior |
|---|---|
| empty or whitespace-only content | rejected |
| up to 8192 characters | accepted |
| over 8192 characters | accepted with a warning |
| over 65536 characters | rejected |
Examples:
/snippet save x ""
Expected result:
Snippet content is empty
Very long content below the hard limit is stored with a warning:
Snippet "bigger" stored, content larger than 8192 characters
The goal is not to arbitrarily restrict the user, but to protect the prompt input field and avoid accidentally abusive prompts.
Snippets are stored in a local application support JSON file:
<support-dir>\<AppName>-snippets.json
The format is intentionally flat:
{
"review": "You are a senior Delphi reviewer. Be concise.",
"summary": "Summarize the following in 3 bullet points."
}This format has several advantages:
- human-readable;
- easy to back up;
- easy to diff;
- easy to import/export;
- sufficient for a local prompt library.
- save two snippets;
- completely close the application;
- inspect the
support\<AppName>-snippets.jsonfile; - restart the application;
- run:
/snippet list
Both snippets should still be present.
/snippet rename tldr summary
Expected result:
summaryexists;tldrno longer exists;- the content is preserved.
Rejected cases:
/snippet rename a a
Expected result:
Old and new names are identical
/snippet rename a b
if b already exists:
Snippet "b" already exists
/snippet delete review
Expected result: review is deleted.
If the snippet does not exist:
Snippet "review" not found
/snippet export C:\tmp\backup.json
Expected result:
Snippets exported to C:\tmp\backup.json
The exported file contains the same keys and values as the current storage.
/snippet import C:\tmp\backup.json
Expected result:
N snippet(s) imported
Import merges snippets into the existing storage. In case of conflict, the imported value replaces the local value with the same normalized name.
Import accepts only a flat JSON object whose values are strings.
{
"review": "You are a senior Delphi reviewer. Be concise.",
"tldr": "Summarize the following in 3 bullet points."
}File:
not json at all
Command:
/snippet import C:\tmp\bad-format.txt
Expected result:
Import file is not a JSON object
File:
{
"ok": "valid value",
"wrong": 42,
"also_wrong": ["x"]
}Command:
/snippet import C:\tmp\bad-types.json
Expected result:
1 snippet(s) imported, 2 skipped
File:
{
"a.b": "rejected",
"valid": "ok",
"with/slash": "rejected"
}Command:
/snippet import C:\tmp\bad-names.json
Expected result:
1 snippet(s) imported, 2 skipped
/snippet import C:\tmp\absent.json
Expected result:
Import file not found: C:\tmp\absent.json
Some errors are not handled by the snippet service itself, but by command validation.
| Command | Expected status |
|---|---|
/snippet save x |
csWrongArgCount: 1 argument received, 2 expected |
/snippet use |
csWrongArgCount: 0 arguments received, 1 expected |
/snippet list extra |
csWrongArgCount: 1 argument received, 0 expected |
/snippet bogus x |
csUnknownAction |
/snippeT save x "y" |
OK if the command name is normalized to lowercase |
This separation matters to the developer:
- the registry validates action existence and arity;
- the service validates names, content, files, and business logic.
This scenario is enough to show the command’s value in a few minutes.
- run the application in debug mode;
- delete the
support\<AppName>-snippets.jsonfile if it exists; - keep the
supportfolder open in File Explorer.
| # | Command | Expected result |
|---|---|---|
| 1 | /snippet list |
No snippet stored |
| 2 | /snippet save review "You are a senior Delphi reviewer. Be concise." |
success; JSON file created |
| 3 | /snippet save tldr "Summarize the following in 3 bullet points." |
success; two keys in the file |
| 4 | /snippet list |
Markdown list with review and tldr |
| 5 | /snippet show review |
fenced block containing the text |
| 6 | /snippet use review |
input field pre-filled with the content |
| 7 | /snippet rename tldr summary |
success; summary exists, tldr no longer exists |
| 8 | /snippet delete review |
success; only summary remains |
| 9 | /snippet list |
one entry |
- save two snippets;
- completely close the application;
- verify the JSON file;
- restart the application;
- run
/snippet list.
The snippets should be restored.
/snippet export C:\tmp\backup.json
Then delete the support file, restart the application, and run:
/snippet list
Expected result:
No snippet stored
Then:
/snippet import C:\tmp\backup.json
/snippet list
Expected result: snippets restored.
The developer sees a command that directly improves day-to-day usage of an LLM application: it removes repetition from stable prompts.
/snippet use fills the input field, but does not submit automatically. This is an important product decision: the user remains responsible for the final prompt.
The flat JSON file is easy to inspect, back up, and version. For an integration sample, this is more transparent than opaque storage.
The command exposes a clear surface. The service handles:
- validation;
- normalization;
- storage;
- import/export;
- interaction with the prompt input field.
The developer can see how to add a business command without turning the main interface into a monolith.
The command documents its limits: no \" escaping in the tokenizer, no templating, no auto-submit, no secret storage.
That is a useful signal for a developer: the command is simple, but its scope is clear.
The current command replaces the input field content. An append action could be added, but it requires a reliable primitive to read or extend the current input field text.
Possible example:
/snippet append review
Expected effect: append the snippet to the text already present.
A possible extension would be placeholder support:
Hello {{name}}, could you review this section?
That would be a different responsibility. Snippet storage should remain independent from a possible templating engine.
The current import favors robustness: it imports valid entries and counts skipped ones. A strict version could reject the whole file at the first problem.
Snippets are plain text. They should not contain secrets. API keys, tokens, and sensitive information should use dedicated secure storage.
/snippet is a small command, but it demonstrates real value for Pythia-webview2:
- it gives the user a local prompt library;
- it makes repetitive LLM workflows faster;
- it shows how a command can modify the prompt input field;
- it persists its state in readable JSON;
- it exposes a complete surface: create, read, use, rename, delete, import, export;
- it documents its limits clearly.
For an application that integrates an LLM, this command is simple enough to understand quickly and rich enough to demonstrate a real extension mechanism.