r/Alfred • • 8d ago

I videcoded a little something something!

first of all, I am not a coder, i have no idea how all of this works. I know Claude, I know Alfred and i have a timing problem.

I just asked claude to create a easier version of a google maps workflow. less clutter, basically the same use cases, pulled a few nice looking map layouts from snazzy maps, which can be selected in in config, hooked it up with transitous and voila a super basic destination mapper!

now i have:

- a nice config with a default city setting, a few font size options, editable Home and Work destinations, various map styles, language setting

- a super basic destination router for car, bike, transit and by foot. It also giving me a which is few route options!
- the possibility to add a third destination

I did all that in an evening with claude and i am super happy with it!

32 Upvotes

10 comments sorted by

6

u/scitbiz 8d ago

Looks awesome, could you share your workflow?

2

u/PropaneFitness 8d ago

x2!

2

u/etsyseller89 7d ago

hello there, i hope this helps! here is a prompt!

Open Maps for Alfred – Build Prompt

For people: paste everything from The prompt on into Claude (code execution on). For an exact copy, attach Open-Maps.alfredworkflow too. Add the skill github.com/Hemmingsson/alfred-ui-skill (MIT). Claude can't run Alfred: test what it lists, send screenshots. Addresses and e-mail go only into Configure Workflow….

The prompt

1. Task and rules

Build or take over Open Maps 1.1.4, an Alfred 6 workflow with an Alfred UI window: routes and place search on a live map, open data only, no API keys.

  1. Read the alfred-ui skill (SKILL.md, references/) before writing ui.json; take every key from it. Missing? Ask for it or name your guesses.
  2. If Open-Maps.alfredworkflow is attached, read it all first and change only what is asked. Otherwise rebuild from this prompt and list your choices.
  3. Change nothing unrequested; ask first. No personal data in code or readme; personal values come only from User Configuration.
  4. Every delivery: a ready .alfredworkflow with a raised version, plus three notes: changed, tested, please test in Alfred.
  5. Reply in the user's language. Workflow texts are English, with German as second language.

2. Behaviour

  • Keyword maps (configurable) opens the window inside Alfred (launchmode 0).
  • Input: maps Eiffel Tower (place); A > B or from A to B (route); A > B > C or from A via B to C (one stop); German von A über B nach C. home/work (also zuhause, daheim, office, arbeit, büro) use the configured addresses. External Trigger route takes Start > Destination.
  • Keys: ↩ route; ↩ again or ⌘O opens Google Maps with the resolved coordinates; ⌘1–⌘4 mode; ⌘T swap; ⌘U add/remove stop.
  • Sidebar: From/To with a round +/− for a stop field; optional Home/Work; four modes with times; large travel time, alternative buttons 1–3, departure–arrival line; transit itinerary (coloured lines, platforms, transfers, delays); hint line.
  • Map: route, stops, start/destination; light-blue alternatives with time chips, clickable; pinch, scroll, double-click zoom.

3. Layout (points)

