Agent skill

Clustering System

by OpenLitterMap in OpenLitterMap/openlittermap-web

ClusteringService, tile keys, dirty tiles/teams, clustering commands, ClusterController GeoJSON API, PhotoObserver dirty marking, and map cluster rendering.

GPL-3.0Auto-check passedDatabases

Install Clustering System

skills CLI
$ npx skills add OpenLitterMap/openlittermap-web --skill clustering-system -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install OpenLitterMap/openlittermap-web clustering-system --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/OpenLitterMap/openlittermap-web.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.ai/skills/clustering-system .claude/skills/clustering-system && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
clustering-system
GitHub stars
134
Token cost
~2k tokens
SKILL.md length
638 words
Files
1
Skills in repo
16
Repo updated
First seen
Licence
GPL-3.0

At a glance

ClusteringService, tile keys, dirty tiles/teams, clustering commands, ClusterController GeoJSON API, PhotoObserver dirty marking, and map cluster rendering.

  • Works in 6 steps: Global clustering uses verified >= 2.… → PhotoObserver uses two thresholds.… → ClusteringService uses raw SQL, not… → …
  • Databases work in your project
  • SKILL.md covers Key Files, Artisan Commands, Invariants and Architecture, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Clustering System is an agent skill from OpenLitterMap/openlittermap-web. ClusteringService, tile keys, dirty tiles/teams, clustering commands, ClusterController GeoJSON API, PhotoObserver dirty marking, and map cluster rendering.

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases. It works with PHP. The repository describes itself as: https://opengeospatialdata.springeropen.com/articles/10.1186/s40965-018-0050-y. The licence is GPL-3.0.

When your agent uses it

  • Databases work in your project

Example prompts

  • “/clustering-system”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Global clustering uses verified >= 2. ADMIN_APPROVED and above. Team clustering uses verified >= 1 (tagged, so school students see their…
  2. PhotoObserver uses two thresholds. Global tile dirty: >= ADMIN_APPROVED. Team dirty: >= VERIFIED.
  3. ClusteringService uses raw SQL, not Eloquent. All clustering queries use DB::statement() with INSERT...SELECT. The Cluster model exists…
  4. Team clusters are in the same table as global clusters. team_id = 0 for global, team_id = N for team-specific. All global queries MUST…
  5. tile_key must be populated before per-tile clustering works. Always run --populate before --all.
  6. Global sentinel tile key is 4294967295 (UINT max). Global zoom clusters use this value. Per-tile clusters use the actual tile key.

What it can do on your machine

Read from SKILL.md and the folder at commit ac688aa. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are sql and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Clustering System loads about 2k tokens when it runs. Until then it costs about 44 tokens; SKILL.md has 638 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~44
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from OpenLitterMap/openlittermap-web at commit ac688aa, republished under its GPL-3.0 licence (© OpenLitterMap). 638 words, ~1,976 tokens.

Download SKILL.mdSave it as .claude/skills/clustering-system/SKILL.md (or your agent's skills folder).
name
clustering-system
description
ClusteringService, tile keys, dirty tiles/teams, clustering commands, ClusterController GeoJSON API, PhotoObserver dirty marking, and map cluster rendering.

Clustering System

Hierarchical grid-based clustering for map visualization. Photos are grouped into clusters at 9 zoom levels (0, 2, 4, 6, 8, 10, 12, 14, 16) using a two-tier strategy:

  • Global (zoom 0-6): Single query across all verified photos (verified >= 2)
  • Per-tile (zoom 8-16): Uses pre-computed tile keys and generated columns for performance

Team clustering is unified into the same clusters table via team_id column (0 = global, N = team-specific).

Key Files

  • config/clustering.php — Grid sizes, zoom levels, tile size, TTL, limits
  • app/Services/Clustering/ClusteringService.php — Core clustering logic (raw SQL, not Eloquent)
  • app/Http/Controllers/Clusters/ClusterController.php — Public API endpoint (GeoJSON + ETag)
  • app/Http/Controllers/Teams/TeamsClusterController.php — Team cluster API (GeoJSON + bbox). points() selects summary (not result_string).
  • app/Observers/PhotoObserver.php — Dirty tile/team marking + school privacy
  • app/Console/Commands/Clusters/UpdateClusters.php — clustering:update (full rebuild)
  • app/Console/Commands/Clusters/ProcessDirtyTiles.php — clustering:process-dirty (incremental)
  • app/Console/Commands/Clusters/CheckMigrationStatus.php — clustering:check-migration (diagnostic)
  • app/Models/Cluster.php — Eloquent model (composite PK, $timestamps = false)
  • resources/js/stores/maps/clusters/index.js — Pinia store for cluster data
  • resources/js/stores/maps/points/requests.js — Points store: GET_POINTS() with page, year, date, username, signal params
  • resources/js/views/Maps/helpers/clustersHelper.js — Frontend cluster rendering + interactions
  • resources/js/views/Maps/helpers/mapLifecycleHelper.js — Map init (always adds cluster layer), cleanup, health checks
  • resources/js/views/Maps/helpers/pointsHelper.js — Points view, pagination, stats, abort signals
  • tests/Feature/Map/Clusters/ClusteringTest.php — Core clustering tests
  • tests/Feature/Map/Clusters/ClusteringApiTest.php — API endpoint tests
  • tests/Feature/Map/Clusters/TeamClusteringTest.php — Team clustering tests

Artisan Commands

bash
# Full rebuild
clustering:update --populate       # Backfill NULL tile_keys (50k chunks)
clustering:update --all            # Recluster all global + tile zoom levels
clustering:update --team=5         # Cluster a specific team
clustering:update --all-teams      # Cluster all teams with photos
clustering:update --stats          # Show statistics + integrity check
clustering:update --explain        # Show query execution plan (combine with --all)

# Interactive menu (no flags)
clustering:update                  # Shows choice() menu: all, populate, both, team, all-teams, stats

# Incremental (scheduled every 5 minutes)
clustering:process-dirty           # Process dirty tiles + teams
clustering:process-dirty --limit=100 --team-limit=20

# Diagnostic
clustering:check-migration         # Verify columns, indexes, PK, data integrity

Scheduler (Kernel.php): clustering:process-dirty runs every 5 minutes. clustering:update --all --all-teams runs nightly at 00:10.

Invariants

  1. Global clustering uses verified >= 2. ADMIN_APPROVED and above. Team clustering uses verified >= 1 (tagged, so school students see their uploads on the team map before teacher approval).
  2. PhotoObserver uses two thresholds. Global tile dirty: >= ADMIN_APPROVED. Team dirty: >= VERIFIED.
  3. ClusteringService uses raw SQL, not Eloquent. All clustering queries use DB::statement() with INSERT...SELECT. The Cluster model exists but is not used by the pipeline.
  4. Team clusters are in the same table as global clusters. team_id = 0 for global, team_id = N for team-specific. All global queries MUST filter WHERE team_id = 0.
  5. tile_key must be populated before per-tile clustering works. Always run --populate before --all.
  6. Global sentinel tile key is 4294967295 (UINT max). Global zoom clusters use this value. Per-tile clusters use the actual tile key.

Architecture

Photo saved/deleted
  → PhotoObserver marks tile dirty (if verified >= ADMIN_APPROVED)
  → PhotoObserver marks team dirty (if verified >= VERIFIED and has team_id)
    → clustering:process-dirty (scheduler, every 5 min)
      → ClusteringService::clusterTile()    — one tile across zooms 8-16
      → ClusteringService::clusterTeam()    — one team across zooms 0-16

Nightly full rebuild:
  → clustering:update --all --all-teams

Tile Key Computation

Formula with 0.25° tile size (1440 x 720 grid):

latIndex = FLOOR((lat + 90) / 0.25)
lonIndex = FLOOR((lon + 180) / 0.25)
tileKey  = latIndex * 1440 + lonIndex

Database Schema

Clusters table (composite PK)
sql
PRIMARY KEY (team_id, tile_key, zoom, year, cell_x, cell_y)
team_id       UNSIGNED INT      -- 0 = global, N = team-specific
tile_key      UNSIGNED INT      -- 4294967295 = global sentinel
zoom          INT               -- 0-16
year          SMALLINT UNSIGNED -- 0 = all-time
cell_x, cell_y INT              -- Grid cell coordinates
lat, lon      DOUBLE            -- Centroid
point_count   BIGINT UNSIGNED   -- Photos in cluster
grid_size     DECIMAL(6,3)
Show full SKILL.md (295 more words)Show less
Dirty tiles table
sql
dirty_tiles: tile_key (PK), changed_at, attempts

Uses upsert with backoff: after 3 attempts, changed_at advances by 5 minutes. Auto-cleaned after 24 hours.

Note: dirty_teams table was dropped (2026-03-14). Team clustering is now on-demand only via clustering:update --team=ID or --all-teams.

is_public changes trigger dirty tile marking. PhotoObserver fires dirty tile logic when a photo's is_public changes (e.g. via PATCH /api/v3/photos/{id}/visibility). When a private-by-choice photo is made public (and is verified), its tile is marked dirty so the cluster updates. When a photo is made private, the tile is similarly marked dirty to remove it from future cluster renders.

API Endpoints

  • GET /api/clusters — Public. Params: zoom, bbox[], lat, lon. Returns GeoJSON FeatureCollection with ETag caching (304 support). Limit 5,000 clusters.
  • GET /api/clusters/zoom-levels — Available zoom configurations.
  • GET /api/teams/clusters/{team} — Auth required. Same bbox filtering and GeoJSON format.

Common Mistakes

  • Using verified = 2 instead of verified >= 2. Photos at BBOX_APPLIED (3), BBOX_VERIFIED (4), AI_READY (5) must be included.
  • Forgetting team_id = 0 in global queries. Without this, team clusters leak into public map data.
  • Running --all without --populate first. Photos without tile_key are excluded from per-tile clustering.
  • Assuming the Cluster model is used by the pipeline. ClusteringService uses raw SQL for performance.
  • Scheduling deleted commands. The old clusters:generate-all and clusters:generate-team-clusters are deleted. Use clustering:update and clustering:process-dirty.
  • Not flushing cluster cache after regeneration. clustering:update --all and --all-teams auto-flush clusters:v5:* cache keys. Cache prefix has NO colon separator: openlittermap_cacheclusters:v5:*.
  • Conditionally adding cluster layer to map. mapLifecycleHelper.js ALWAYS adds the clusters GeoJSON layer to the map instance, even when initial fetch returns 0 features. Without this, subsequent cluster loads after panning/zooming don't render.
  • Ignoring params in GET_POINTS(). The store method must destructure and pass page, year, fromDate, toDate, username, signal to the backend. The API returns pagination as page (not current_page) at root level — pointsHelper.getPaginationData() normalizes this.

© OpenLitterMap, GPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .ai/skills/clustering-system of OpenLitterMap/openlittermap-web.

Open the folder on GitHubat commit ac688aa

Compare with similar skills

Clustering System next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Clustering System compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Clustering System this skillOpenLitterMap/openlittermap-web134—~2kAutomated safety check: PassGPL-3.0
Alsacreations Guidelinesalsacreations/kiwipedia338—~900Automated safety check: PassNone
Deploy To Hostinghostinger/api-mcp-server159—~2.7kAutomated safety check: NotesMIT
WooCommerce PHP Performance Patternswoocommerce/woocommerce11k—~395Automated safety check: PassCustom licence
Migrate To Hostinghostinger/api-mcp-server159—~1.8kAutomated safety check: PassMIT
Php SQL Audit0xShe/PHP-Code-Audit-Skill4021 repos~668Automated safety check: PassNone

Similar skills

  • Alsacreations Guidelines

    alsacreations/kiwipedia

    Guidelines techniques et conventions internes d'Alsacréations (Kiwipedia) — HTML, CSS, JavaScript, TypeScript, Vue.js, WordPress, PHP/MySQL, accessibilité, performance, SEO, RGPD, écoconception…

    338 GitHub stars~900 tokensUpdated 18 days ago
    DatabasesAuto-check passed
  • Deploy To Hosting

    hostinger/api-mcp-server

    Deploy an existing project to a website on Hostinger web hosting (Shared, Cloud or Agency plans) and keep it deployed: picks the right deploy for static sites, Node.js apps (Next.js, Nuxt, Express…

    159 GitHub stars~2.7k tokensUpdated yesterday
    DevOps & CloudAuto-check: notes
  • Flags and fixes performance issues in WooCommerce PHP code: missing post cache priming, uncached option lookups in loops, and inefficient SQL query patterns.

    11k GitHub stars~395 tokensUpdated today
    DatabasesAuto-check passed
  • Migrate To Hosting

    hostinger/api-mcp-server

    Move an existing website from another host to Hostinger web hosting (Shared, Cloud or Agency plans) without downtime: WordPress sites from a files archive and SQL dump, static and PHP sites from an…

    159 GitHub stars~1.8k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Php SQL Audit

    0xShe/PHP-Code-Audit-Skill

    PHP Web 源码 SQL 注入漏洞审计工具。从源码中识别所有 SQL 执行点并分析注入风险,输出可利用性分级、PoC 与修复建议(禁止省略)。

    402 GitHub starsUsed in 1 repo~668 tokens
    DatabasesAuto-check passed
  • Error Log Mining

    uphiago/recon-skills

    Mine errorlog for creds, paths, SQL when leak hunt finds. An agent skill from uphiago/recon-skills.

    1.3k GitHub stars~3.3k tokensUpdated 1 mo ago
    SecurityAuto-check passed

More from OpenLitterMap/openlittermap-web

All 16 skills in this repo
  • Tailwindcss Development

    OpenLitterMap/openlittermap-web

    Styles applications using Tailwind CSS v3 utilities. An agent skill from OpenLitterMap/openlittermap-web.

    134 GitHub stars~713 tokensUpdated 23 days ago
    Auto-check passed
  • Olm Architecture

    OpenLitterMap/openlittermap-web

    OpenLitterMap v5 architecture reference. An agent skill from OpenLitterMap/openlittermap-web.

    134 GitHub stars~5.2k tokensUpdated 23 days ago
    Auto-check passed
  • Achievements System

    OpenLitterMap/openlittermap-web

    AchievementEngine, AchievementRepository, milestone checkers, AchievementsSeeder, userachievements pivot, AchievementsController API, and achievement evaluation flow.

    134 GitHub stars~1.4k tokensUpdated 23 days ago
    Auto-check passed
  • Admin System

    OpenLitterMap/openlittermap-web

    AdminController, photo approval, tag editing, deletion, MetricsService integration, admin middleware, verification queue, and admin XP.

    134 GitHub stars~3.9k tokensUpdated 23 days ago
    Auto-check passed
  • API Endpoints

    OpenLitterMap/openlittermap-web

    REST API endpoints, route structure, auth guards, request/response contracts, error patterns, and the full API surface for web SPA and mobile clients.

    134 GitHub stars~4k tokensUpdated 23 days ago
    Auto-check passed
  • Leaderboard System

    OpenLitterMap/openlittermap-web

    LeaderboardController, Redis sorted sets for all-time XP rankings, per-user metrics rows for time-filtered rankings, rewardXpToAdmin, and leaderboard privacy.

    134 GitHub stars~2k tokensUpdated 23 days ago
    Auto-check passed

Works with

Categories

Questions about Clustering System

What does Clustering System do?

ClusteringService, tile keys, dirty tiles/teams, clustering commands, ClusterController GeoJSON API, PhotoObserver dirty marking, and map cluster rendering. Clustering System is an agent skill from OpenLitterMap/openlittermap-web. ClusteringService, tile keys, dirty tiles/teams, clustering commands, ClusterController GeoJSON API, PhotoObserver dirty marking, and map cluster rendering.

When should I use Clustering System?

Clustering System fits situations like: databases work in your project.

How do I install Clustering System in Claude Code?

Run `npx skills add OpenLitterMap/openlittermap-web --skill clustering-system -a claude-code`. Or copy the skill folder (.ai/skills/clustering-system in OpenLitterMap/openlittermap-web) into .claude/skills/clustering-system in your project. Claude Code loads it when a task matches its description.

How do I install Clustering System in Codex?

Run `npx skills add OpenLitterMap/openlittermap-web --skill clustering-system -a codex`. Or copy the skill folder (.ai/skills/clustering-system in OpenLitterMap/openlittermap-web) into .agents/skills/clustering-system in your project. Codex loads it when a task matches its description.

Can I use Clustering System in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add OpenLitterMap/openlittermap-web --skill clustering-system -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/clustering-system, .gemini/skills/clustering-system, .github/skills/clustering-system and .opencode/skills/clustering-system in your project.

What does Clustering System need to run?

SKILL.md names no scripts, command-line tools or credentials: Clustering System is instructions for the agent only.

Does Clustering System access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Clustering System safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Clustering System use?

Clustering System is published under the GPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Clustering System use?

About 2k tokens (SKILL.md is roughly 7.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Clustering System?

Skills that share tags, products or a category with Clustering System: Alsacreations Guidelines (alsacreations/kiwipedia, 338 stars), Deploy To Hosting (hostinger/api-mcp-server, 159 stars), WooCommerce PHP Performance Patterns (woocommerce/woocommerce, 11k stars) and Migrate To Hosting (hostinger/api-mcp-server, 159 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Clustering System?

OpenLitterMap (a GitHub organization) maintains it in OpenLitterMap/openlittermap-web, which has 134 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on September 14, 2026.

Source: OpenLitterMap/openlittermap-web on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.