htmx-go-basic-cursorrules-prompt-file — Cursor rule
Guides Cursor when building Go web apps with HTMX. Enforces standard project layout, html/template rendering, and idiomatic request handling.
.cursor/rules/htmx-go-basic-cursorrules-prompt-file.mdcWhat htmx-go-basic-cursorrules-prompt-file does
This rule instructs Cursor on creating a Go backend paired with HTMX. It establishes an explicit folder structure: entry point in cmd/main.go, internal application packages under internal/handlers, internal/models, and internal/templates, plus assets inside static.
Server-side rendering relies on the standard html/template library, while JSON responses use encoding/json. For HTTP routing, the prompt expects http.HandlerFunc or gorilla/mux. It also mandates request cancellation through context, server graceful shutdown, CSRF defenses, and hx-boost for navigation. The setup depends on standard Go modules and avoids heavy full-stack frameworks.
What it helps with
- Organize a Go and HTMX codebase using
cmd,internal, andstaticdirectories - Render HTML fragments using the standard
html/templatepackage - Handle HTMX requests with
http.HandlerFuncand route viagorilla/mux - Configure graceful server shutdown with
contexttimeouts - Add CSRF protection and full-page transitions with
hx-boost
Example prompts for the agent
- Create a new handler in
internal/handlers/that returns an HTML snippet for an HTMX request - Add graceful shutdown to
cmd/main.gousing signal handling and context - Build an HTML template in
internal/templates/with semantic tags andhx-boostnavigation
How to install htmx-go-basic-cursorrules-prompt-file
Manually: put the files in place
.cursor/rules/htmx-go-basic-cursorrules-prompt-file.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/htmx-go-basic-cursorrules-prompt-file.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/htmx-go-basic-cursorrules-prompt-file.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/htmx-go-basic-cursorrules-prompt-file.mdManually: put the files in place
.clinerules/htmx-go-basic-cursorrules-prompt-file.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about htmx-go-basic-cursorrules-prompt-file
How do I install htmx-go-basic-cursorrules-prompt-file in Cursor?
Save the rule file to .cursor/rules/htmx-go-basic-cursorrules-prompt-file.mdc in your repository.
What does htmx-go-basic-cursorrules-prompt-file do?
It sets code conventions for Go and HTMX projects, detailing the directory layout, template rendering, and error handling for the assistant.
Which router and template engine does this rule specify?
It directs Cursor to use Go's standard html/template package for rendering and http.HandlerFunc with optional gorilla/mux routing.
Source text
htmx-go-basic-cursorrules-prompt-file.mdc · CC0-1.0
--- description: "Cursor rules for Go development with basic setup." globs: **/* alwaysApply: false --- // HTMX with Go (Basic Setup) .cursorrules // HTMX and Go best practices const htmxGoBestPractices = [ "Use html/template for server-side rendering", "Implement http.HandlerFunc for handling HTMX requests", "Utilize gorilla/mux for routing if needed", "Use encoding/json for JSON responses", "Implement proper error handling and logging", "Utilize context for request cancellation and timeouts", ]; // Folder structure const folderStructure = ` cmd/ main.go internal/ handlers/ models/ templates/ static/ css/ js/ go.mod go.sum `; // Additional instructions const additionalInstructions = ` 1. Use semantic HTML5 elements with HTMX attributes 2. Implement proper CSRF protection 3. Utilize HTMX extensions when needed 4. Use hx-boost for full page navigation 5. Follow Go's idiomatic error handling 6. Implement graceful shutdown for the server 7. Use Go modules for dependency management `;
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules