Implement a feature from a mini-plan document, user story, or GitHub issue using TDD, enforcing security and .NET/MCP best practices. Pass the path to a mini-plan .md file, user story, or GitHub issue URL/file. Also use when the user says "implement issue
You are implementing a feature for CodeCompress, a .NET 10 / C# 14 MCP server. Read and follow the input document provided — this may be a mini-plan, a user story, or a GitHub issue. Enforce strict TDD methodology, OWASP security requirements, and .NET/MCP best practices throughout.
Determine the input type from $ARGUMENTS:
.md file with "Files to Create/Modify" and "Acceptance Criteria" sections): Follow the plan as-is — it already contains implementation details, file lists, and test specifications..md file, plain text, or URL describing desired behavior in terms of user-facing outcomes, acceptance criteria, or "As a … I want … so that …" format): You must derive the implementation plan yourself before coding. See Deriving a Plan from a Story/Issue below.If $ARGUMENTS is a GitHub issue URL, fetch its content using available tools (e.g., gh issue view CLI if available, or Ref MCP ref_read_url) before proceeding.
Never rely on training data for library APIs, SDK usage, or framework patterns. Always fetch current documentation before using any library or framework API.
Use the Context7 MCP (resolve-library-id → query-docs) as the primary documentation source:
resolve-library-id("ModelContextProtocol"), resolve-library-id("TUnit"), resolve-library-id("Microsoft.Data.Sqlite")query-docs(id, "McpServerToolType tool registration")Use the Ref MCP (ref_search_documentation / ref_read_url) as a secondary source when Context7 lacks coverage or you need to read a specific documentation URL.
When to look up docs:
Do NOT guess at API signatures, attribute names, or SDK patterns. A 30-second doc lookup prevents hours of debugging wrong APIs.
Before reading any plan or writing any code, bootstrap your understanding of the codebase using the CodeCompress MCP server. This is mandatory — do not skip this step or substitute manual file browsing.
Run the CodeCompress update/rebuild index tool first, before any query tools. This ensures the index reflects the latest state of the codebase (recent commits, new files, renamed types). Do not proceed until the index update completes successfully.
Use CodeCompress query tools to explore the codebase and build a working mental model:
Only after this discovery phase should you proceed to read the input document in detail.
$ARGUMENTS (mini-plan, user story, or GitHub issue — see Input Detection above)CLAUDE.md for project conventionsWhen the input is a user story or GitHub issue rather than a structured mini-plan, you must produce the equivalent plan yourself before entering the TDD cycle.
CLAUDE.md.Before writing any code, determine the correct implementation order:
State your implementation order briefly, then proceed.
For every deliverable in the plan (mini-plan or derived plan), follow this strict cycle:
await Assert.That(result).IsEqualTo(expected);
[Arguments(...)] for parameterized testsCodeCompress.Core/Foo/Bar.cs → CodeCompress.Core.Tests/Foo/BarTests.csdotnet test --filter "FullyQualifiedName~TestClassName" to confirm tests fail (red phase)dotnet test --filter "FullyQualifiedName~TestClassName" to confirm all tests pass (green phase).editorconfig (PascalCase public, _camelCase private, Allman braces, 4-space indent)readonly where possible, var when type is apparentdotnet build CodeCompress.slnx — must produce zero warningsCodeCompress.Server.exe is locked by the running MCP server process, call the stop_server MCP tool to gracefully shut down the server, then retry the build. Claude Code will automatically restart the server on the next MCP tool call.For every file you create or modify, verify these requirements. Delegate to the security expert agent when implementing security-critical components.
PathValidator — Path.GetFullPath() + starts-with check against project root. No .. traversal. Reject paths outside root.@param parameterized syntax. Zero string concatenation in SQL. Verify this for every query you write.Fts5QuerySanitizer before passing to SQLite. No raw user input in FTS5 syntax.dynamic or object for user-facing data. All types are strongly-typed records/enums/classes.Use specialized skill-backed agents for complex subtasks. Launch agents in parallel when their work is independent.
The project has dedicated expert skills. When delegating to an agent, reference the relevant skill to provide domain expertise:
| Skill | When to Use | Slash Command |
|---|---|---|
| tdd-expert | Writing tests, test infrastructure, TUnit patterns, NSubstitute mocking, Verify snapshots | /tdd-expert |
| security-expert | Security review, OWASP compliance, prompt injection prevention, path/SQL/FTS5 validation | /security-expert |
| cli-expert | CLI command implementation, System.CommandLine, help text, output formatting, exit codes | /cli-expert |
| parser-expert | Language parser development, regex symbol extraction, sample projects, integration tests | /parser-expert |
All skills reference the shared dotnet-reference.md for .NET conventions.
| Task Type | Delegate To | Mode |
|---|---|---|
| Security-critical code (PathValidator, SQL, FTS5, output sanitization) | security-expert (enforce mode) | During implementation |
| Security review after implementation | security-expert (review mode) | Post-implementation |
| Test writing, test scaffolding, TUnit patterns | tdd-expert | Before implementation (TDD) |
| New language parser | parser-expert | During implementation |
| CLI commands, help text, output formatting | cli-expert | During implementation |
| Complex .NET patterns (DI, GenericHost, async, Span) | Reference dotnet-reference.md | Inline |
| MCP SDK integration (tool registration, protocol) | Fetch docs via Context7/Ref MCP | Inline |
| Parallel implementation of independent components | Launch multiple agents with relevant skills | Parallel |
Skills have disable-model-invocation: true, so they cannot be invoked via the Skill tool or automatically. Instead, you must read the skill file and inject its full content into the agent prompt. This is the only way to engage the skill's expertise.
Mandatory steps for every delegation:
.claude/skills/security-expert/SKILL.md.claude/skills/tdd-expert/SKILL.md.claude/skills/cli-expert/SKILL.md.claude/skills/parser-expert/SKILL.mdExample — security review delegation:
1. Read `.claude/skills/security-expert/SKILL.md`
2. Read the changed source files
3. Launch Agent with prompt:
- "You are the security expert for CodeCompress. Follow these instructions:"
- [paste full SKILL.md content]
- "## Mode: Review"
- "## Files to Review"
- [paste each file's source code]
Sub-agents cannot call MCP tools or read files. Before delegating:
After all implementation is complete:
dotnet test CodeCompress.slnx — all tests passdotnet build CodeCompress.slnx — clean build.claude/skills/security-expert/SKILL.md, include its full content and all changed source code in the agent prompt. This is not optional — every implementation must have a skill-backed security review before completion.When the implementation includes a new language parser or enhances an existing parser, ensure the sample project and integration tests reflect the full parser capability:
For new parsers: Create a directory at samples/{language}-sample-project/ containing realistic source files.
For existing parser enhancements: Audit the existing sample project at samples/{language}-sample-project/ for coverage of the new/changed constructs. Add missing constructs to existing sample files or create new ones as needed. Each sample directory has a COVERAGE.md checklist — update it when adding new constructs.
Follow the existing patterns (see samples/csharp-sample-project/, samples/luau-sample-project/, samples/terraform-sample-project/ for reference).
Requirements:
COVERAGE.md in the sample directory to reflect any new constructs addedFor new parsers: Create an end-to-end integration test class at tests/CodeCompress.Integration.Tests/{Language}EndToEndTests.cs following the pattern in CSharpEndToEndTests.cs.
For existing parser enhancements: Update the existing integration test class to cover the new constructs. This typically means updating file/symbol count assertions and adding new specific symbol lookups that verify the enhanced parsing.
Integration test pattern (same for new and updated):
IndexEngine with the new parser, sample project pathSymbolKind values appearSearchSymbolsAsyncDependencyInfo)Important: Terraform-style dotted symbol names (e.g., aws_instance.web) conflict with GetSymbolByNameAsync's parent.child splitting logic. Use GetSymbolsByFileAsync to find symbols by exact name in those cases.
Run the full test suite to confirm all integration tests pass alongside existing tests.
After implementation is complete, review README.md for any updates needed based on the changes made. Common updates include:
If updates are needed, make them and include them in the commit.
When complete, provide:
PyTorch深度学习模式与最佳实践,用于构建稳健、高效且可复现的训练流程、模型架构和数据加载。