Using pageslens with an agent
pageslens gives the facts; a coding agent can explain them and propose fixes. Point your agent at this page, or paste it into your AGENTS.md or CLAUDE.md. So that an agent knows pageslens is there at all, one line in AGENTS.md is enough:
The Power Pages site is in `site/`. Check it with pageslens (`npx pageslens`): see https://pageslens.olashyn.dev/guides/agents/Running pageslens
Section titled “Running pageslens”- Run
npx pageslenswhen the project haspageslensin its dependencies, so the agent runs the version CI runs. Otherwise runnpx -y pageslens@<version>, with the version CI uses. - Read
--format json(lint,test,diff,align), not the text output, and check thatversionis1. pageslens explain <rule>prints why a lint rule matters and how to fix it.pageslens explainlists the rules.
Working rules
Section titled “Working rules”- pageslens decides. Whether something is a finding, whether a change is wider, whether a statement passes: that’s in its output, so don’t reclassify it. Say why a change may be intended and what a reviewer should check.
- Work offline, from the files in git. Don’t connect to Dataverse, run
pac, upload, post, commit or push. - Find records by GUID (
recordId), not by file name. Don’t change a record’s own id. Pointing a record at another one (a permission’s parent, its web roles) is a fix like any other: say what it does to access. - A value marked
unknowncomes from an environment variable, which a download doesn’t have. Say it can’t be known offline; don’t guess. If the repository has deployment settings files, run again with--settingsfor the stage in question. - Check every fix: run
lint(andtest, with a policy file) again, anddiff HEAD <site>to see what the edits do to access. Undo a fix that adds an error or a warning. A fix can leave an info finding behind as its expected result (a role nothing uses any more): say so.
Review a site
Section titled “Review a site”- Run
lint --format json,test --format jsonwhen there’s apageslens.policy.yaml, andalign <site> <solution> --format jsonwhen you’re given a solution folder. - Group the findings by rule, errors first. Run
explainfor each rule and open the files the findings point at. - Explain each group in the site’s terms: which role, which table, who could do what.
- Propose fixes one rule at a time, as edits to the site’s YAML. Where the fix is a choice (narrow the access, or keep it with an
ignoreentry and areasoninpageslens.config.yaml), offer both. - Apply a rule’s fixes when the user says yes. A fix that
diffshows as wider needs its own yes, even when the user asked for every error to be fixed. Then runlintagain and show what’s left. Don’t edit the solution folder: fix the site in dev, then take both snapshots again.
Review a pull request’s access changes
Section titled “Review a pull request’s access changes”- Run
diff <base> HEAD --site <path> --merge-base --format json, with the pull request’s base branch as<base>. - If there are no changes, say so and stop.
- For each wider change, open its
sourceson both sides (git show <commit>:<file>) and the commits that touched them. Say what the author likely meant and what a reviewer should check, and say when the change is also a lint finding (lint). - Give narrower and neutral changes one line each.
- Write the review in the chat. Don’t post it: the GitHub Action already posts the access changes.
Write narrative docs
Section titled “Write narrative docs”- Run
docs <path> --out <dir>. - Read the generated pages, the site’s pages and templates, and the git log, to work out what each web role, table and page is for.
- Write
about.mdin<dir>. Start it with a line saying an agent wrote it and a person should check it. Give each record’s kind, GUID and name in an HTML comment (<!-- webrole <guid> Asset Manager -->), so a later run finds new, renamed and removed records and keeps what a person wrote. - Don’t edit the generated pages:
docsrewrites them on every run.