cloudflare
Cloudflare Pages and Workers: valid headers and redirects files and current binding types. Level all adds security rules for worker code. It requires javascript.
Selected when
Section titled “Selected when”A scope has filenames wrangler.toml, wrangler.json, wrangler.jsonc, or _worker.js, or a dependency on wrangler or @opennextjs/cloudflare, or a file path **/functions/_middleware.{js,ts}.
Checks
Section titled “Checks”headers
Section titled “headers”Checks that _headers holds only blocks of a path followed by indented name-value lines, and that the /* block sets X-Content-Type-Options, Referrer-Policy, and X-Frame-Options or a CSP frame-ancestors.
Runs at the commit stage, once per scope.
Cloudflare skips a line it cannot read, and a static site has no server code to set these protections, so a typo or a missing line silently drops a security header.
What to do
Section titled “What to do”Write each block as a path, then indented lines of a name, a colon, and a value. Add each missing security header to the block for /*.
Example
Section titled “Example”An indented X-Frame-Options: DENY at the top of _headers reports a header with no path. Put a path such as /* on an unindented line above it.
Lint rules
Section titled “Lint rules”| Rule | What it checks | What to do |
|---|---|---|
missing-header |
The /* block of _headers sets X-Content-Type-Options: nosniff, a Referrer-Policy, and X-Frame-Options or a frame-ancestors policy. |
Add the missing headers to the /* block. |
syntax |
A file that the check reads parses without errors. | Fix the syntax at the reported line. |
Turn it off
Section titled “Turn it off”gspot ignore cloudflare/headers --paths "<path>" --reason "<why>"gspot ignore cloudflare/headers --rule missing-header --reason "<why>"redirects
Section titled “redirects”Checks each redirect source, destination, and optional status: 200, 301, 302, 303, 307, or 308, without a force suffix.
Runs at the commit stage, once per scope.
Cloudflare drops a redirect it cannot parse, and the old address starts to answer 404.
What to do
Section titled “What to do”Write the rule as source, destination, and status.
Example
Section titled “Example”The _redirects line /old /new 999 reports an unsupported redirect status. For a permanent redirect, change it to /old /new 301.
Turn it off
Section titled “Turn it off”gspot ignore cloudflare/redirects --paths "<path>" --reason "<why>"stale-types
Section titled “stale-types”Checks that the environment types file, when the scope has one, is tracked and matches what wrangler writes.
Runs at the push stage, once per scope, with wrangler.
Stale binding types let code compile against a binding the configuration dropped.
What to do
Section titled “What to do”Run wrangler types and commit the file.
Example
Section titled “Example”A Worker types file that differs from the output of wrangler types reports drift. Run wrangler types, and commit the new file.
Lint rules
Section titled “Lint rules”| Rule | What it checks | What to do |
|---|---|---|
stale |
Each committed file holds what the generator command writes now. | Run the generator command, and commit the new file after you read the diff. |
missing |
Each file that the check compares with the generator output exists. | Run the generator command, then add the file to Git. |
untracked |
Git tracks each file that the generator writes. | Add the file with git add, and commit it. |
Turn it off
Section titled “Turn it off”gspot ignore cloudflare/stale-types --paths "<path>" --reason "<why>"gspot ignore cloudflare/stale-types --rule stale --reason "<why>"Settings
Section titled “Settings”| Setting | What it sets |
|---|---|
cloudflare.types_file |
The committed file that holds the Worker types. gspot sets it to cloudflare-env.d.ts in an OpenNext project. |
cloudflare.types_interface |
The environment interface name that wrangler types writes. gspot sets it to CloudflareEnv in an OpenNext project. |
Rules for coding agents
Section titled “Rules for coding agents”| Rule file | Installed when |
|---|---|
.gspot/rules/CLOUDFLARE.md |
Always |
Tools and versions
Section titled “Tools and versions”| Tool | Version |
|---|---|
| wrangler | 3.78.3 or later, install it yourself |
Paths that must stay out of Git
Section titled “Paths that must stay out of Git”**/.wrangler/**. repository/local-files reports a tracked file at these paths.