ai-address-parser
Skill12 starsChanged 49 days agoMITView on GitHub
Parses a free-text address blob (supplier email, Google Maps result, business card) into structured fields (street, postal code, city, state, country, contact, phone) via an LLM chat-completions call. Use when a form has separate address inputs and you want a paste-a-blob-to-autofill affordance instead of manual field-by-field entry.
In this repository37 other files it gives its agents.
- 3mf-print-editorSkill
- aegis-protocolSkill
- ai-address-parser-debugSkill
- ai-csuiteSkill
- browser-driverSkill
- chatgpt-web-delegationSkill
- chinese-humanizerSkill
- claude-agent-sdk-authSkill
- close-loopSkill
- de-ai-englishSkill
- dev-inboxSkill
- dokploy-deploySkill
- dokploy-upgradeSkill
- ecommerce-golive-checkSkill
- fork-upstream-syncSkill
- foxcode-openclawSkill
- git-cryptSkill
- git-worktree-decisionSkill
- handoff-receiverSkill
- image-prompt-engineerSkill
- init-rulesSkill
- landing-launch-checkSkill
- linuxdo-applicationSkill
- npm-publishSkill
- omnidebug-autopilotSkill
- psychology-masterSkill
- refactor-agents-mdSkill
- research-to-wechatSkill
- right-sized-solutionSkill
- rtk-token-saverSkill
- session-handoffSkill
- shared-memorySkill
- stalwart-dokploy-resend-relaySkill
- typed-decisions-around-llmsSkill
- web-compliance-builderSkill
- wechat-compliance-checkSkill
- wordpress-vps-installSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Every address field is a string, including postalCode — never coerce it to a number.
- Very specific: line 33
Add a confidence enum (high / medium / low) so the UI can flag results worth double-checking instead of presenting every parse as equally …
- Distinctive: line 43
Normalize country to one format: If the app's country field is free text (no ISO enum), ask for the full English country name so results …
- Distinctive: line 44
Length limits: If the target fields have max-length constraints, state each one's limit in the prompt so the model self-truncates, then …
- Very specific: line 49
Call the OpenAI-compatible chat-completions endpoint (POST {base_url}/chat/completions) with:
- Distinctive: line 86
Before shipping, run the parser against:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Address Parser
Turns messy pasted address text into structured form fields using an OpenAI-compatible chat-completions endpoint in JSON mode, applied non-destructively so it never clobbers fields the user already filled in.
Step 1: Design the Output Schema
Extract exactly the fields your form needs, no more. A typical set:
{
"address": "",
"postalCode": "",
"city": "",
"state": "",
"country": "",
"contact": "",
"phone": "",
"confidence": "high"
}- Every address field is a string, including
postalCode— never coerce it to a number. Many countries' postal codes have leading zeros or embedded spaces (e.g. Swedish123 45), and a numeric type silently destroys both. - Add a
confidenceenum (high/medium/low) so the UI can flag results worth double-checking instead of presenting every parse as equally certain. - Do not add fields the codebase has deliberately left unvalidated (e.g. skip an ISO country-code enum or a postal-code regex if the rest of the app treats these as free text — matching the model's output format to the app's actual validation avoids introducing a stricter contract than the rest of the system has).
Step 2: Write the Extraction Prompt
The prompt is the actual product here — get these rules right:
- Field-by-field extraction rules. Spell out what belongs in each field explicitly, especially the boundary between fields that are easy to blend. Example: "address = street line(s) only — never repeat city/postal/country into it." Without this, models happily dump the whole address into one field.
- Empty-string-not-guess rule. State directly: "If a field cannot be confidently determined, return an empty string — never guess, never write 'N/A' or 'unknown'." Models default to filling every field with something; this rule is what makes partial/ambiguous input safe to merge.
- Postal-code-as-string rule. Tell the model explicitly to preserve leading zeros and the country's native format as a string.
- Normalize country to one format. If the app's country field is free text (no ISO enum), ask for the full English country name so results are consistent and human-readable, matching whatever format the rest of the app already uses for that field.
- Length limits. If the target fields have max-length constraints, state each one's limit in the prompt so the model self-truncates, then truncate again defensively server-side (see Step 5).
- End the prompt with
Return ONLY this JSON object:followed by the exact empty-valued schema, then the raw input text.
Step 3: Make the Request
Call the OpenAI-compatible chat-completions endpoint (POST {base_url}/chat/completions) with:
model: the configured model namemessages: a singleusermessage containing the prompt from Step 2response_format: { type: 'json_object' }— forces JSON-mode output where the provider supports it- A generous timeout (60-90s) — parsing calls are not always fast
- Do not send a
temperatureparameter. Some newer models reject the request outright (HTTP 400) iftemperatureis present at all, rather than ignoring it. Omit it entirely instead of setting a default. - Auth via a bearer token from server-side config — never expose the key to the client.
Step 4: Parse the Response Defensively
Some models wrap JSON-mode output in markdown code fences despite response_format. Parse with a fallback:
try JSON.parse(raw)
catch: extract the first `{...}` block via a greedy regex (`/\{[\s\S]*\}/`) and JSON.parse that instead
catch again: treat as unparseableValidate the parsed result against the Step 1 schema (e.g. with a schema library). On validation failure, return a distinct error ("AI returned an unexpected format — try again") rather than surfacing a raw parse error. On the network/API call failing, return a separate error ("parsing failed — try again"). Log the raw content (truncated) server-side for debugging, but do not leak it to the client.
Step 5: Enforce Limits Server-Side
Re-apply the same length limits from Step 2 by slicing each returned string server-side before returning it to the client. Prompt instructions are not guarantees — treat them as best-effort and enforce the real constraint in code.
Step 6: Merge Non-Destructively on the Client
This is the rule that makes the feature safe to ship: only write a parsed field into the form if the form's current value for that field is empty, and skip any field the model returned as an empty string.
if (!form.city && result.city) form.city = result.cityNever overwrite a field the user already typed, even if the parse result disagrees with it — the user's own input is always authoritative. Surface the confidence field when it is low so the admin knows to manually verify before saving, but do not block the merge on it.
Step 7: Test These Failure Modes
Before shipping, run the parser against:
- A multi-line address block (typical postal-mail format)
- A single-line comma-separated address (typical Google Maps copy-paste)
- Non-Latin script input (e.g. an address in Chinese or Arabic) — confirm the model still extracts into the target language/format your app expects, or at minimum degrades to low confidence rather than fabricating fields
- Phone-only input with no address at all — confirm every address field comes back empty rather than guessed
- Garbage/unrelated input (e.g. a recipe, random text) — confirm the model returns empty strings and low confidence rather than hallucinating a plausible-looking address
Step 8: Bilingual Field Variant
Some record types carry paired fields for two languages instead of one canonical value — e.g. companyNameZh/companyNameEn, companyAddressZh/companyAddressEn. Extend the base technique like this:
- Pair every bilingual field. For each concept, define both a source-language field and a counterpart field (e.g.
contactNameZh/contactNameEn), not a single field plus a separate "language" flag. - Fill-from-source-then-render-counterpart rule. Instruct the model: fill the field matching the language the source text actually used, taking the value from the source itself, then populate the counterpart only where the rendering is mechanical — romanizing a Chinese address or personal name into Latin script for a shipping label is safe, because the result is a transliteration rather than new information.
- Distinguish transliterable values from registered ones. A company's legal name in another language is a registered fact, not something derivable from its name in the first language; same for anything officially issued. Leave the counterpart empty for those fields rather than producing a plausible-looking translation that will not match any document. Getting this wrong is worse than an empty field, because the invented name looks authoritative and flows into invoices and customs paperwork.
- Do not machine-translate into a script the source did not contain. If the input is single-language (e.g. English-only), leave the opposite-script fields empty rather than guessing a translation. This mirrors the empty-string-not-guess rule from Step 2, applied per-language: an absent language in the source is itself information, not a gap to paper over.
- State both rules explicitly and adjacently in the prompt — models default to translating everything into both fields unless told not to for the single-language case.
- The non-destructive merge rule from Step 6 applies per bilingual field independently — merging
companyNameEndoes not depend on whethercompanyNameZhwas also filled.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