Window width and map height from config (1180, 620). Root border, padding 12, spacing 12.

  • Left, 345 wide (border):

    • top (flex, 1 column, spacing 10, left-aligned).

      • Row 0 fieldsBlock: card (radius 10, padding 4, light #0000000d / dark #ffffff12, inset right 15) with swap button (SF arrow.up.arrow.down, 26) and a vertical inline stack: textfield von (focus), 1-pt divider, empty viaSlot, textfield nach (277 wide, borderless, no focus ring, insets 10/8, font 15). A 30-pt round viaButton (SF plus/minus) on a circle #e3e3e8 / #4a4a50 overhangs the right edge.
      • Row 1 rest (330 wide, flex): optional quick buttons; modesCard (same card, 2×4 grid: SF car.fill, tram.fill, bicycle, figure.walk at 20, bold 13 times below); durationRow (bold 32 time left; circular buttons alt0–alt2, 26, right); info (14, secondary).
    • centre: steps dataview (330 wide, hidden when empty). Each cell: a 5-pt colour bar or ┊ dots, a time column in bold monospaced digits, then text.
    • bottom: the hint line, 12.5, centred.
  • Centre: mapBox (stack, radius 12) holding the webkitview map.
  • Active mode and alternative: controlAccentColor; the rest secondaryLabelColor.

4. Data and fair use

5. Map page

  • Page: the script writes a self-contained HTML file with the data as JSON. It fetches the style JSON and recolours it (every style but colorful); on failure it uses the style URL.
  • Route: legs 5.5×scale over a 10×scale casing, walking dotted. Line colours come from the data, else by mode; each transit leg gets a line badge.
  • Markers: start white dot with blue ring, stop with black ring, destination red pin, transfer stops grey ring with optional names.
  • Framing: fit bounds with padding 46/72/60/60, max zoom 16.
  • Alternatives: light blue, with a 22-pt invisible hit line and a time chip where they diverge most.
  • Zoom: wheel rate 1/250, no rotation, NavigationControl bottom right. Pinch via Safari gesture* events, turned into easeTo.
  • Labels like Google Maps:

    • countries, regions, seas and cities: coalesce(name:<lang>, name);
    • towns, streets and POIs: name;
    • non-Latin places: Latin name, a newline, then name:nonlatin;
    • leave ref labels alone.
  • Palettes (land, water, park, building, minor road, major road, motorway, casing, text, place):

    • dark: #24262b #1c3550 #22332a #2c2f35 #33363d #4a4e57 #5a5e68 #1b1c20 #b9bcc4 #d0d3da;
    • light (on positron): #f2f1ed #c3d9ee #dcebcf #e5e2db #fff #fff #fde7a4 #d6d2c9 #5f6368 #3c4043;
    • alternatives #5d8ccc (dark) / #8fb8f2 (light), chosen #0a84ff.
    • interface and wy recreate the Snazzy Maps styles by samisel and StipeP; their exact values are in the workflow file.

6. Configuration

User Configuration, in English (defaults): maps_keyword (maps), language (auto/en/de), start_region (empty = city of the time zone), default_mode (transit), show_quick (on), home_address, work_address, map_style (dark; light, auto, colorful, interface, wy), map_scale (1; 0.85–1.3), map_stop_names (on), font_fields/font_duration/font_info (15/32/14), window_width (1180; 700–2400), map_height (620; 300–1400), contact (e-mail for Transitous).

Texts live in one I18N table (en, de), with u/key placeholders in the JSON. Units, 12/24-hour clock and time zone follow macOS.

7. Build

  • info.plist (XML): bundle id alfred.workflow.open-maps; Keyword and External Trigger route both lead to the Alfred UI object; createdby empty.
  • Bundle: icon.png and maps.alfredui/ with ui.json, parts.json (rest 0/1, viaSlot open/closed), steps.json, map.json and maps.
  • maps is one JXA script: maps <action> <from> <to> <mode> <via> [extra], one JSON action on stdout.
  • Actions: init, enter, render, swap, via, home, work, alt, pick, google. After each one, route runs async and does all network work.
  • Visible actions answer at once from the cache; state lives in alfred_workflow_cache. All macOS access goes through one io object (tests replace it with __io).

8. Pitfalls (each broke a delivery)

  1. Map clicks: changed fires only on real page loads, not on # changes, and text pages can't reload.

    • Write pages to rotating files map-0…3.html, load via src. A click sets location.search="?alt=N&t=…"; the event passes {value:map.src}; handle each address once. The reloaded page waits 1.5 s before building the map.
    • openlinksexternally: "^https?:", not true.
  2. A replaced textfield loses the cursor. Only update fields; replace the parts around them.
  3. A replaced part needs the same grid/region/position as in ui.json, or it lands in row 0.
  4. hidden keeps its space: swap optional parts with replace (empty view ↔ content).
  5. async answers can arrive late: check the request is still current, else return {}.
  6. Missing values arrive as <null>, booleans as 1/0 or true/false: clean args first.
  7. Silent failures: JXA dies on redeclared globals ($, Path, delay, Application, Library, ObjC, Ref, Progress, Automation); uncaught exceptions print nothing (wrap run() in try/catch, show the error); check that NSTask launched.
  8. {value:} only in args, variables, data.filter; pulse args plain or one whole {var:}. Ids unique, including cell ids. British keys (colour, centre, behaviour); events use triggers.
  9. Map labels are mixed English/local by default. Users rejected all-translated and all-local, so use the rule in part 5.
  10. Respect OSRM's limit and Transitous' contact request.
  11. Before sharing, search the build for names, addresses and e-mails; use only neutral examples.

9. Test and hand over

Before every delivery: Node tests of the script with a mock __io; a JXA globals check in a vm context (define the globals from inside it); a key check of ui.json/parts.json against the skill, incl. pitfall 3; the map page in headless Chromium with MapLibre stubbed. Zip the folder contents, keeping the exec bit on maps.

Then ask the user to check in Alfred: cursor in From on opening; times for all modes; ⌘ keys; clicking map alternatives; Home/Work (no gap when off); zoom; place names; settings applied on next opening.

1

u/iamjediknight 7d ago

I took easier approach :-). Installed the github.com/Hemmingsson/alfred-ui-skill skill and the image from the original post and said "recreate this as an Alfred workflow"

1

u/etsyseller89 6d ago

haha great! how did it work out?!

1

u/iamjediknight 5d ago

Pretty good. I am using it as exercise to learn about the Alfred api

4

u/radnad 8d ago

We've arrived in a new era of workflows where people can vibe code interesting tools but they probably can't just share it without sharing personal data. I thing we need to establish a way for Vibe coded workflows to be shared more easily. Potentially having a basic prompt that'd make the workflow to be open for others to implement locally and that would create the options to enter or retrieve the data to make it work for a new user.

There are so many other questions to take into account, obviously, like maintaining a workflow when it's just a tool you created for yourself, and others starting to depend on it.

1

u/appwaypoint 8d ago

Great idea!

1

u/iamjediknight 8d ago

Please share. Pretty Please