all repos

moviefeed @ main

rss feed server for tracking new tv show episodes

moviefeed/AGENTS.md(view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# moviefeed - Agent Guidelines
## Build/Test/Lint Commands

```bash
# Build the application
go build -o moviefeed .

# Run the application
go run . -config config.yaml

# Format code
go fmt ./...

# Run linter (requires golangci-lint)
golangci-lint run

# Run tests with verbose output
go test -v ./...
```

## Code Style Guidelines
### Go Version
- Target Go 1.24 or later
- Use standard library features where possible

### Imports
- Group imports: standard library, third-party, internal (blank lines between)
- Use explicit import paths (no `.` imports)

### Formatting
- Use `go fmt` for all code formatting
- Maximum line length: 100 characters (soft limit)
- Use tabs for indentation (Go standard)

### Struct Tags
- Use json tags for JSON serialization: `json:"field_name"`
- Use yaml tags for YAML serialization: `yaml:"field_name"`
- Match tag names to external API format exactly (e.g., TMDB API snake_case)

### Error Handling
- Always return errors from functions that can fail
- Use `fmt.Errorf` with `%w` for error wrapping: `fmt.Errorf("failed: %w", err)`
- Validate inputs and configuration early
- Use `slog.Error` for failures with structured context
- Use `slog.Warn` for non-critical issues that shouldn't halt execution
- Continue processing on individual failures when appropriate (e.g., fetching episodes per show)

### Resource Management
- Always `defer` cleanup operations (file closing, response body closing)
- Check errors immediately after operations that return them
- Use `defer resp.Body.Close()` for HTTP responses

### Logging
- Use `log/slog` for all logging
- Log levels: Error for failures, Warn for non-critical issues, Info for normal operation
- Include relevant context using key-value pairs: `slog.Warn("msg", "key", value)`
- Avoid logging secrets or sensitive data

### Configuration
- Support both YAML and JSON config formats via file extension detection
- Provide sensible defaults for optional fields (e.g., port defaults to "8000")
- Validate required fields after loading config (API key, at least one show)
- Return clear error messages for validation failures

### HTTP/API
- Use net/http for HTTP client operations
- Set appropriate Content-Type headers
- Use gorilla/feeds for RSS feed generation
- Return proper HTTP status codes (500 for internal errors)
- Use defer for response body cleanup

### TMDB API Integration
- Support both IMDB IDs (tt*) and TMDB IDs directly
- Use find endpoint to convert IMDB to TMDB ID
- Fetch only first season and latest season (not all seasons)
- Filter episodes by air date (last 30 days)
- Handle missing or invalid air dates gracefully

### Testing
- Write tests for all public functions
- Use table-driven tests for multiple test cases
- Mock external API calls in tests
- Test error paths and edge cases
- Test config validation with both valid and invalid inputs

### Comments
- Exported functions should have godoc comments
- Keep comments brief and accurate
- Update comments when code changes
- Don't comment obvious code