|
| 1 | +# MayR Labs CLI - Copilot Agent Instructions |
| 2 | + |
| 3 | +## Project Overview |
| 4 | +MayR Labs CLI is a lightweight, cross-platform command-line tool built with Go to streamline common development, configuration, and automation tasks across projects. |
| 5 | + |
| 6 | +## Tech Stack |
| 7 | +- **Language:** Go 1.17+ |
| 8 | +- **CLI Framework:** Cobra |
| 9 | +- **Build:** Single static binary |
| 10 | +- **Platforms:** macOS, Linux, Windows |
| 11 | + |
| 12 | +## Project Structure |
| 13 | +``` |
| 14 | +. |
| 15 | +├── cmd/ # CLI commands (Cobra) |
| 16 | +│ └── root.go # Root command and app initialization |
| 17 | +├── internal/ # Private application code |
| 18 | +│ ├── commands/ # Command implementations |
| 19 | +│ ├── utils/ # Utility functions |
| 20 | +│ └── config/ # Configuration handling |
| 21 | +├── pkg/ # Public libraries (if any) |
| 22 | +├── tests/ # Integration tests |
| 23 | +├── .github/ |
| 24 | +│ └── workflows/ # CI/CD workflows |
| 25 | +└── main.go # Application entry point |
| 26 | +``` |
| 27 | + |
| 28 | +## Development Guidelines |
| 29 | + |
| 30 | +### Building and Testing |
| 31 | +```bash |
| 32 | +# Build the project |
| 33 | +go build -o mayrlabs main.go |
| 34 | + |
| 35 | +# Run tests |
| 36 | +go test ./... -v |
| 37 | + |
| 38 | +# Run tests with coverage |
| 39 | +go test ./... -cover -coverprofile=coverage.out |
| 40 | + |
| 41 | +# Run linter |
| 42 | +go vet ./... |
| 43 | +golangci-lint run |
| 44 | +``` |
| 45 | + |
| 46 | +### Adding New Commands |
| 47 | +1. Create command file in `internal/commands/` |
| 48 | +2. Implement command logic with proper error handling |
| 49 | +3. Add command to root command in `cmd/root.go` |
| 50 | +4. Write unit tests in corresponding `_test.go` file |
| 51 | +5. Update documentation if needed |
| 52 | + |
| 53 | +### Code Style |
| 54 | +- Follow standard Go formatting (`gofmt`) |
| 55 | +- Use meaningful variable and function names |
| 56 | +- Add comments for exported functions and complex logic |
| 57 | +- Keep functions small and focused |
| 58 | +- Handle errors explicitly, don't ignore them |
| 59 | + |
| 60 | +### Testing Requirements |
| 61 | +- Write unit tests for all public functions |
| 62 | +- Aim for >80% code coverage |
| 63 | +- Include edge cases and error scenarios |
| 64 | +- Use table-driven tests where appropriate |
| 65 | + |
| 66 | +### CI/CD |
| 67 | +- All PRs must pass CI checks (build, test, lint) |
| 68 | +- Code must be formatted with `gofmt` |
| 69 | +- All tests must pass |
| 70 | +- No security vulnerabilities |
| 71 | + |
| 72 | +## Common Tasks |
| 73 | + |
| 74 | +### Working with Cobra Commands |
| 75 | +Commands are organized hierarchically. Use `cobra-cli` or create manually: |
| 76 | +```go |
| 77 | +var myCmd = &cobra.Command{ |
| 78 | + Use: "mycommand", |
| 79 | + Short: "Brief description", |
| 80 | + Long: "Detailed description", |
| 81 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 82 | + // Implementation |
| 83 | + return nil |
| 84 | + }, |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +### Cross-Platform Considerations |
| 89 | +- Use `filepath.Join()` for paths |
| 90 | +- Use `os.PathSeparator` when needed |
| 91 | +- Test on multiple platforms if modifying platform-specific code |
| 92 | +- Use build tags for platform-specific code: `// +build windows` |
| 93 | + |
| 94 | +## Dependencies |
| 95 | +- `github.com/spf13/cobra` - CLI framework |
| 96 | +- `github.com/spf13/viper` - Configuration management |
| 97 | +- Additional dependencies as needed for specific features |
| 98 | + |
| 99 | +## Security Considerations |
| 100 | +- Never commit sensitive data (API keys, passwords, etc.) |
| 101 | +- Validate all user inputs |
| 102 | +- Use secure random generation for passwords/tokens |
| 103 | +- Be careful with file operations (path traversal attacks) |
| 104 | + |
| 105 | +## Documentation |
| 106 | +- Keep README.md updated with new commands |
| 107 | +- Add inline comments for complex logic |
| 108 | +- Document all exported functions and types |
| 109 | +- Include usage examples in help text |
| 110 | + |
| 111 | +## Getting Help |
| 112 | +- Check existing issues on GitHub |
| 113 | +- Refer to Cobra documentation: https://cobra.dev/ |
| 114 | +- Follow Go best practices: https://golang.org/doc/effective_go.html |
0 commit comments