mcp-memory-service is a self-hosted memory backend that lets AI agents store and retrieve shared project context through REST, MCP, OAuth, a command-line interface, and a dashboard. It is intended for agent pipelines and clients such as LangGraph, CrewAI, AutoGen, Claude Desktop, and OpenCode, with support for knowledge graphs and memory consolidation. The catalogue includes skills, agents, commands, instructions, hooks, a setting, an MCP entry, and a plugin for its workflows.
Borrowing it
Nothing to install: this file belongs to doobidoo/mcp-memory-service. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/doobidoo/mcp-memory-service/main/.claude/commands/refactor-function.mdgit clone --depth 1 https://github.com/doobidoo/mcp-memory-serviceWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/commands/doobidoo/mcp-memory-service/refactor-function)<a href="https://agentmods.dev/commands/doobidoo/mcp-memory-service/refactor-function"><img src="https://agentmods.dev/badge/commands/doobidoo/mcp-memory-service/refactor-function/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/commands/doobidoo/mcp-memory-service/refactor-function"><img src="https://agentmods.dev/badge/commands/doobidoo/mcp-memory-service/refactor-function.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.01588 |
| Opus 5.5 | $0.00000 | $0.00635 |
| Sonnet 5.5 | $0.00000 | $0.00318 |
| Haiku 4.5 | $0.00000 | $0.00159 |
Grade A, and why
refactor-function scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 273 lines — stays where its author put it; the contents beside it link to each section on GitHub.
/refactor-function Command
Automated function complexity reduction using multi-agent workflow.
Usage
# In editor, select a function and run:
/refactor-function
# With options:
/refactor-function --target-complexity 6 --max-helpers 3
/refactor-function --pattern extract-method
/refactor-function --dry-run # Show plan without applying
Workflow
1. Context Extraction
- Detect selected function or function at cursor
- Extract function signature, body, surrounding context
- Parse imports and dependencies
2. Baseline Analysis (code-quality-guard)
- Measure current complexity
- Identify nesting depth
- Count boolean operators
- Calculate maintainability index
- Generate refactoring targets
3. Refactoring (amp-bridge)
- Apply Extract Method pattern
- Create helper functions
- Reduce nesting with early returns
- Replace if-elif chains with dictionaries
- Extract magic strings to constants
4. Validation (code-quality-guard)
- Measure new complexity
- Verify targets met
- Check for regressions
- Generate diff report
5. User Review
Before:
Function: parse_output
Complexity: 12 (C-grade)
Nesting: 5 levels
After:
Main: parse_output (C=6, B-grade)
Helpers:
- _parse_field (C=4, A-grade)
- _validate_output (C=3, A-grade)
Apply changes? [y/n]
6. Optional Commit
If applied, offer to commit:
"refactor: Reduce complexity in <function_name>
- Complexity: C=12→6 (-50%)
- Extracted N helpers (avg C=X)
- Pattern: Extract Method"
Options
| Option | Description | Default |
|---|---|---|
--target-complexity |
Target cyclomatic complexity | 6 |
--max-helpers |
Max helper functions to create | 5 |
--pattern |
Refactoring pattern | extract-method |
--dry-run |
Show plan without applying | false |
--auto-commit |
Commit if successful | false |
--scope |
Scope (function|class|file) | function |
Patterns Supported
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 273 lines · 0 tokens per session scan A 3b66847514b5
refactor-function is a command published in the GitHub repository doobidoo/mcp-memory-service (2,021 stars, last pushed yesterday), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,588 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other commands, from other repositories
setup-context
Set up your Skill Memory — a pm-context.md every skill reads so outputs come back tailored to you.
perf-difficult-conversation
Three-conversations framework rehearsal (Stone/Patton/Heen — Harvard Negotiation Project) for high-stakes conversations — termination, demotion, hard feedback, conflict surfacing. Produces three-conversations breakdown (what-happened / feelings / identity), conversation script with multiple opening choices, SCARF…
culture-onboarding-90
Design a 90-day onboarding architecture for a role. First day (psychological safety + belonging activation), first week (relationship + role context + early wins), first month (skill ramp + integration + baseline), first quarter (autonomous performance + cultural integration check). Written-first elements for…
reclaim-knowledge
Organize scattered professional material into a domain-based second-brain architecture. Maps existing sources (Canva, Drive, local folders, Notion, screenshots) to functional domains. Non-technical-friendly — produces folder structure + drag-and-drop instructions, not CLI commands.
discover-genius
Excavate genius from a person's scattered corpus. Produces Genius Profile (what only they uniquely see) + Freedom Path (four-bucket sort of every activity). Gateway to all downstream intelligence systems. For humans, not agents.
orchestrate-brain
Weekly 30-minute second-brain review ritual. Orchestrates inbox clear, lightweight distillation, vault maintenance, cross-reference pass, and next-week capture focus. The compounding rhythm that keeps the system alive.