agentleFS
MindrallyMindrally/skills/go-api-development/SKILL.md

go-api-development

Skill266 starsChanged 10 months agoApache-2.0View on GitHub

Go API development guidelines using the standard library (1.22+) with best practices for RESTful API design, error handling, and security

The file

Show its rules and text

We split this skill into the rules it gives an agent

21 rules. About 0 are common, 19 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈19

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always use the latest stable version of Go (1.22 or newer) and be familiar with RESTful API design principles, net/http package, and the …

    line 10
  2. Distinctive:

    Follow the user's requirements carefully and to the letter

    line 11
  3. Distinctive:

    Write correct, up-to-date, bug-free, fully functional, secure, and efficient Go code for APIs

    line 13
  4. Distinctive:

    Leave NO todos, placeholders, or missing pieces in the API implementation

    line 14
  5. Distinctive:

    Always prioritize security, scalability, and maintainability in your API designs

    line 15
  6. Very specific:

    Use the new http.ServeMux introduced in Go 1.22 for routing

    line 21
  7. Distinctive:

    Use appropriate HTTP status codes for responses

    line 23
  8. Distinctive:

    Use structured error responses in JSON format

    line 30
  9. Very specific:

    Use encoding/json for JSON serialization/deserialization

    line 42
  10. Distinctive:

    Use appropriate JSON formatting for responses

    line 45
  11. Distinctive:

    Use goroutines for concurrent operations where beneficial

    line 50
  12. Distinctive:

    Use context for request cancellation and timeouts

    line 52
  13. Distinctive:

    Use middleware chaining for composable request processing

    line 57
  14. Distinctive:

    Add request/response logging middleware

    line 59
  15. Distinctive:

    Use HTTPS in production

    line 64
  16. Distinctive:

    Use secure defaults for cookies and sessions

    line 67
  17. Distinctive:

    Use standard library logging with structured output

    line 71
  18. Distinctive:

    Avoid logging sensitive information

    line 73
  19. Distinctive:

    Use log levels appropriately

    line 74
  20. Distinctive:

    Write unit tests for handlers and business logic

    line 78
  21. Distinctive:

    Use table-driven tests where appropriate

    line 80

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Go API Development with Standard Library

Core Principles

  • Always use the latest stable version of Go (1.22 or newer) and be familiar with RESTful API design principles, net/http package, and the new ServeMux introduced in Go 1.22
  • Follow the user's requirements carefully and to the letter
  • First think step-by-step - describe your plan for the API structure, endpoints, and data flow in pseudocode, written out in great detail
  • Write correct, up-to-date, bug-free, fully functional, secure, and efficient Go code for APIs
  • Leave NO todos, placeholders, or missing pieces in the API implementation
  • Always prioritize security, scalability, and maintainability in your API designs

API Development Guidelines

Routing and HTTP Handling

  • Use the new http.ServeMux introduced in Go 1.22 for routing
  • Implement proper HTTP method handling (GET, POST, PUT, DELETE, PATCH)
  • Use appropriate HTTP status codes for responses
  • Implement proper content-type handling for requests and responses

Error Handling

  • Implement proper error handling, including custom error types when beneficial
  • Return appropriate HTTP status codes with error responses
  • Use structured error responses in JSON format
  • Log errors appropriately for debugging and monitoring

Input Validation

  • Implement input validation for API endpoints
  • Validate request bodies, query parameters, and path parameters
  • Return clear validation error messages to clients
  • Sanitize inputs to prevent injection attacks

JSON Handling

  • Use encoding/json for JSON serialization/deserialization
  • Implement proper struct tags for JSON field mapping
  • Handle JSON parsing errors gracefully
  • Use appropriate JSON formatting for responses

Concurrency

  • Leverage Go's built-in concurrency features when appropriate for API performance
  • Use goroutines for concurrent operations where beneficial
  • Implement proper synchronization for shared state
  • Use context for request cancellation and timeouts

Middleware

  • Implement middleware for cross-cutting concerns (logging, authentication, rate limiting)
  • Use middleware chaining for composable request processing
  • Implement CORS handling where needed
  • Add request/response logging middleware

Security

  • Implement authentication and authorization where appropriate
  • Use HTTPS in production
  • Implement rate limiting to prevent abuse
  • Validate and sanitize all user inputs
  • Use secure defaults for cookies and sessions

Logging

  • Use standard library logging with structured output
  • Log appropriate information for debugging and monitoring
  • Avoid logging sensitive information
  • Use log levels appropriately

Testing

  • Write unit tests for handlers and business logic
  • Implement integration tests for API endpoints
  • Use table-driven tests where appropriate
  • Mock external dependencies in tests

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.