Prompt Parsing
Prompt parsing is the step where IntentCSS cleans, normalizes, and breaks a natural language prompt into usable tokens.
Overview
Prompt parsing takes raw user input and turns it into structured text that the Intent Engine can understand.
For example:
intentcss generate --prompt "make me a beautiful blue button"
intentcss generate --prompt "make me a beautiful blue button"
is reduced into useful terms like:
beautiful
blue
button
beautiful
blue
button
The parser helps IntentCSS ignore filler words and focus on the parts that affect generation.
Parsing Flow
IntentCSS uses a simple prompt processing flow:
Raw Prompt
↓
Typo Correction
↓
Normalization
↓
Tokenization
↓
NLP Extraction
↓
Parsed Intent Data
Raw Prompt
↓
Typo Correction
↓
Normalization
↓
Tokenization
↓
NLP Extraction
↓
Parsed Intent Data
Normalization
Normalization makes the prompt easier to process.
It:
- Trims extra spaces
- Converts text to lowercase
- Removes unnecessary punctuation
- Collapses repeated whitespace
Example:
" Make!!! a BLUE button "
" Make!!! a BLUE button "
becomes:
make a blue button
make a blue button
Tokenization
After normalization, the prompt is split into tokens.
Example:
make a blue button
make a blue button
becomes:
make
a
blue
button
make
a
blue
button
Tokens are then used by the confidence system and intent matcher.
NLP Extraction
IntentCSS also uses NLP to extract more meaningful words from a prompt.
For example:
make me a beautiful blue button
make me a beautiful blue button
contains filler words like:
make
me
a
make
me
a
The important words are:
beautiful
blue
button
beautiful
blue
button
This improves matching accuracy and avoids letting filler words reduce confidence too much.
Parsed Intent Shape
A parsed prompt contains useful metadata:
{
originalPrompt: "make me a beautiful blue button",
normalizedPrompt: "make me a beautiful blue button",
tokens: ["make", "me", "a", "beautiful", "blue", "button"],
target: "tailwind",
detectedComponent: "button",
detectedColor: "blue"
}
{
originalPrompt: "make me a beautiful blue button",
normalizedPrompt: "make me a beautiful blue button",
tokens: ["make", "me", "a", "beautiful", "blue", "button"],
target: "tailwind",
detectedComponent: "button",
detectedColor: "blue"
}
This parsed result is passed into the Intent Engine.
Detected Fields
The parser can detect common prompt categories.
| Field | Example |
|---|---|
| Component | button, card, navbar, form |
| Color | blue, red, green, purple |
| Behavior | responsive, adaptive, centered |
| Style | glass, shadow, rounded |
| Size | small, large, compact |
Example
Input:
intentcss generate --prompt "responsive centered login form"
intentcss generate --prompt "responsive centered login form"
Parsed meaning:
Component: form
Behavior: responsive
Layout: centered
Context: login
Component: form
Behavior: responsive
Layout: centered
Context: login
Generated output:
mx-auto flex flex-col gap-4 rounded-xl bg-white p-6 shadow-md w-full max-w-md space-y-2
mx-auto flex flex-col gap-4 rounded-xl bg-white p-6 shadow-md w-full max-w-md space-y-2
Why Parsing Matters
Prompt parsing keeps IntentCSS predictable and safe.
Without parsing, a prompt would just be raw text.
With parsing, IntentCSS can:
- Identify the component
- Detect modifiers
- Correct typos
- Improve confidence scoring
- Avoid random generation
Next Steps
Continue with:
- Typo Correction
- Confidence Scoring
- Intent Engine