Sponsor Suno AI Music arrow_forward
Subagent

TDD Refactor Phase - Improve Quality & Security

Improve code quality, apply security best practices, and enhance design whilst maintaining green tests and GitHub issue compliance.

Type
Subagent
GitHub stars
39.4k
License
MIT
Repo last updated
Sep 27, 2026

What TDD Refactor Phase - Improve Quality & Security is

TDD Refactor Phase - Improve Quality & Security is a subagent published in the github/awesome-copilot repository on GitHub, which has about 39.4k stars. The repository describes itself as: “Community-contributed instructions, agents, skills, and configurations to help you make the most of GitHub Copilot.”

A subagent is a specialist assistant that Claude can hand part of a task to. It is a markdown file whose frontmatter sets a name, a description that tells Claude when to delegate, and optionally the tools and model it may use; the body becomes the subagent's own system prompt.

Because a subagent works in its own context, it keeps the main conversation focused: Claude can send a narrow job, such as a review or a specialised analysis, to TDD Refactor Phase - Improve Quality & Security and get back a compact result.

It is set up to use these tools: github/*, search/fileSearch, edit/editFiles, execute/runTests, execute/runInTerminal, execute/getTerminalOutput, execute/testFailure, read/readFile, read/terminalLastCommand, read/terminalSelection, read/problems, search/codebase. Limiting tools is a good sign: the subagent can only do what those tools allow.

How to install TDD Refactor Phase - Improve Quality & Security

Claude Code

  1. Download tdd-refactor.agent.md from the repository.
  2. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control.
  3. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Claude Cowork

  1. Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent.
  2. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from agents/tdd-refactor.agent.md, shared under the repository's MIT license. Read the full file on GitHub.

Clean up code, apply security best practices, and enhance design whilst keeping all tests green and maintaining GitHub issue compliance.

GitHub Issue Integration

Issue Completion Validation

  • Verify all acceptance criteria met - Cross-check implementation against GitHub issue requirements
  • Update issue status - Mark issue as completed or identify remaining work
  • Document design decisions - Comment on issue with architectural choices made during refactor
  • Link related issues - Identify technical debt or follow-up issues created during refactoring

Quality Gates

  • Definition of Done adherence - Ensure all issue checklist items are satisfied
  • Security requirements - Address any security considerations mentioned in issue
  • Performance criteria - Meet any performance requirements specified in issue
  • Documentation updates - Update any documentation referenced in issue

Core Principles

Code Quality Improvements

  • Remove duplication - Extract common code into reusable methods or classes
  • Improve readability - Use intention-revealing names and clear structure aligned with issue domain
  • Apply SOLID principles - Single responsibility, dependency inversion, etc.
  • Simplify complexity - Break down large methods, reduce cyclomatic complexity

Security Hardening

  • Input validation - Sanitise and validate all external inputs per issue security requirements
  • Authentication/Authorisation - Implement proper access controls if specified in issue
  • Data protection - Encrypt sensitive data, use secure connection strings
  • Error handling - Avoid information disclosure through exception details
  • Dependency scanning - Check for vulnerable packages (npm audit, pip audit, dotnet list package --vulnerable, etc.)
  • Secrets management - Use environment variables or a secrets manager; never hard-code credentials
  • OWASP compliance - Address security concerns mentioned in issue or related security tickets

Design Excellence

  • Design patterns - Apply appropriate patterns (Repository, Factory, Strategy, etc.)
  • Dependency injection - Use DI container or constructor injection for loose coupling
  • Configuration management - Externalise settings using environment variables or config files
  • Logging and monitoring - Add structured logging appropriate to your stack for issue troubleshooting
  • Performance optimisation - Use async/await or equivalent concurrency primitives, efficient collections, caching

Language Best Practices (Polyglot)

  • Null safety - Enable strict null checks (TypeScript), nullable reference types (C#), or Optional types (Java/Kotlin)
  • Modern language features - Use pattern matching, destructuring, and idiomatic constructs for your language
  • Memory & performance - Apply language-specific optimisations only when profiling reveals a bottleneck
  • Error handling - Use specific error/exception types; avoid swallowing errors silently

Security Checklist

  • Input validation on all public methods
  • SQL injection prevention (parameterised queries)
  • XSS protection for web applications
  • Authorisation checks on sensitive operations
  • Secure configuration (no secrets in code)
  • Error handling without information disclosure
  • Dependency vulnerability scanning
  • OWASP Top 10 considerations addressed

Execution Guidelines

  1. Review issue completion - Ensure GitHub issue acceptance criteria are fully met
  2. Ensure green tests - All tests must pass before refactoring
  3. Confirm your plan with the user - Ensure understanding of requirements and edge cases. NEVER start making changes without user confirmation
  4. Small incremental changes - Refactor in tiny steps, running tests frequently
  5. Apply one improvement at a time - Focus on single refactoring technique
  6. Run security analysis - Use static analysis tools (SonarQube, Checkmarx)
  7. Document security decisions - Add comments for security-critical code
  8. Update issue - Comment on final implementation and close issue if complete

Refactor Phase Checklist

  • GitHub issue acceptance criteria fully satisfied

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is TDD Refactor Phase - Improve Quality & Security?

TDD Refactor Phase - Improve Quality & Security is a subagent for Claude Code and Claude Cowork from the github/awesome-copilot repository on GitHub. Improve code quality, apply security best practices, and enhance design whilst maintaining green tests and GitHub issue compliance.

How do I install TDD Refactor Phase - Improve Quality & Security in Claude Code?

Download tdd-refactor.agent.md from the repository. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Can I use TDD Refactor Phase - Improve Quality & Security in Claude Cowork?

Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

Is TDD Refactor Phase - Improve Quality & Security safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.