arc-switch
Copilot instructions6 starsChanged 8 months agoMITView on GitHub
This file provides guidelines for GitHub Copilot and other AI assistants when helping with this repository. All tools must output data in JSON format with standardized fields for consistency and interoperability. Every parser tool must use this exact structure for all output records: Every tool output must include these four required fields: All parser-specific data must be contained within the message field as a JSON object. This provides: - Consistent top-level structure across all parsers - Clear separation between metadata…
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
88 rules. About 0 are common, 66 are distinctive, and 22 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈66
Distinctive · estimate
This author's own choices. Worth a look.
22
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Follow the Go Code Review Comments for style guidance
- Very specific: line 11
Use gofmt or goimports for consistent formatting
- Very specific: line 13
Follow package structure: package main for executables, descriptive names for libraries
- Distinctive: line 14
Place interfaces near where they're used, not in separate files
- Distinctive: line 20
Use custom error types for specific error conditions
- Very specific: line 21
Use errors.Is() and errors.As() for error checking when appropriate
- Very specific: line 22
Prefer fmt.Errorf("...%w", err) for wrapping errors
- Distinctive: line 26
Use short, concise variable names in small scopes
- Distinctive: line 27
Use descriptive names for exported functions, types, and variables
- Distinctive: line 28
Use camelCase for private and PascalCase for exported identifiers
- Distinctive: line 29
Prefer single-letter variables for indices and short loops
- Very specific: line 33
Write table-driven tests using testing.T
- Very specific: line 34
Use t.Parallel() for tests that can run in parallel
- Distinctive: line 35
Test both expected successes and failures
- Distinctive: line 36
Avoid global variables in tests
- Distinctive: line 41
Use buffered I/O for file operations
- Distinctive: line 43
Use efficient data structures (maps for lookups, slices for iteration)
- Distinctive: line 44
Consider sync.Pool for frequently allocated objects
- Distinctive: line 49
Use channels to communicate between goroutines, not shared memory
- Distinctive: line 50
Use context for cancellation and timing
- Distinctive: line 52
Use sync.Mutex for simple state protection
- Distinctive: line 53
Consider sync.WaitGroup for waiting on multiple goroutines
- Distinctive: line 59
Use JSON struct tags consistently
- Distinctive: line 60
Document all configuration options
- Distinctive: line 63
Follow separation of concerns between:
- Distinctive: line 71
All tools must output data in JSON format with standardized fields for consistency and interoperability.
- Distinctive: line 75
Every parser tool must use this exact structure for all output records:
- Distinctive: line 90
Every tool output must include these four required fields:
- Very specific: line 99
All parser-specific data must be contained within the message field as a JSON object.
- Very specific: line 185
All parsers should be designed to work with the standardized syslogwriter library located in src/SyslogTools/syslogwriter/.
- Distinctive: line 223
When creating new parsers, ensure:
- Distinctive: line 225
Structure Compliance: Always use the four required fields (data_type, timestamp, date, message)
- Distinctive: line 227
Message Content: All parser-specific data goes in the message field only
- Distinctive: line 228
JSON Validity: Ensure output is valid JSON and can be parsed
- Distinctive: line 229
Syslog Compatibility: Test integration with the syslogwriter library
- Very specific: line 233
Use consistent data_type naming: vendor_device_data_type (e.g., "cisco_nexus_mac_table")
- Distinctive: line 236
Document all message field structures in the parser's README
- Distinctive: line 238
Write unit tests that validate JSON structure compliance
- Very specific: line 239
Test parser output with the validation script: Use ./validate-parser-output.sh to verify compliance with the standardized JSON structure
- Very specific: line 267
Keep main.go small and focused on setup and coordination
- Distinctive: line 268
Use separate packages for specialized functionality
- Distinctive: line 269
Place most logic in importable packages for testing
- Distinctive: line 270
Use appropriate directory structure:
- Distinctive: line 280
Use Go modules for dependency management
- Distinctive: line 282
Use specific versions in go.mod, not master branch
- Distinctive: line 286
Follow these guidelines to ensure all markdown files comply with linting rules and GitHub best practices.
- Very specific: line 290
Start every markdown file with a single H1 header (#)
- Distinctive: line 291
Use proper heading hierarchy (H1 → H2 → H3, don't skip levels)
- Distinctive: line 294
Use consistent heading case (prefer title case for main sections)
- Distinctive: line 298
Always specify language for fenced code blocks:
- Very specific: line 309
Use backticks for inline code: variable_name, function()
- Distinctive: line 310
Use triple backticks for multi-line code blocks
- Very specific: line 315
Use - (hyphen) for unordered lists consistently
- Very specific: line 316
Use 1. for ordered lists (let markdown auto-number)
- Distinctive: line 317
Add blank lines around lists for proper spacing
- Distinctive: line 319
Use bold for emphasis, *italic* for subtle emphasis
- Very specific: line 320
Use inline code for technical terms, commands, and filenames
- Distinctive: line 324
Use descriptive link text, avoid "click here" or bare URLs
- Distinctive: line 325
Prefer reference-style links for readability in long documents:
- Distinctive: line 331
Use relative paths for internal repository links
- Distinctive: line 332
Ensure all links are valid and accessible
- Distinctive: line 336
Use proper table formatting with aligned columns
- Distinctive: line 350
Don't break lines in the middle of inline code or links
- Distinctive: line 351
Use soft line breaks (don't force hard wraps unless necessary)
- Very specific: line 355
Use descriptive filenames with hyphens: installation-guide.md
- Distinctive: line 358
Use table of contents for longer documents (>10 sections)
- Distinctive: line 362
Ensure compliance with these key rules:
- Very specific: line 365
MD003: Use consistent heading style (ATX-style with #)
- Very specific: line 366
MD004: Use consistent unordered list style (hyphens -)
- Distinctive: line 368
MD009: No trailing spaces at end of lines
- Distinctive: line 369
MD010: No hard tabs, use spaces only
- Distinctive: line 370
MD012: No multiple consecutive blank lines
- Very specific: line 372
MD018: No space after # in headings
- Distinctive: line 374
MD025: Only one H1 heading per document
- Distinctive: line 375
MD026: No trailing punctuation in headings
- Distinctive: line 384
Use GitHub Flavored Markdown (GFM) features appropriately
- Distinctive: line 385
Test rendering in GitHub's preview before committing
- Very specific: line 386
Use task lists for TODO items: - [ ] Task name
- Distinctive: line 387
Use GitHub's alert syntax for important information:
- Very specific: line 396
Use proper emoji codes when appropriate: :rocket: → 🚀
- Distinctive: line 400
Write in clear, concise language
- Distinctive: line 401
Use active voice when possible
- Distinctive: line 403
Document prerequisites and assumptions
- Distinctive: line 405
Keep documentation up-to-date with code changes
- Distinctive: line 406
Use consistent terminology throughout the project
- Distinctive: line 410
Every tool/project should include a README.md with:
- Distinctive: line 423
Use markdownlint or similar tools to validate markdown files
- Distinctive: line 426
Test documentation rendering in GitHub preview mode
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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.
Files
Copilot Instructions for arc-switch Go Projects
This file provides guidelines for GitHub Copilot and other AI assistants when helping with this repository.
Golang Best Practices
Code Style and Organization
- Follow the Go Code Review Comments for style guidance
- Respect Go's Effective Go principles
- Use
gofmtorgoimportsfor consistent formatting - Organize imports in three groups: standard library, external packages, internal packages
- Follow package structure:
package mainfor executables, descriptive names for libraries - Place interfaces near where they're used, not in separate files
Error Handling
- Return errors explicitly; avoid panic except for unrecoverable situations
- Handle errors immediately; don't defer checks
- Use custom error types for specific error conditions
- Use
errors.Is()anderrors.As()for error checking when appropriate - Prefer
fmt.Errorf("...%w", err)for wrapping errors
Variable Naming
- Use short, concise variable names in small scopes
- Use descriptive names for exported functions, types, and variables
- Use camelCase for private and PascalCase for exported identifiers
- Prefer single-letter variables for indices and short loops
Testing
- Write table-driven tests using
testing.T - Use
t.Parallel()for tests that can run in parallel - Test both expected successes and failures
- Avoid global variables in tests
- Name test files as
*_test.go
Performance
- Use buffered I/O for file operations
- Preallocate slices when size is known
- Use efficient data structures (maps for lookups, slices for iteration)
- Consider sync.Pool for frequently allocated objects
- Profile before optimizing
Concurrency
- Use channels to communicate between goroutines, not shared memory
- Use context for cancellation and timing
- Be careful with goroutine leaks
- Use sync.Mutex for simple state protection
- Consider sync.WaitGroup for waiting on multiple goroutines
SNMP Project Specifics
- Log errors with context (device info, OIDs)
- Handle SNMP timeouts gracefully
- Use JSON struct tags consistently
- Document all configuration options
- Include retry logic for transient failures
- Validate input configurations
- Follow separation of concerns between:
- SNMP operations
- MIB handling
- Configuration management
- Output formatting
JSON Output Format
All tools must output data in JSON format with standardized fields for consistency and interoperability.
Standardized JSON Structure
Every parser tool must use this exact structure for all output records:
{
"data_type": "",
"timestamp": "",
"date": "",
"message": {
// Parser-specific JSON data goes here
}
}Required Fields
Every tool output must include these four required fields:
data_type: String identifying the type of data (e.g., "interface_counters", "cisco_nexus_mac_table", "lldp_neighbors")timestamp: Full timestamp in ISO 8601 format (e.g., "2024-01-15T10:30:00Z") for machine parsingdate: Date in ISO format (YYYY-MM-DD) for easy filtering and sortingmessage: JSON object containing all parser-specific data fields
Message Field Structure
All parser-specific data must be contained within the message field as a JSON object. This provides:
- Consistent top-level structure across all parsers
- Clear separation between metadata and data
- Compatibility with the syslogwriter library
- Easier processing and validation
Example: Cisco Nexus MAC Table Parser
{
"data_type": "cisco_nexus_mac_table",
"timestamp": "2024-06-23T17:05:01Z",
"date": "2024-06-23",
"message": {
"primary_entry": true,
"gateway_mac": false,
"routed_mac": false,
"overlay_mac": false,
"vlan": "7",
"mac_address": "02ec.a004.0000",
"type": "dynamic",
"age": "NA",
"secure": "F",
"ntfy": "F",
"port": "Eth1/1",
"vpc_peer_link": false
}
}Message Fields for MAC Table Parser:
primary_entry: Boolean indicating if this is a primary entrygateway_mac: Boolean indicating if this is a gateway MACrouted_mac: Boolean indicating if this is a routed MACoverlay_mac: Boolean indicating if this is an overlay MACvlan: VLAN ID as stringmac_address: MAC address in Cisco format (xxxx.xxxx.xxxx)type: Entry type (e.g., "dynamic", "static")age: Age information or "NA"secure: Security flag ("F" or "T")ntfy: Notification flag ("F" or "T")port: Port identifiervpc_peer_link: Boolean, only present when true for vPC peer-link entries
Example: Interface Counters Parser
{
"data_type": "interface_counters",
"timestamp": "2024-01-15T10:30:00Z",
"date": "2024-01-15",
"message": {
"interface_name": "Eth1/1",
"interface_type": "ethernet",
"in_octets": 205027653248,
"in_ucast_pkts": 650373664,
"in_mcast_pkts": 2262324,
"in_bcast_pkts": 68097,
"out_octets": 3195383643785,
"out_ucast_pkts": 2314463086,
"out_mcast_pkts": 365931965,
"out_bcast_pkts": 53571839,
"has_ingress_data": true,
"has_egress_data": true
}
}Message Fields for Interface Counters Parser:
interface_name: Interface identifier (e.g., "Eth1/1", "Po50", "Vlan1")interface_type: Type category ("ethernet", "port-channel", "vlan", "management", "tunnel")in_octets: Ingress octets counter (-1 if unavailable)in_ucast_pkts: Ingress unicast packets counter (-1 if unavailable)in_mcast_pkts: Ingress multicast packets counter (-1 if unavailable)in_bcast_pkts: Ingress broadcast packets counter (-1 if unavailable)out_octets: Egress octets counter (-1 if unavailable)out_ucast_pkts: Egress unicast packets counter (-1 if unavailable)out_mcast_pkts: Egress multicast packets counter (-1 if unavailable)out_bcast_pkts: Egress broadcast packets counter (-1 if unavailable)has_ingress_data: Boolean indicating if ingress counters are availablehas_egress_data: Boolean indicating if egress counters are available
Integration with SyslogWriter
All parsers should be designed to work with the standardized syslogwriter library located in src/SyslogTools/syslogwriter/. This library expects the exact JSON structure defined above:
import "github.com/arc-switch/syslogwriter"
// Initialize syslog writer
writer, err := syslogwriter.NewWithDefaults("parser-name")
if err != nil {
log.Fatal(err)
}
defer writer.Close()
// Create standardized JSON structure
entry := map[string]interface{}{
"data_type": "your_parser_type",
"timestamp": time.Now().Format(time.RFC3339),
"date": time.Now().Format("2006-01-02"),
"message": map[string]interface{}{
// Your parser-specific fields here
"field1": "value1",
"field2": 12345,
},
}
// Convert to JSON and write to syslog
jsonData, err := json.Marshal(entry)
if err != nil {
log.Printf("Failed to marshal entry: %v", err)
return
}
if err := writer.WriteEntry(string(jsonData)); err != nil {
log.Printf("Failed to write to syslog: %v", err)
}Validation Requirements
When creating new parsers, ensure:
- Structure Compliance: Always use the four required fields (data_type, timestamp, date, message)
- Field Validation: Validate that all required fields are present and non-empty
- Message Content: All parser-specific data goes in the message field only
- JSON Validity: Ensure output is valid JSON and can be parsed
- Syslog Compatibility: Test integration with the syslogwriter library
Parser Development Guidelines
- Use consistent data_type naming:
vendor_device_data_type(e.g., "cisco_nexus_mac_table") - Include comprehensive error handling for malformed input
- Provide verbose output options for debugging
- Document all message field structures in the parser's README
- Include sample input and output files for testing
- Write unit tests that validate JSON structure compliance
- Test parser output with the validation script: Use
./validate-parser-output.shto verify compliance with the standardized JSON structure
Output Validation
The project includes a validation script at the root level (validate-parser-output.sh) that verifies parser outputs conform to the standardized JSON structure. This script supports multiple JSON formats:
- Single JSON object (compact or pretty-printed)
- JSON array containing multiple objects
- Concatenated JSON objects (newline-separated)
- Live parser output via stdin
Usage examples:
# Validate a parser output file
./validate-parser-output.sh parser-output.json
# Validate live parser output
./parser -input data.txt | ./validate-parser-output.sh
# Test your parser's compliance
cd src/SwitchOutput/Cisco/Nexus/10/ip_arp_parser
./ip_arp_parser -input ../show-ip-arp.txt | /workspaces/arc-switch2/validate-parser-output.shAlways run the validation script on your parser output before committing code.
Project Structure
- Keep
main.gosmall and focused on setup and coordination - Use separate packages for specialized functionality
- Place most logic in importable packages for testing
- Use appropriate directory structure:
/cmd- Main applications/pkg- Library code/internal- Private application code/api- API definitions/configs- Configuration file templates
Dependencies
- Minimize external dependencies
- Use Go modules for dependency management
- Vendor dependencies for reproducible builds
- Use specific versions in go.mod, not master branch
Markdown Best Practices
Follow these guidelines to ensure all markdown files comply with linting rules and GitHub best practices.
Document Structure
- Start every markdown file with a single H1 header (
#) - Use proper heading hierarchy (H1 → H2 → H3, don't skip levels)
- Include a blank line after each heading
- End files with a single blank line
- Use consistent heading case (prefer title case for main sections)
Code Blocks and Syntax Highlighting
Always specify language for fenced code blocks:
# Good ./command --help# For plain text output Interface Status: UP- Use backticks for inline code:
variable_name,function() - Use triple backticks for multi-line code blocks
- Specify appropriate language identifiers:
bash,go,json,yaml,text,markdown
Lists and Formatting
- Use
-(hyphen) for unordered lists consistently - Use
1.for ordered lists (let markdown auto-number) - Add blank lines around lists for proper spacing
- Indent nested list items with 2 spaces
- Use bold for emphasis, italic for subtle emphasis
- Use
inline codefor technical terms, commands, and filenames
Links and References
- Use descriptive link text, avoid "click here" or bare URLs
- Prefer reference-style links for readability in long documents:
See the [Go documentation][go-docs] for more details. [go-docs]: https://golang.org/doc/ - Use relative paths for internal repository links
- Ensure all links are valid and accessible
Tables
- Use proper table formatting with aligned columns
- Include header separators with at least 3 dashes
- Align text content left, numbers right:
| Tool Name | Type | Status | |------------------|----------|--------| | mac_parser | CLI | Active | | interface_parser | CLI | Active |
Line Length and Wrapping
- Aim for 80-120 character line length for readability
- Break long lines at natural points (after punctuation, before conjunctions)
- Don't break lines in the middle of inline code or links
- Use soft line breaks (don't force hard wraps unless necessary)
File Organization
- Use descriptive filenames with hyphens:
installation-guide.md - Include a brief description at the top of each document
- Organize content with clear sections and subsections
- Use table of contents for longer documents (>10 sections)
Common Markdown Linting Rules (markdownlint)
Ensure compliance with these key rules:
- MD001: Heading levels should only increment by one level at a time
- MD003: Use consistent heading style (ATX-style with
#) - MD004: Use consistent unordered list style (hyphens
-) - MD007: Unordered list indentation should be 2 spaces
- MD009: No trailing spaces at end of lines
- MD010: No hard tabs, use spaces only
- MD012: No multiple consecutive blank lines
- MD013: Line length should be reasonable (80-120 chars)
- MD018: No space after
#in headings - MD022: Headings should be surrounded by blank lines
- MD025: Only one H1 heading per document
- MD026: No trailing punctuation in headings
- MD030: Spaces after list markers (1 space for unordered, 2 for ordered)
- MD032: Lists should be surrounded by blank lines
- MD040: Fenced code blocks should have a language specified
- MD041: First line in file should be a top-level heading
- MD047: Files should end with a single newline character
GitHub-Specific Considerations
- Use GitHub Flavored Markdown (GFM) features appropriately
- Test rendering in GitHub's preview before committing
- Use task lists for TODO items:
- [ ] Task name - Use GitHub's alert syntax for important information:
> [!NOTE] > This is a note > [!WARNING] > This is a warning - Include shields/badges consistently at the top of README files
- Use proper emoji codes when appropriate:
:rocket:→ 🚀
Documentation Standards
- Write in clear, concise language
- Use active voice when possible
- Include examples for all instructions
- Document prerequisites and assumptions
- Provide troubleshooting sections for complex procedures
- Keep documentation up-to-date with code changes
- Use consistent terminology throughout the project
README File Requirements
Every tool/project should include a README.md with:
- Title and Description: Clear project name and purpose
- Installation Instructions: How to build/install the tool
- Usage Examples: Command-line examples with expected output
- Configuration: Available options and settings
- Input/Output Formats: Expected data formats and schemas
- Examples: Sample input/output files
- Contributing: How to contribute to the project
- License: License information or reference
Validation and Tools
- Use markdownlint or similar tools to validate markdown files
- Set up pre-commit hooks to check markdown formatting
- Configure editor extensions for real-time markdown linting
- Test documentation rendering in GitHub preview mode
- Validate all external links regularly
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
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.

