بنقرة واحدة
go
Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Create structured analyses with numbered findings, execution plans, and task materialization
Author a rulebook task spec interactively — research, draft, ask the user clarifying questions, confirm, then create the tasks in rulebook ready for /rulebook-driver. Use when the user wants to plan/spec a feature before implementing.
Spec-driven task management for features and breaking changes with OpenSpec-compatible format
Tool: Anthropic Claude Code CLI (`npm install -g @anthropic-ai/claude-code`)
Behavioral guidelines to reduce common LLM coding mistakes — overcomplication, sloppy refactors, hidden assumptions, weak goals. Use when writing, reviewing, or refactoring code. Auto-applies; invoke explicitly via /karpathy-guidelines or 'follow karpathy discipline'.
Accessibility audit for WCAG compliance and usability
استنادا إلى تصنيف SOC المهني
| name | Go |
| description | Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow). |
| version | 1.0.0 |
| category | languages |
| author | Rulebook |
| tags | ["languages","language"] |
| dependencies | [] |
| conflicts | [] |
CRITICAL: Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
# Complete quality check sequence:
gofmt -l . # Format check (should be empty)
golangci-lint run # Linting
go vet ./... # Static analysis
go test ./... -v -race -coverprofile=coverage.out # Tests + race detection
go tool cover -func=coverage.out # Coverage (95%+ required)
go build ./... # Build verification
# Security audit:
go list -json -m all | nancy sleuth # Vulnerability scan
go list -u -m all # Check outdated deps
CRITICAL: Use Go 1.21+ for modern features and performance.
gofmt or goimports for code formattinggofmt -w .gofmt -l . | wc -l should be 0golangci-lint with recommended linters.golangci.ymlExample .golangci.yml:
linters:
enable:
- govet
- errcheck
- staticcheck
- gosimple
- unused
- gosec
- gocyclo
- gofmt
- goimports
linters-settings:
gocyclo:
min-complexity: 15
govet:
check-shadowing: true
issues:
exclude-use-default: false
*_test.go files in same packaget.Run() for organized testsExample test structure:
package mypackage
import (
"testing"
)
func TestMyFunction(t *testing.T) {
tests := []struct {
name string
input string
want string
wantErr bool
}{
{"valid input", "test", "TEST", false},
{"empty input", "", "", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := MyFunction(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("MyFunction() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("MyFunction() = %v, want %v", got, tt.want)
}
})
}
}
CRITICAL: Tests must be categorized based on execution time and dependencies.
Tests that require active servers, databases, or external services must be isolated using build tags.
Implementation:
// +build s2s
package mypackage
import (
"testing"
"os"
)
func TestDatabaseConnection(t *testing.T) {
// Requires active database server
if os.Getenv("RUN_S2S_TESTS") == "" {
t.Skip("S2S tests disabled. Set RUN_S2S_TESTS=1 to enable.")
}
db := connectToDatabase()
// ... test implementation
}
func TestAPIIntegration(t *testing.T) {
// Requires active API server
if os.Getenv("RUN_S2S_TESTS") == "" {
t.Skip("S2S tests disabled. Set RUN_S2S_TESTS=1 to enable.")
}
client := createAPIClient()
// ... test implementation
}
// Regular fast test (always runs)
package mypackage
import "testing"
func TestLocalComputation(t *testing.T) {
// Fast test, no external dependencies
result := computeLocally("input")
if result != "expected" {
t.Errorf("Expected 'expected', got %v", result)
}
}
# Regular tests (excludes S2S)
go test ./...
# Include S2S tests (requires active servers)
RUN_S2S_TESTS=1 go test -tags s2s ./...
# Run only S2S tests
RUN_S2S_TESTS=1 go test -tags s2s ./... -run TestDatabase
Tests that take > 10-20 seconds must be marked and run separately.
Implementation:
// +build slow
package mypackage
import (
"testing"
"time"
)
func TestHeavyComputation(t *testing.T) {
// Takes 30+ seconds
start := time.Now()
result := processLargeDataset()
duration := time.Since(start)
if result == nil {
t.Error("Expected result, got nil")
}
t.Logf("Test completed in %v", duration)
}
func TestLargeFileProcessing(t *testing.T) {
// Processes large files, takes > 20 seconds
result := processFile("large_file.dat")
if !result.Success {
t.Error("File processing failed")
}
}
package mypackage
import (
"os"
"testing"
)
func TestHeavyComputation(t *testing.T) {
if os.Getenv("RUN_SLOW_TESTS") == "" {
t.Skip("Slow tests disabled. Set RUN_SLOW_TESTS=1 to enable.")
}
// Heavy computation test
}
# Regular tests (excludes slow and S2S)
go test ./...
# Include slow tests
RUN_SLOW_TESTS=1 go test -tags slow ./...
# Run both S2S and slow tests
RUN_S2S_TESTS=1 RUN_SLOW_TESTS=1 go test -tags "s2s slow" ./...
.PHONY: test test-s2s test-slow test-all
test:
go test ./...
test-s2s:
RUN_S2S_TESTS=1 go test -tags s2s ./...
test-slow:
RUN_SLOW_TESTS=1 go test -tags slow ./...
test-all:
RUN_S2S_TESTS=1 RUN_SLOW_TESTS=1 go test -tags "s2s slow" ./...
func TestWithTimeout(t *testing.T) {
done := make(chan bool)
go func() {
// Long-running test
result := heavyOperation()
done <- (result != nil)
}()
select {
case success := <-done:
if !success {
t.Error("Test failed")
}
case <-time.After(60 * time.Second):
t.Fatal("Test timeout after 60 seconds")
}
}
// +build s2s and // +build slowRUN_S2S_TESTS and RUN_SLOW_TESTStime.After() or context.WithTimeout() for long-running testst.Skip() when services are unavailableCRITICAL: Use Go modules for dependency management.
# Initialize module
go mod init github.com/username/project
# Add dependency
go get github.com/package/name@latest
# Update dependencies
go get -u ./...
go mod tidy
# Verify dependencies
go mod verify
Check for latest versions:
Version Selection:
go mod tidy to remove unusedfmt.Errorffmt.Errorf("operation failed: %w", err)errors.Is() and errors.As() for error checkingExample:
package mypackage
import (
"errors"
"fmt"
)
var (
ErrInvalidInput = errors.New("invalid input")
ErrNotFound = errors.New("not found")
)
func ProcessData(input string) (string, error) {
if input == "" {
return "", fmt.Errorf("process data: %w", ErrInvalidInput)
}
result, err := doSomething(input)
if err != nil {
return "", fmt.Errorf("failed to process: %w", err)
}
return result, nil
}
go doc -allExample:
// Package auth provides authentication and authorization utilities.
//
// This package implements JWT-based authentication following OAuth 2.0
// standards. All functions are thread-safe.
package auth
// Authenticate verifies user credentials and returns a JWT token.
//
// The token is valid for 24 hours and includes the user's ID and roles.
//
// Example:
//
// token, err := Authenticate("user@example.com", "password")
// if err != nil {
// log.Fatal(err)
// }
// fmt.Println("Token:", token)
//
// Returns an error if credentials are invalid or database is unreachable.
func Authenticate(email, password string) (string, error) {
// Implementation
return "", nil
}
project/
├── go.mod # Module definition
├── go.sum # Dependency checksums (commit this)
├── README.md # Project overview (allowed in root)
├── CHANGELOG.md # Version history (allowed in root)
├── AGENTS.md # AI assistant rules (allowed in root)
├── LICENSE # Project license (allowed in root)
├── CONTRIBUTING.md # Contribution guidelines (allowed in root)
├── CODE_OF_CONDUCT.md # Code of conduct (allowed in root)
├── SECURITY.md # Security policy (allowed in root)
├── cmd/
│ └── myapp/
│ └── main.go # Application entry point
├── internal/ # Private packages
│ └── module/
│ ├── module.go
│ └── module_test.go
├── pkg/ # Public packages
│ └── api/
│ ├── api.go
│ └── api_test.go
├── tests/ # Integration tests
└── docs/ # Documentation
sync.WaitGroup for synchronizationExample:
func ProcessConcurrently(items []string) ([]Result, error) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
results := make(chan Result, len(items))
errors := make(chan error, len(items))
var wg sync.WaitGroup
for _, item := range items {
wg.Add(1)
go func(item string) {
defer wg.Done()
select {
case <-ctx.Done():
errors <- ctx.Err()
return
default:
result, err := processItem(item)
if err != nil {
errors <- err
return
}
results <- result
}
}(item)
}
wg.Wait()
close(results)
close(errors)
// Collect results
var finalResults []Result
for r := range results {
finalResults = append(finalResults, r)
}
// Check for errors
for err := range errors {
if err != nil {
return nil, err
}
}
return finalResults, nil
}
Must include GitHub Actions workflows for:
Testing (go-test.yml):
Linting (go-lint.yml):
gofmt -l .golangci-lint rungo vet ./...Build (go-build.yml):
go build ./...Go modules are published via Git tags and automatically indexed by pkg.go.dev.
Prerequisites:
go.mod Configuration:
module github.com/your-org/your-module
go 1.22
require (
github.com/example/dependency v1.2.3
)
Publishing Workflow:
Ensure go.mod is correct:
go mod tidy
go mod verify
Run quality checks:
go fmt ./...
go vet ./...
golangci-lint run
go test -v -race ./...
Create semantic version tag:
git tag v1.0.0
git push origin v1.0.0
pkg.go.dev automatically indexes the module
Verify at: https://pkg.go.dev/github.com/your-org/your-module@v1.0.0
Publishing Checklist:
go test ./...)go test -race ./...)go fmt ./...)go vet ./...)go mod tidy)Semantic Versioning:
Go uses semantic versioning strictly:
Major Version Updates (v2+):
For v2 and above, update module path:
// go.mod
module github.com/your-org/your-module/v2
go 1.22
Module Documentation:
Write godoc-compatible comments:
// Package yourmodule provides functionality for X, Y, and Z.
//
// Basic usage:
//
// import "github.com/your-org/your-module"
//
// result, err := yourmodule.Process("input")
// if err != nil {
// log.Fatal(err)
// }
package yourmodule
// Process handles the input and returns a result.
//
// Example:
//
// result, err := Process("hello")
// if err != nil {
// return err
// }
// fmt.Println(result)
func Process(input string) (string, error) {
// Implementation
}
GOPROXY:
Go modules are automatically cached in public proxies:
No manual publication needed!
Retraction:
To retract a published version:
// go.mod
retract v1.0.5 // Critical bug in processing