Skip to main content
rule

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.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/htmx-go-basic-cursorrules-prompt-file.mdc
Open on GitHub

What 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, and static directories
  • Render HTML fragments using the standard html/template package
  • Handle HTMX requests with http.HandlerFunc and route via gorilla/mux
  • Configure graceful server shutdown with context timeouts
  • 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.go using signal handling and context
  • Build an HTML template in internal/templates/ with semantic tags and hx-boost navigation

How to install htmx-go-basic-cursorrules-prompt-file

Manually: put the files in place

.cursor/rules/htmx-go-basic-cursorrules-prompt-file.mdc

Frontmatter: description, globs, alwaysApply

Step 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

Similar IDE rules

All IDE rules for Backend and APIs →

From the same set210

javascript-chrome-apis-cursorrules-prompt-file A Cursor rule that points the AI agent at Chrome extension work: manifest, architecture, Chrome API usage. ★ 41,024repo stars javascript-astro-tailwind-css-cursorrules-prompt-f Cursor rule for Astro and Tailwind CSS projects. Enforces clean component composition, static page generation, and disciplined island hydration. ★ 41,024repo stars java-springboot-jpa-cursorrules-prompt-file This rule guides Cursor when building Java Spring Boot projects with JPA, DTOs, and layered APIs. Use it when generated code should follow a fixed structure. ★ 41,024repo stars htmx-go-fiber-cursorrules-prompt-file A Cursor rule for Go projects built on Fiber with HTMX: it pins down folder layout, routing and template rendering so the agent stops improvising. ★ 41,024repo stars htmx-flask-cursorrules-prompt-file A Cursor rule for HTMX projects built with Flask. It sets guidance for templates, forms, routes, database access, and project layout. ★ 41,024repo stars htmx-django-cursorrules-prompt-file A Cursor rule that keeps the agent on Django rails while it writes HTMX code: templates, forms, CSRF, class-based views. ★ 41,024repo stars htmx-basic-cursorrules-prompt-file Guides Cursor when building HTMX interfaces with server templates, clean folder layouts around app.py, and standard request attributes. ★ 41,024repo stars html-tailwind-css-javascript-cursorrules-prompt-fi A Cursor rule for HTML, Tailwind CSS, and vanilla JavaScript work. Use it when an agent needs clear coding constraints for frontend files. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor