Skip to main content
The fastest way is to point your coding agent at the skill. It chooses an approach for your stack, translates the patterns for your database, and tests the result.

Lookup table

To do it yourself, classify each distinct user agent once with the real package, then join the results. Logs hold far fewer distinct user agents than requests, so this is fast, and it gives exactly the same answers as request-time classification.
Load user_agent, category, kind, id, name, operator into a table and join on it:
Re-run it on a schedule to pick up new user agents and dataset updates.

Generated SQL

When a lookup table isn’t practical, generate a CASE expression from the dataset, with one WHEN per pattern:
  1. every agents.json entry, in file order;
  2. then every http-clients.json entry.
Generate it with a script, and regenerate it whenever the dataset changes. Don’t copy patterns by hand. The first three were verified against every example in the dataset.
Logs usually keep only the user agent. That still identifies known agents, crawlers and HTTP clients, but agents that borrow a browser user agent will look like people unless you also logged the Accept header.