Console commands
Every screen has a console equivalent, which is what makes Holmes usable in a deploy script or a CI job.
Inspecting the index
# what's in the index, and how much of the site it covers
php craft holmes/index
# run a query and show the working
php craft holmes/index/search "baker street" --site=default
# every index row for one element, diffed against the live content
php craft holmes/index/element 1234
Audits
# quick audit of everything
php craft holmes/audit
# deep, uncapped
php craft holmes/audit --mode=deep --deep-limit=0
# only these checks
php craft holmes/audit --checks=orphaned-rows,unindexed-elements
# audit, then repair everything repairable
php craft holmes/audit --fix
# list registered checks and which are deep-only
php craft holmes/audit/checks
# re-read a stored report by ID
php craft holmes/audit/show 12
Options
| Option | What it does |
|---|---|
--mode | quick or deep. Defaults to the defaultMode setting. |
--deep-limit | Elements loaded per type in a deep pass. 0 for no cap. |
--checks | Comma-separated check handles to run, instead of all enabled ones. |
--fix | Apply every repairable finding after the run. |
--fail-on | Exit non-zero when anything at or above this severity is found. |
Reindexing and repairs
# list element types and their sources, with UIDs
php craft holmes/sync/sources
# reindex one source
php craft holmes/sync/reindex --element-type='craft\elements\Entry' --source=section:<uid>
# reindex everything
php craft holmes/sync/all
# delete rows whose element no longer exists
php craft holmes/sync/orphans
# release stuck reservations, then drain the deferred index queue
php craft holmes/sync/queue
Run holmes/sync/sources first — it prints the exact --source values the reindex command expects.
In CI
--fail-on=critical turns an audit into a build step. Run it after a deploy, after a content migration, or nightly:
# fail the build if anything critical is in the index
php craft holmes/audit --mode=deep --fail-on=critical
A deep audit in CI is worth the minutes it costs: it is the only mode that catches a migration which changed content without reindexing it, which is exactly the class of bug a deploy introduces.
If a deep audit is too slow for every build, a good middle ground is a quick audit on every deploy and a nightly deep one:
# on deploy — seconds, read-only
php craft holmes/audit --fail-on=critical
# nightly — the full comparison
php craft holmes/audit --mode=deep --deep-limit=0 --fail-on=warning
Repairing from a deploy script
holmes/audit --fix is safe to run unattended: every repair goes through Craft’s indexer, and each one rediscovers its own scope rather than trusting the report. The one thing to be deliberate about is holmes/sync/all on a large production site — it queues a reindex of everything, which is a lot of work to start by accident.