Skip to content
Back to skills

Extract To Context

ASecurity

Move existing code out of `proxy.Service` into its bounded-context package as a move-only, behavior-preserving refactor. Use for any structural move or extraction, including splitting a large function or file into a context package.

  • 5,621 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 12, 2026
ai-agentsgobashgit

Security analysis

A100/100

Scanned November 12, 2026

npx -y skills add weave-os/router --skill extract-to-context --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Extract To Context?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Extract To Context
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/weave-os-extract-to-context/badge)](https://www.skillsdirectory.com/skills/weave-os-extract-to-context)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: extract-to-context
description: Move existing code out of `proxy.Service` into its bounded-context package as a move-only, behavior-preserving refactor. Use for any structural move or extraction, including splitting a large function or file into a context package.
---

# Extract to a bounded context

A structural move changes where code lives, never what it does. Pick the context with `where-does-this-go`; extract the code with the least shared mutable state first.

## Steps

1. **Confirm golden coverage** of the code being moved (`golden-traces`). If a path is uncovered, add the scenario in its own PR first.
2. **Declare the port and types** in the new package (`go list ./internal/...` to find it, or create it with a `CLAUDE.md`). Wire the concrete implementation in `cmd/router`, and have `Service` hold the port instead of the fields it replaces.
3. **Move-only commit.** Cut and paste; change only identifiers and imports the move forces. Verify:
   ```bash
   git diff --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change HEAD~1
   ```
   Everything except signatures and call sites should render as moved.
4. **Tidy commit** on top: renames, dead parameters, comments.
5. **Never mix a move with a fix.** A bug found mid-move becomes a separate PR that lands a synthetic failing regression first, per the root `CLAUDE.md` incident rule.

## PR description

Add a before → after table for every baseline the move touches:

| Metric | Before | After |
|---|---|---|
| `proxy.Service` fields / methods | | |
| over-limit functions / files | | |
| duplicate-code clones | | |
| inference-boundary baseline entries | | |

Every row must shrink or stay equal. Moved code must meet the limits, or sit in the baseline with a smaller value than before.

## Verify

```bash
go test ./internal/proxy -run TestGolden   # unchanged, no -update
go test ./internal/architecture/...
make inference-boundary
make arch-ratchet                          # when the target exists
make check-changed
```

Moves in Inference Execution or Credential Brokerage also need a canary watch on error rate, failover rate, billing rows per request and decision distribution; flag that in the PR. Escalate to the CODEOWNER when the port signature would change another context's contract.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.