Go Interfaces
Automates Go interface implementation generation based on specified methods, reducing boilerplate code and ensuring consistency.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add go-interfaces npx -- -y @trustedskills/go-interfaces
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"go-interfaces": {
"command": "npx",
"args": [
"-y",
"@trustedskills/go-interfaces"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
This skill helps Go developers automate and improve their use of interfaces. It provides scripts to ensure compliance with interface contracts, promotes best practices for defining interfaces in consuming packages rather than implementing ones, and encourages returning concrete types from constructors. The goal is to reduce boilerplate code, maintain consistency, and enhance the flexibility of Go projects by hiding implementation details.
When to use it
- When you need to verify that your Go code correctly implements exported interfaces.
- To enforce a design pattern where consuming packages define interfaces rather than implementing ones.
- When refactoring existing Go code to improve modularity and reduce dependencies.
- To ensure safe type assertions using the comma-ok idiom, preventing runtime panics.
Key capabilities
- Interface Compliance Checking: The
check-interface-compliance.shscript identifies exported interfaces that lack compile-time compliance checks (usingvar _ I = (*T)(nil)). - Interface Placement Guidance: Provides recommendations on defining interfaces in consuming packages, not implementing ones.
- Concrete Type Return Encouragement: Promotes returning concrete types (structs or pointers) from constructors to allow for future method additions without refactoring.
- Implementation Hiding: Suggests returning interfaces from constructors to hide implementation details and enable algorithm substitution.
- Safe Type Assertions: Emphasizes the use of the comma-ok idiom (
value.(string), ok) to safely check type assertions and avoid runtime panics.
Example prompts
Since this is a code generation/analysis skill, there are no direct user prompts. However, you would invoke it via command line:
bash scripts/check-interface-compliance.sh --help(to see options for the compliance check script)- (During development) Reviewing the recommendations on interface placement and concrete type return when designing Go packages.
Tips & gotchas
- This skill focuses on code analysis and guidance, not automatic generation of interfaces or implementations.
- The
check-interface-compliance.shscript requires a working Bash environment. - Follow the provided guidelines regarding interface placement to avoid unnecessary complexity and improve maintainability.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.