cloudflared
AGENTS.md16k starsChanged 3 months agoApache-2.0View on GitHub
Cloudflare's command-line tool and networking daemon written in Go. Production-grade tunneling and network connectivity services used by millions of developers and organizations worldwide. Notes on linting: - .golangci.yaml is configured with new-from-rev and whole-files: true. Touching a file triggers linting of the ENTIRE file, not just the changed hunks. Expect to fix pre-existing issues in files you modify, or add targeted // nolint: <linter> comments with a short justification. - Prefer defer func() { _ = resource.Close() }() over defer…
Trending
More talk lately.about the whole repository
Who's talking about cloudflare/cloudflared
- Homebrew/homebrew-core“go 1.21.0”GitHub · Jun 21, 2023 · 50 reactions
- @giggio.net“A explicação está toda nos docs da Cloudflare. A parte que faz a conexão da VPN está nos docs do Warp. E a …”Bluesky · Aug 12, 2025 · 18 likes
- NixOS/nixpkgs“`cloudflared` build from source uses a custom `go` toolchain”GitHub · Jan 2, 2025 · 18 reactions
- juanfont/headscale“Purpose of non-standard POST method in Websocket handshake?”GitHub · May 15, 2023 · 15 reactions
- anthropics/claude-code“DNS resolution fails in Claude Code Web VM even with Full network access”GitHub · Dec 18, 2025 · 7 reactions
The biggest 5 of 42 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 42
Talked about on GitHub, Bluesky and Hacker News (42 times).
On GitHub · 35
- Jun 21, 2023go 1.21.0 — Homebrew/homebrew-core50 reactions · 28 comments
- Jan 2, 2025`cloudflared` build from source uses a custom `go` toolchain — NixOS/nixpkgs18 reactions
- May 15, 2023Purpose of non-standard POST method in Websocket handshake? — juanfont/headscale15 reactions · 12 comments
- Dec 18, 2025DNS resolution fails in Claude Code Web VM even with Full network access — anthropics/claude-code7 reactions · 6 comments
- Oct 21, 2026cloudflared: 2026.10.1 -> 2026.10.3 — NixOS/nixpkgs6 reactions · 8 comments
30 more on GitHub
- Apr 3, 2025cloudflared: 2025.2.1 -> 2025.4.0 — NixOS/nixpkgs6 reactions · 1 comment
- Mar 16, 2019Install As Service — AdguardTeam/dnsproxy6 reactions · 14 comments
- Feb 5, 2023Add cloudflared — opnsense/tools5 reactions · 11 comments
- May 22, 2021Cloudflare Tunnel (Argo tunnel) as system service in OMV-extras — openmediavault/openmediavault5 reactions · 9 comments
- Aug 5, 2019Updated cloudflared — cloudflare/cloudflare-ingress-controller5 reactions · 8 comments
- Feb 4, 2026[image]: cloudflared — docker-hardened-images/catalog4 reactions
- Jun 4, 2025Add Cloudflared as Tunnel — jetkvm/kvm4 reactions · 7 comments
- Mar 10, 2020failed to connect to an HTTPS backend — visibilityspots/dockerfile-cloudflared4 reactions · 2 comments
- Oct 27, 2026Update Cloudflare Tunnel to 2026.10.4 — getumbrel/umbrel-apps3 reactions · 2 comments
- Jul 7, 2023Install — gbraad-cockpit/cockpit-cloudflared3 reactions · 4 comments
- Jan 30, 2023feat: add cloudflared option — AUTOMATIC1111/stable-diffusion-webui3 reactions · 3 comments
- Apr 1, 2022[cloudflared] Missing spec — withfig/autocomplete3 reactions
- Sep 30, 2026[REC] cloudflared — x-cmd/x-cmd2 reactions · 1 comment
- Feb 11, 2025[cloudflare-one/tutorials] Setup CF Tunnel inside Kubernetes cluster to access Kubernetes API — cloudflare/cloudflare-docs2 reactions · 7 comments
- Feb 3, 2025feature: support cloudflared tunnel as a tunnel driver — tarampampam/webhook-tester2 reactions · 1 comment
- Jan 31, 2025feat: add http2Origin to TunnelBinding subject spec — adyanth/cloudflare-operator2 reactions · 5 comments
- Jan 9, 2025cloudflared: 2024.12.2 -> 2025.2.0 — NixOS/nixpkgs2 reactions · 2 comments
- Dec 19, 2024cloudflared: 2024.11.1 -> 2024.12.2 — NixOS/nixpkgs2 reactions
- Jan 2, 2024Proxy server broken — googlecolab/colabtools2 reactions
- Oct 31, 2026feat(tunnel): open one-time phone links without an ngrok account (#523) — Jongtae/Still1 reaction · 5 comments
- Oct 27, 2026chore(mise): update tool aqua:cloudflare/cloudflared (2026.10.4 ➔ 2026.10.5) — Tanguille/cluster1 reaction · 3 comments
- Oct 27, 2026Security: pin cloudflared to 2026.10.3 for native installs — Agustos-Teknoloji/singleserver1 reaction · 1 comment
- Oct 2, 2026Update Cloudflare Tunnel to 2026.9.3 — getumbrel/umbrel-apps1 reaction · 1 comment
- Sep 23, 2026PR14: Integrate cloudflared service activation and rollback — llit47/cloudflared-manager1 reaction · 4 comments
- Sep 3, 2026Update Cloudflare Tunnel to 2026.8.3 — getumbrel/umbrel-apps1 reaction · 1 comment
- Aug 16, 2026feat(mcp): embed cloudflared in-process as named tunnel — LumeWeb/pinner-cli1 reaction · 3 comments
- Jun 25, 2026chore(cloudflared): bump cloudflared to 2026.6.1 — helmforgedev/charts1 reaction · 2 comments
- Jun 16, 2026chore(cloudflared): bump cloudflared to 2026.6.0 — helmforgedev/charts1 reaction · 2 comments
- May 17, 2026cloudflared: 2026.3.0 -> 2026.5.0 — NixOS/nixpkgs1 reaction · 2 comments
- Aug 9, 2022Update pkg.cloudflare.com urls — typisttech/trellis-cloudflare-origin-ca1 reaction · 8 comments
On Bluesky · 4
- Aug 12, 2025A explicação está toda nos docs da Cloudflare. A parte que faz a conexão da VPN está nos docs do Warp. E a que fala de como expor seu… — @giggio.net18 likes and reposts · 1 reply
- Sep 2, 2025github.com/cloudflare/c... — @coprodu.to3 likes and reposts
- Sep 21, 2025https://github.com/cloudflare/cloudflared — @tom-doerr.bsky.social1 likes and repost
- Mar 3, 2025Don't. if you can run a container (or cloudflared as a process) do that. Then you don't need to open ANY ports inbound, encryption from CF… — @fastchicken.co.nz1 likes and repost · 2 replies
On Hacker News · 3
- Feb 15, 2022Cloudflare Tunnel is now licensed under Apache4 points · 1 comment
- Mar 9, 2026Cloudflare's Agents.md3 points
- Sep 18, 2021Turn cloudflared into an open source project?3 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
39 rules. About 1 is common, 21 are distinctive, and 17 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈21
Distinctive · estimate
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 69
Prefer defer func() { _ = resource.Close() }() over defer resource.Close() for io.Closer values whose error truly does not matter — this …
- Distinctive: line 77
Use meaningful package names that reflect functionality
- Very specific: line 79
Avoid generic names like util, common, helper
- Distinctive: line 114
Always handle errors explicitly, never ignore them
- Very specific: line 115
Use fmt.Errorf for error wrapping
- Distinctive: line 116
Create meaningful error messages with context
- Distinctive: line 117
Use error variables for common errors
- Very specific: line 128
Use github.com/rs/zerolog for structured logging
- Distinctive: line 130
Use appropriate log levels (Debug, Info, Warn, Error)
- Very specific: line 141
Use github.com/stretchr/testify for assertions
- Very specific: line 142
Test files end with _test.go
- Distinctive: line 143
Use table-driven tests for multiple scenarios
- Very specific: line 144
Always use t.Parallel() for parallel-safe tests
- Distinctive: line 145
Use meaningful test names that describe behavior
- Distinctive: line 175
Keep interfaces small and focused
- Distinctive: line 176
Use descriptive names for complex types
- Very specific: line 193
Always accept context.Context as first parameter for long-running operations
- Distinctive: line 199
Use channels for goroutine communication
- Very specific: line 201
Prefer sync.RWMutex for read-heavy workloads
- Very specific: line 213
Do NOT reach for the package-private getCurvePreferences helper.
- Distinctive: line 229
Use structured configuration with validation
- Distinctive: line 236
Use OpenTelemetry for distributed tracing
- Very specific: line 243
Run make test lint before any commit
- Very specific: line 245
Use github.com/rs/zerolog for all logging
- Very specific: line 246
Add t.Parallel() to all parallel-safe tests
- Distinctive: line 247
Follow the import grouping conventions
- Distinctive: line 248
Use meaningful variable and function names
- Distinctive: line 274
If you are asked to remove a flag or similar user-visible interface without a prior notice, do not proceed without explicit confirmation.
- Very specific: line 280
Use generic package names (util, helper, common)
- Very specific: line 281
Commit code that fails make test lint
- Very specific: line 282
Use fmt.Print* instead of structured logging
- Common: line 283
Commit secrets, credentials, or sensitive data
- Distinctive: line 284
Use deprecated or unsafe Go patterns
- Distinctive: line 286
Remove existing tests unless they're genuinely invalid
- Very specific: line 290
Use Go modules (go.mod) exclusively
- Distinctive: line 295
Keep dependencies up-to-date and secure
- Distinctive: line 296
Prefer standard library when possible
- Distinctive: line 311
Graceful shutdown: Always implement proper cleanup
- Distinctive: line 315
Logging consistency: Use structured logging throughout
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.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.
Files
Cloudflared
Cloudflare's command-line tool and networking daemon written in Go. Production-grade tunneling and network connectivity services used by millions of developers and organizations worldwide.
Essential Commands
Build & Test (Always run before commits)
# Full development check (run before any commit)
make test lint
# Build for current platform
make cloudflared
# Run all unit tests with coverage
make test
make cover
# Run specific test
go test -run TestFunctionName ./path/to/package
# Run tests with race detection
go test -race ./...Platform-Specific Builds
# Linux
TARGET_OS=linux TARGET_ARCH=amd64 make cloudflared
# Windows
TARGET_OS=windows TARGET_ARCH=amd64 make cloudflared
# macOS ARM64
TARGET_OS=darwin TARGET_ARCH=arm64 make cloudflared
# FIPS compliant build
FIPS=true make cloudflaredCode Quality & Formatting
# Run linter (38+ enabled linters)
make lint
# Auto-fix formatting
make fmt
gofmt -w .
goimports -w .
# Security scanning
make vet
# Component tests (Python integration tests)
cd component-tests && python -m pytest test_file.py::test_function_nameNotes on linting:
.golangci.yamlis configured withnew-from-revandwhole-files: true. Touching a file triggers linting of the ENTIRE file, not just the changed hunks. Expect to fix pre-existing issues in files you modify, or add targeted// nolint: <linter>comments with a short justification.- Prefer
defer func() { _ = resource.Close() }()overdefer resource.Close()forio.Closervalues whose error truly does not matter — this satisfieserrcheckwithout hiding real failures elsewhere.
Project Knowledge
Package Structure
- Use meaningful package names that reflect functionality
- Package names should be lowercase, single words when possible
- Avoid generic names like
util,common,helper
Well-known shared packages
crypto/: Single source of truth for TLS curve preferences and other cryptographic primitives shared by every edge-facing transport. Import ascfdcrypto "github.com/cloudflare/cloudflared/crypto"to avoid colliding with the standard library'scryptopackage. Do NOT duplicate TLS curve or cipher selection logic in other packages.tlsconfig/: Builds the base*tls.Configused for edge connections (CreateTunnelConfig) and loads origin/CA pools. Curve selection is intentionally NOT set here; it is applied per-connection from thecrypto/package so the same config can be cloned and reused across protocols.features/: Runtime feature flags includingPostQuantumMode(PostQuantumPrefer= default,PostQuantumStrict=--post-quantum).fips/: Build-tag driven FIPS detection. Onlyfips.IsFipsEnabled()is exposed; never branch onfipsEnabledinside a function if the two branches return the same value.
Function and Method Guidelines
// Good: Clear purpose, proper error handling
func (c *Connection) HandleRequest(ctx context.Context, req *http.Request) error {
if req == nil {
return errors.New("request cannot be nil")
}
// Implementation...
return nil
}Error Handling
- Always handle errors explicitly, never ignore them
- Use
fmt.Errorffor error wrapping - Create meaningful error messages with context
- Use error variables for common errors
// Good error handling patterns
if err != nil {
return fmt.Errorf("failed to process connection: %w", err)
}Logging Standards
- Use
github.com/rs/zerologfor structured logging - Include relevant context fields
- Use appropriate log levels (Debug, Info, Warn, Error)
logger.Info().
Str("tunnelID", tunnel.ID).
Int("connIndex", connIndex).
Msg("Connection established")Testing Patterns
- Use
github.com/stretchr/testifyfor assertions - Test files end with
_test.go - Use table-driven tests for multiple scenarios
- Always use
t.Parallel()for parallel-safe tests - Use meaningful test names that describe behavior
func TestMetricsListenerCreation(t *testing.T) {
t.Parallel()
// Test implementation
assert.Equal(t, expected, actual)
require.NoError(t, err)
}Constants and Variables
const (
MaxGracePeriod = time.Minute * 3
MaxConcurrentStreams = math.MaxUint32
LogFieldConnIndex = "connIndex"
)
var (
// Group related variables
switchingProtocolText = fmt.Sprintf("%d %s", http.StatusSwitchingProtocols, http.StatusText(http.StatusSwitchingProtocols))
flushableContentTypes = []string{sseContentType, grpcContentType, sseJsonContentType}
)Type Definitions
- Define interfaces close to their usage
- Keep interfaces small and focused
- Use descriptive names for complex types
type TunnelConnection interface {
Serve(ctx context.Context) error
}
type TunnelProperties struct {
Credentials Credentials
QuickTunnelUrl string
}Key Architectural Patterns
Context Usage
- Always accept
context.Contextas first parameter for long-running operations - Respect context cancellation in loops and blocking operations
- Pass context through call chains
Concurrency
- Use channels for goroutine communication
- Protect shared state with mutexes
- Prefer
sync.RWMutexfor read-heavy workloads *tls.Configvalues stored in shared maps (e.g.TunnelConfig.EdgeTLSConfigs) must beClone()d before mutating per-connection fields likeCurvePreferencesorNextProtos. Writing through the shared pointer races with concurrent connection attempts.
TLS & Post-Quantum key exchange
- Per-connection TLS configuration for edge connections is built via
cfdcrypto.TLSConfigWithCurvePreferences(tlsConfig, pqMode). It clones the provided*tls.Configand setsCurvePreferencesbased onpqMode, so callers never need to clone or mutateCurvePreferencesthemselves. Do NOT reach for the package-privategetCurvePreferenceshelper; the exportedTLSConfigWithCurvePreferencesis the only supported entry point. - Two PQ modes are supported and apply identically to QUIC and HTTP/2:
PostQuantumPrefer(default):[X25519MLKEM768, P256Kyber768Draft00, CurveP256]PostQuantumStrict(--post-quantum):[X25519MLKEM768, P256Kyber768Draft00]
- FIPS and non-FIPS builds use the same curve list. Do NOT reintroduce a
fipsEnabledbranch in curve-selection code; if the two modes ever diverge, express the divergence insidecrypto/so call sites remain untouched. - HTTP/2 supports post-quantum handshakes. Never re-add a
PostQuantumStrict-based rejection to H2 code paths, and never force--post-quantumto select QUIC-only in protocol selection.
Configuration
- Use structured configuration with validation
- Support both file-based and CLI flag configuration
- Provide sensible defaults
Metrics and Observability
- Instrument code with Prometheus metrics
- Use OpenTelemetry for distributed tracing
- Include structured logging with relevant context
Boundaries
✅ Always Do
- Run
make test lintbefore any commit - Handle all errors explicitly with proper context
- Use
github.com/rs/zerologfor all logging - Add
t.Parallel()to all parallel-safe tests - Follow the import grouping conventions
- Use meaningful variable and function names
- Include context.Context for long-running operations
- Close resources in defer statements
⚠️ Ask First Before
- Adding new dependencies to go.mod
- Modifying CI/CD configuration files
- Changing build system or Makefile
- Modifying component test infrastructure
- Adding new linter rules or changing golangci-lint config
- Making breaking changes to public APIs
- Changing logging levels or structured logging fields
Breaking Change Policy
Removing or renaming a CLI flag, environment variable, configuration key, alias, or subcommand is a breaking change and requires advance notice:
- A new entry must be added to the Cloudflare Tunnel changelog and published in a release at least 3 months before the removal takes effect.
- The entry must name every affected flag/alias/env var, state the planned removal date or release, and describe the migration path.
- The actual removal PR must not be merged until that notice has shipped in a released version.
If you are asked to remove a flag or similar user-visible interface without a prior notice, do not proceed without explicit confirmation.
🚫 Never Do
- Ignore errors without explicit handling (
_ = err) - Use generic package names (
util,helper,common) - Commit code that fails
make test lint - Use
fmt.Print*instead of structured logging - Commit secrets, credentials, or sensitive data
- Use deprecated or unsafe Go patterns
- Skip testing for new functionality
- Remove existing tests unless they're genuinely invalid
Dependencies Management
- Use Go modules (
go.mod) exclusively - Resolve dependencies from the locked module graph with
go mod download; do not vendor dependencies. - Builds, tests, vet, and lint use
-mod=readonly;go.modandgo.summust not drift in CI. - Linux CI uses Athens before public and direct module sources; macOS and Windows use the public proxy directly.
- CI caches modules in
$GOMODCACHEand compiled packages in$GOCACHEunder.cache/go/for Go-running jobs. - Keep dependencies up-to-date and secure
- Prefer standard library when possible
- Cloudflared uses a fork of quic-go always check release notes before bumping this dependency.
Security Considerations
- FIPS compliance support available
- Vulnerability scanning integrated in CI
- Credential handling follows security best practices
- Network security with TLS/QUIC protocols
- Regular security audits and updates
- Post quantum encryption
Common Patterns to Follow
- Graceful shutdown: Always implement proper cleanup
- Resource management: Close resources in defer statements
- Error propagation: Wrap errors with meaningful context
- Configuration validation: Validate inputs early
- Logging consistency: Use structured logging throughout
- Testing coverage: Aim for comprehensive test coverage
- Documentation: Comment exported functions and types
Remember: This is a mission-critical networking tool used in production by many organizations. Code quality, security, and reliability are paramount.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

