agentleFS
ntaffziintaffzii/Skill-Agents/skills/thai/thai-address/SKILL.md

thai-address

Skill4 starsChanged 2 months agoMITView on GitHub

Use this skill for any task parsing a Thai address into its components (ตำบล/แขวง, อำเภอ/เขต, จังหวัด, รหัสไปรษณีย์) or looking up a province from a postal code or name. Trigger on "แยกที่อยู่", "ที่อยู่ไทย", "รหัสไปรษณีย์", "จังหวัดอะไร", "Thai address parse", "postal code to province". If the address is already cleanly split into labeled fields (e.g. a form with separate province/district inputs), this skill's lookup table is still useful but the parsing half is unnecessary.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run python3 parse.py for the self-test.

    line 48

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Thai Address Parsing

Overview

Thai addresses order components district-to-city the same broad direction as English (house number → subdistrict → district → province → postal code) but use Thai particle words (ตำบล/แขวง, อำเภอ/เขต, จังหวัด) that a naive English-address parser (split on commas, assume last token is a country) will mishandle — Bangkok uses แขวง/เขต instead of ตำบล/อำเภอ, and the parts can appear with or without abbreviations (ต./อ./จ.). This skill gives a regex-based extractor plus the 77-province reference table.

When to use

  • แยกที่อยู่ไทยเป็นส่วนประกอบ (ตำบล, อำเภอ, จังหวัด, รหัสไปรษณีย์)
  • หารหัสไปรษณีย์ 2 หลักแรก → จังหวัด (candidate lookup, not exact 5-digit resolution)
  • Matching a province name across Thai/English spelling and with/without "จังหวัด"/"Province" wrapper
  • Validating that a claimed province name is one of the real 77

When NOT to use

  • The task needs the exact 5-digit postal code for a specific subdistrict — this skill narrows to province-level candidates from the first 2 digits only; direct the user to Thailand Post's official lookup for the precise code
  • The address is non-Thai — use general address parsing instead

Core knowledge

  • Thailand has 77 provinces (76 + Bangkok). Bangkok uses แขวง (subdistrict) / เขต (district) terminology; every other province uses ตำบล / อำเภอ.
  • Postal codes are 5 digits. The first 2 digits identify a province-level zone in a well-documented sequential assignment (10 = Bangkok area, 20s = eastern seaboard, 30s-40s = northeast, 50s = north, 60s = lower-north/central, 70s = west, 80s-90s = south). The last 3 digits identify the specific post office/district — this skill does not resolve that level.
  • Bangkok and Samut Prakan share the 10 prefix; several other neighboring provinces' outlying districts can carry a prefix that "belongs" to an adjacent province's normal range. Treat a prefix match as a candidate list, not a certainty.
  • Standard field order in a full Thai address: [เลขที่/บ้านเลขที่] [หมู่ที่] [ถนน] ตำบล/แขวง[X] อำเภอ/เขต[Y] จังหวัด[Z] [รหัสไปรษณีย์].

Common mistakes

  1. Assuming ตำบล/อำเภอ apply to Bangkok addresses — Bangkok uses แขวง/เขต instead.
  2. Treating the first 2 postal-code digits as uniquely identifying one province — several pairs (notably Bangkok/Samut Prakan) share a prefix.
  3. Matching province names with exact string equality only — fails on "จ.เชียงใหม่", "จังหวัดเชียงใหม่", "Chiang Mai Province", and plain "เชียงใหม่" all referring to the same province.
  4. Assuming a mostly-empty parse result means "no address" — it more often means the input didn't use the expected Thai particle words (see Known limitations).
  5. Fabricating a precise 5-digit postal code from a province name alone — the province-level prefix does not determine the last 3 digits.

Code

parse.py (uses provinces.json, no external dependencies):

  • load_provinces() → list of {name_th, name_en, region, postal_prefix}
  • find_province(name) → tolerant Thai/English match, handles "จังหวัด"/"จ."/"Province" wrapping
  • postal_prefix_to_provinces(code) → candidate province list from the first 2 digits
  • parse_thai_address(text) → {postal_code, province, district, subdistrict}

Run python3 parse.py for the self-test.

Known limitations

  • parse_thai_address is a structural regex extractor, not a trained address-parsing model. It requires the Thai particle words (ตำบล/แขวง/อำเภอ/เขต/จังหวัด or their abbreviations) to be present in the text; a plain comma-separated address without those words will parse mostly empty.
  • postal_prefix_to_provinces resolves to a province-level candidate list from 2 digits only — it cannot give the exact 5-digit code for a specific subdistrict, and a handful of border-area districts use a prefix outside their "home" province's normal range. Verify the exact code against Thailand Post's official lookup before printing it on a real document.
  • Province English-name romanization follows one common convention (RTGS-influenced with spaces, e.g. "Buri Ram"); other sources spell some names differently (e.g. "Buriram" one word) — treat spelling variants as equivalent when matching, not as errors.
  • provinces.json's region field uses one common 6-region grouping; other classifications (e.g. Royal Institute's 4-region scheme) group some Central provinces as "Lower North" instead — don't treat region as an official government classification.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.