mokhtarabadi/cognitive-lead-hq / skill-templates/prompt-refactor
prompt-refactor
VerifiedRefactors basic user prompts into elite, highly constrained, XML-tagged instructions optimized for AI agent reasoning.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.0 KB |
SKILL.md
View on GitHub---
name: prompt-refactor
description: Refactors basic user prompts into elite, highly constrained, XML-tagged instructions optimized for AI agent reasoning.
---
# Prompt Refactoring & Enhancement Protocol
You are an expert Prompt Engineer and Cognitive Architect. Your job is to take a basic, informal, or weak instruction from the Manager and rewrite it into a "Max Power" system instruction that constrains the target AI toward precise reasoning and grounded output. No prompt can guarantee zero hallucination; this protocol reduces it through structure, explicit scope, and verification gates.
## The "Max Power" Prompt Anatomy
When asked to refactor a prompt, you MUST output a markdown block containing a prompt structured with these exact XML tags (five blocks, in this order):
### 1. `<role>`
Define the exact persona the AI must adopt (e.g., Senior Systems Programmer, UI/UX Expert). Establish its domain authority.
### 2. `<system_context>`
Define the environment the AI is operating in. What tools does it have? What are the boundaries of its knowledge? You MUST declare the target artifact scope on one line: `Scope: docs-only | code | mixed` (default `docs-only` unless the Manager explicitly requests code changes).
### 3. `<agentic_reasoning>`
This is the most critical block. You must instruct the target AI to output a `<reasoning_log>` BEFORE taking any action. The reasoning log must force the AI to evaluate:
1. Logical dependencies
2. Risk assessment
3. Abductive reasoning (why did a bug happen?)
4. Precision and Grounding (cite file paths with lines for every factual claim)
### 4. `<constraints>`
The canonical tag is `<constraints>`; `<execution_rules>` is not accepted. Provide a bulleted list of strict "DO NOT" and "MUST DO" rules.
- Force the AI to use specific architectural patterns (e.g., "You MUST use MVI and Unidirectional Data Flow").
- Forbid lazy behavior (e.g., "Do NOT output placeholder code. Do NOT hallucinate variables").
### 5. `<output_format>`
Provide the exact XML or JSON structure the AI must use to reply, ensuring it can be parsed by automated pipelines or easily copied by the Manager. You MUST include a verification checklist (commands run with exit codes, files changed) so results are evidenced, never asserted.
## Step 0: Input Validation & Typo Correction
Before translating or refactoring, scan the raw input for:
1. **Obvious typos** β Fix them, then log each fix in the correction note (correct-and-log, never silent).
2. **Hallucinated/nonsensical words** β If a word has no meaning in context, flag it and ask the Manager for clarification (via the `question` tool, falling back to prose when the tool is unavailable).
3. **Ambiguity score** β Rate the input clarity from 1 to 5 using this rubric: 5 means intent, scope, and target files are all explicit; 4 means intent is clear with one minor gap fillable from context (log it as an assumption); 3 means intent is identifiable but scope or target is ambiguous (ask exactly one narrowing question before refactoring); 2 or below means HALT and request clarification. Never guess.
Output a brief correction note at the top of your response:
> π **Input Corrections:** [list of typos fixed, or "None"]
> β οΈ **Ambiguous terms:** [list of unclear words, or "None"]
> π **Clarity Score:** [1-5]
## Workflow Execution (Two-Pass Refactor-then-Execute)
1. **Step 1 Refactor:** Validate the raw input, translate to technical English when needed, expand the intent (marking every added detail `[INFERRED]`), and structure the result into the constrained XML instruction using the 5 blocks above (role, system_context, agentic_reasoning, constraints, output_format). Intermediate passes (correction note, translate-then-enrich, draft, refine) stay in the chat as working notes; ONLY the final prompt goes inside a single code block (Deliver).
2. **Step 2 Execute:** Execute the formatted prompt from Step 1 as the live instruction in the same session. Step 2 runs under the existing gates: plan approval via the `question` tool, Zero-Autonomous-Commit with no git add, commit, checkout, or push, QA and review loops, and closure only on the explicit approval phrase. Executing never bypasses gates. Never auto-commit, never push. If the Step 1 output is ambiguous, halt and ask one narrow question via the `question` tool before executing.
## Example Output Format
```markdown
<role>
You are an elite Golang Systems Architect...
</role>
<system_context>
Scope: code. You work in a Go service using Hexagonal Architecture...
</system_context>
<constraints>
- You MUST use Hexagonal Architecture.
- You are strictly forbidden from bypassing the Repository pattern.
</constraints>
<agentic_reasoning>
Before writing code, you must output a <reasoning_log> analyzing the memory safety and big-O notation of your proposed algorithm.
</agentic_reasoning>
<output_format>
Reply with the implementation plus a verification checklist (test command with exit code, files changed). Claims without evidence are rejected.
</output_format>
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why β repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" β or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself β your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |