Skip to content

Commit 067b733

Browse files
committed
docs(copilot): add comprehensive instructions for Copilot usage
2 parents 1e97351 + f3b8402 commit 067b733

File tree

2 files changed

+130
-1
lines changed

2 files changed

+130
-1
lines changed

.github/copilot-instructions.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# GitHub Copilot Instructions
2+
3+
## 1. Repository Context & Mission
4+
5+
**Repository:** `HttpUserAgentParser` (mycsharp)
6+
7+
**Primary Goal:**
8+
Provide a **high-performance, stable, and broadly compatible .NET library** for parsing HTTP User-Agent strings, including integrations for ASP.NET Core and MemoryCache.
9+
10+
**Core Design Principles:**
11+
- API stability over convenience
12+
- Predictable performance characteristics
13+
- Minimal allocations in hot paths
14+
- Full test coverage for all observable behavior
15+
16+
---
17+
18+
## 2. Repository Structure (Authoritative)
19+
20+
Copilot must understand and respect the architectural boundaries:
21+
22+
- `src/HttpUserAgentParser`
23+
→ Core parsing logic and public APIs
24+
25+
- `src/HttpUserAgentParser.AspNetCore`
26+
→ ASP.NET Core integration (middleware, extensions)
27+
28+
- `src/HttpUserAgentParser.MemoryCache`
29+
→ Caching extensions and cache-aware abstractions
30+
31+
- `tests/*`
32+
→ Unit tests for **all** shipped packages
33+
→ Tests define expected behavior and are the source of truth
34+
35+
- `perf/*`
36+
→ Benchmarks for performance-sensitive code paths
37+
38+
---
39+
40+
## 3. Standard .NET CLI Commands
41+
42+
Use these commands consistently:
43+
44+
- Clean:
45+
`dotnet clean --nologo`
46+
47+
- Restore:
48+
`dotnet restore`
49+
50+
- Build:
51+
`dotnet build --nologo`
52+
53+
- Test (all):
54+
`dotnet test --nologo`
55+
56+
- Test (single project):
57+
`dotnet test <path-to-csproj> --nologo`
58+
59+
---
60+
61+
## 4. Autonomous Execution Rules (Critical)
62+
63+
Copilot is expected to work **independently and end-to-end** without human intervention.
64+
65+
### Mandatory Quality Gates (Never Skip)
66+
- The solution **must compile** after every change
67+
- **All tests must pass**
68+
- New behavior **must include unit tests**
69+
- Public APIs **must not break** existing users unless explicitly intended
70+
- Changes must be **minimal, focused, and intentional**
71+
72+
If any gate fails:
73+
1. Diagnose the root cause
74+
2. Fix the issue
75+
3. Re-run the full validation cycle
76+
77+
---
78+
79+
## 5. Change Strategy & Scope Control
80+
81+
When solving a task, Copilot should:
82+
83+
1. **Analyze existing code first**
84+
- Prefer extension over modification
85+
- Reuse established patterns and helpers
86+
2. **Avoid architectural rewrites**
87+
- No refactors unless explicitly required
88+
3. **Preserve backward compatibility**
89+
- No breaking changes to public APIs
90+
- No silent behavioral changes
91+
92+
If multiple solutions are possible:
93+
- Prefer the **simplest**, **most explicit**, and **least invasive** option
94+
95+
---
96+
97+
## 6. Testing Requirements
98+
99+
Every functional change must be fully tested:
100+
101+
- Unit tests are mandatory for:
102+
- New features
103+
- Bug fixes
104+
- Edge cases and regressions
105+
- Prefer existing utilities from:
106+
`tests/HttpUserAgentParser.TestHelpers`
107+
108+
Tests define correctness. If behavior is unclear, tests take precedence over assumptions.
109+
110+
---
111+
112+
## 7. Performance Guidelines
113+
114+
- Treat parsing logic as performance-critical
115+
- Avoid unnecessary allocations and LINQ in hot paths
116+
- Prefer spans, pooling, and cached results where appropriate
117+
- Update or add benchmarks in `perf/*` for performance-relevant changes
118+
119+
---
120+
121+
## 8. Output Expectations
122+
123+
Copilot should deliver:
124+
- Compilable, production-ready code
125+
- Complete test coverage for new behavior
126+
- Clear, intentional commits without unrelated changes
127+
128+
**Do not stop early.**
129+
A task is only complete when **all quality gates pass** and the solution is fully validated.

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@
8181
"isBackground": false
8282
}
8383
]
84-
}
84+
}

0 commit comments

Comments
 (0)