agentleFS
serbanghitaserbanghita/Mobile-Detect/CLAUDE.md

Mobile-Detect

CLAUDE.md11k starsChanged 3 years agoMITView on GitHub

Whenever you find a new rule that applies to this project, add it to this file. PHP library (Detection\MobileDetect) for detecting mobile devices/tablets via User-Agent strings and HTTP headers. Requires PHP >= 8.0. PSR-12 code style. Every time you run a performance review (ad-hoc benchmarking, before a release, after touching a hot path, or at the end of a perf-oriented PR), append a new dated section to PERFORMANCE.md using the template block at the bottom of that file. Do not…

We split this CLAUDE.md 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:

    Every time you run a performance review (ad-hoc benchmarking, before a release, after touching a hot path, or at the end of a perf-oriented …

    line 36

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md 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
CLAUDE.md

CLAUDE.md

Whenever you find a new rule that applies to this project, add it to this file.

Project

PHP library (Detection\MobileDetect) for detecting mobile devices/tablets via User-Agent strings and HTTP headers. Requires PHP >= 8.0. PSR-12 code style.

Branch & Release

  • Active branch: 4.x (rolling — one branch per major). Always rebase into 4.x (not main or master). Tags follow <major>.<minor>.<patch>.
  • On new tag: update @version docblock + $VERSION property in src/MobileDetect.php, and version in MobileDetect.json.

Commands

# Tests
vendor/bin/phpunit -v -c tests/phpunit.xml
vendor/bin/phpunit -v -c tests/phpunit.xml --filter testMethodName

# Lint + static analysis
vendor/bin/phpcs
vendor/bin/php-cs-fixer fix
vendor/bin/phpstan analyse --memory-limit=1G --level 3 src tests

# Benchmark (defaults live in /phpbench.json and per-method @Revs/@Iterations)
composer bench                # aggregate report
composer bench:baseline       # stores tag=baseline + phpbench-baseline.xml
composer bench:compare        # runs with --ref=baseline, enforces 2% @Assert
# Advisory CI: .github/workflows/4.x-bench.yml runs on every PR to 4.x,
# uploads artifacts, and posts a PR comment. Does not block merge.

Performance reviews

Every time you run a performance review (ad-hoc benchmarking, before a release, after touching a hot path, or at the end of a perf-oriented PR), append a new dated section to PERFORMANCE.md using the template block at the bottom of that file. Do not edit prior sections — they are a historical record for regression comparison.

Minimum contents per section: branch/commit, PHP image, host, phpbench config, the full aggregate table (13 subjects today), and a short notes list interpreting what's surprising or actionable in the numbers.

Architecture

src/
  MobileDetect.php          # Core class: regex patterns, isMobile(), isTablet(), is(), version(), magic isXXXX() via __call
  MobileDetectStandalone.php # Non-Composer wrapper (loads standalone/ autoloader)
  Cache/Cache.php            # In-memory PSR-16 cache with TTL
  Exception/                 # MobileDetectException + error codes
tests/
  providers/vendors/*.php    # UA fixture arrays per vendor (Apple, Samsung, etc.)
  UserAgentTest.php          # Data-driven tests from vendor fixtures
  MobileDetectGeneralTest.php # Core logic tests
  CacheTest.php, MobileDetectWithCacheTest.php, MobileDetectExceptionTest.php
  Benchmark/MobileDetectBench.php   # PHPBench suite (PSR-4: DetectionTests\Benchmark)

Key Patterns

  • Detection results are cached via PSR-16 (CacheInterface). Default: in-memory Cache. Cache keys use sha1 by default.
  • $_SERVER HTTP headers auto-initialized unless autoInitOfHttpHeaders config is false.
  • CloudFront headers (HTTP_CLOUDFRONT_IS_MOBILE_VIEWER, etc.) are recognized for AWS detection.
  • Magic isXXXX() calls dispatch through __call -> is() -> match() against static regex arrays ($phoneDevices, $tabletDevices, $operatingSystems, $browsers).

Download now (ZIP)

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 2 mentionsFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 5 mentionsMay 2026: 19 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the serbanghita/Mobile-Detect repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about serbanghita/Mobile-Detect

The biggest 5 of 84 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 84

Talked about on GitHub, Stack Overflow and the web (84 times).

On GitHub · 50

45 more on GitHub

On Stack Overflow · 30

25 more on Stack Overflow

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

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.