Guide
Writing a plugin with AI
You don't have to write plugin code by hand. A general-purpose AI assistant β ChatGPT, Claude, Cursor, or similar β can write it for you, as long as it's given the exact API it has to write against. That's what the skill file on this page is: a single document listing every method a plugin can call, so the AI doesn't invent ones that don't exist.
Step by step
-
Open an AI chat
Any general-purpose assistant works β Cursor, ChatGPT, Claude, or similar.
-
Give it the skill file
Copy the whole reference below and paste it in as context, or point the assistant at
mapextender.com/ai-skills.mdif it can fetch a URL. Either way, it needs the whole file β trimming it risks the AI guessing at methods that don't exist. -
Describe what you want
Use the prompt template further down. Being specific about data source, colors, and behavior on map movement gets a much closer first result.
-
Review the output
Check it against the checklist below before you trust it.
-
Add it on the plugins page
Click New Plugin, then paste in the name, description, match patterns, settings schema, and code the AI returned. See Creating a plugin for the rest of that flow, including how to test and debug it.
The skill file
This is the same reference as the Plugin API reference page, in plain text so an AI assistant can read it directly rather than parsing a formatted page.
https://mapextender.com/ai-skills.md
Open the raw file to copy its contents directly.
Prompt template
Paste this into the same chat as the skill file, filling in your own request at the bottom:
You are writing a Map Extender plugin.
Follow the Map Extender AI Skills API exactly.
Return:
1. Plugin name
2. Description
3. Match patterns
4. Settings schema as valid JSON (array), if needed
5. Default settings, if needed
6. JavaScript plugin code only, with no imports/exports/TypeScript/JSX
User request:
<describe the plugin here>
Example request
Create a plugin that shows all bicycle parking locations in the current map bounds.
Use Overpass API.
Add blue markers.
Show the name or "Bicycle parking" in the popup.
Reload when the map moves, debounced by 500ms.
Add a setting for marker color.
AI output checklist
Before you trust generated code, check that it:
- Uses
plugin.mapHook.onHook(...)to wait for the map - Uses
plugin.fetch(...)for remote requests, never a directfetch - Has a settings schema that's valid JSON (if it has one at all) and pastes cleanly into the plugins page's JSON editor
- Debounces repeated map movement before making network calls
- Ignores stale responses with a sequence counter, so an old request can't overwrite a newer one
- Clears old layer data before drawing new results
- Logs useful success and error messages with
plugin.log/plugin.error - Uses no
import,export, TypeScript syntax, JSX, or npm packages - Doesn't require a page refresh to enable or disable
- Creates layers through
plugin.mapHook.createMarkerLayer,createPolylineLayer,createWmsLayer, or one of the other layer methods β not by touching the map library directly
A plugin is real JavaScript running on every site its patterns match. Passing this checklist means the code follows the right shape β it doesn't mean you shouldn't read through what it actually does before enabling it, the same as with any code you didn't write yourself.