شعار Refactoring Advisor

Refactoring Advisor

المجتمع
Firstp1ck
refactoring-advisor

Agents should invoke this skill for refactors, code smells, migrations, duplication removal, module splitting, API cleanup, or restructuring plans. Emphasizes small safe steps, behavior preservation, and verification after each change.

نظرة عامة

الناشرFirstp1ck
المستودعpi-coding-agent-forge
اسم المهارةrefactoring-advisor
النجوم
93
التفريعات
22
الملفات المرفقة
تعليمات فقط
الترخيصMIT
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • مكتفية بذاتها

    كل ما يحتاجه النموذج موجود في التعليمات — لا ملفات إضافية لمزامنتها.

  • مفتوحة المصدر

    نشرها Firstp1ck على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Refactoring Advisor في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى الإضافات → المهارات.
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-skill-refactoring-advisor/skills/refactoring-advisor
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات → المهارات → إضافة مهارة → من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Firstp1ck/pi-coding-agent-forge.git /tmp/pi-coding-agent-forge
mkdir -p .claude/skills
cp -r /tmp/pi-coding-agent-forge/pi-skill-refactoring-advisor/skills/refactoring-advisor .claude/skills/refactoring-advisor
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Refactoring Advisor في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج Refactoring Advisor تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Refactoring Advisor بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تترتب أي تكلفة على المهارة غير المستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

Refactoring Advisor

Systematic code smell detection and safe refactoring planning. Every refactoring plan ensures the codebase compiles and passes tests at every intermediate step.

Quick Start

Identify and Plan a Refactoring

  1. Detect the smell: What's wrong and why does it matter?
  2. Assess the risk: What could break? How large is the blast radius?
  3. Check test coverage: Are the affected areas covered? If not, add tests first.
  4. Plan incremental steps: Each step should leave the code in a working state.
  5. Estimate effort: Size the work (S/M/L/XL) and identify dependencies.

Common Code Smells by Language

Rust

SmellDescriptionRefactoring
God structOne struct with too many fields/methodsExtract into smaller, focused structs
Unnecessary clones.clone() where borrowing would workReplace with borrows, use lifetimes
Stringly typedUsing String where an enum fitsIntroduce enum with From impls
Match explosionHuge match blocks that grow with every variantExtract match arms into methods, use trait dispatch
Unwrap sprawl.unwrap() scattered through non-test codeReplace with ? operator, proper error handling
Leaky abstractionpub on internal implementation detailsReduce to pub(crate) or pub(super)
Monolithic lib.rsEverything in one fileSplit into focused modules
Over-genericGenerics where a concrete type sufficesSimplify to concrete types until generics are needed

TypeScript / React

SmellDescriptionRefactoring
Prop drillingProps passed through 3+ component levelsExtract to context, composition, or custom hook
God componentComponent with 200+ lines or multiple responsibilitiesSplit into focused components
Barrel file bloatIndex files re-exporting everythingDirect imports, remove barrel files
Any escape hatchas any or // @ts-ignore hiding type issuesFix the types, use type guards or discriminated unions
useEffect spaghettiMultiple unrelated effects in one componentSplit effects, extract to custom hooks
Inline styles sprawlStyles defined inline instead of using design systemExtract to CSS modules, Tailwind classes, or styled components
Callback prop chainsPassing callbacks through many layersUse context or state management
State duplicationSame data stored in multiple state variablesDerive computed values, single source of truth

Django / Python

SmellDescriptionRefactoring
Fat viewsBusiness logic in views instead of servicesExtract to service layer
Circular importsModules importing each otherRestructure boundaries, use lazy imports
God modelOne model with 20+ fields and many methodsSplit into related models, use composition
N+1 queriesDatabase queried in a loopAdd select_related() / prefetch_related()
Magic stringsHardcoded strings for choices, status, etc.Use TextChoices / IntegerChoices enums
Untyped functionsMissing type hints on public functionsAdd type annotations, run mypy
Test-free codeNo tests for critical business logicAdd tests before refactoring
Signal spaghettiComplex logic hidden in Django signalsReplace with explicit method calls

Refactoring Safety Protocol

Before Any Refactoring

  1. Verify test coverage. Run existing tests. If the area being refactored has no tests, write characterization tests first.
  2. Create a checkpoint. Ensure all changes are committed. The refactoring starts from a clean state.
  3. Define the end state. What does "done" look like? How will you verify success?

During Refactoring

  1. One change at a time. Each commit should be a single, focused refactoring step.
  2. Compile after every change. (cargo check, tsc --noEmit, python -m py_compile)
  3. Run tests after every change. If tests fail, fix before proceeding.
  4. No behavior changes. Refactoring changes structure, not behavior. If behavior must change, do it in a separate step.

After Refactoring

  1. Full test suite passes.
  2. Clippy / ESLint / Ruff clean. No new warnings introduced.
  3. Review the diff. Does the change accomplish what was intended? Any accidental behavior changes?

Refactoring Plan Template

When proposing a refactoring, use this structure:

markdown
## Refactoring Plan: [Description]

**Target:** [File/module/component]
**Smell:** [What's wrong]
**Goal:** [What "done" looks like]
**Risk:** Low / Medium / High
**Effort:** S / M / L / XL
**Test coverage:** Adequate / Needs improvement first

### Pre-requisites
- [ ] Tests pass on current code
- [ ] [Any additional pre-reqs]

### Steps

1. **[Step 1 description]**
   - Files affected: [list]
   - Verification: `cargo check && cargo test`

2. **[Step 2 description]**
   - Files affected: [list]
   - Verification: `cargo check && cargo test`

[... more steps ...]

### Rollback
If issues arise: `git revert` to the last passing commit.

### Success Criteria
- [ ] All tests pass
- [ ] No new clippy/lint warnings
- [ ] [Specific architectural improvement verified]

Migration Strategies

Pattern: Strangler Fig

For gradually replacing a legacy module:

  1. Create the new module alongside the old one
  2. Route new features through the new module
  3. Gradually migrate existing callers
  4. Remove the old module when all callers are migrated

Best for: Large-scale replacements where a clean cut is risky.

Pattern: Branch by Abstraction

For replacing an implementation behind an interface:

  1. Introduce an abstraction (trait/interface) over the current implementation
  2. Update callers to use the abstraction
  3. Implement the new version behind the same abstraction
  4. Switch the wiring (dependency injection, feature flag)
  5. Remove the old implementation

Best for: Swapping implementations (database, API client, algorithm).

Pattern: Parallel Change (Expand-Contract)

For changing a widely-used interface:

  1. Expand: Add the new interface alongside the old one
  2. Migrate: Update callers one by one to use the new interface
  3. Contract: Remove the old interface

Best for: API changes, function signature updates, data structure migrations.


Integration

  • Data: Refactoring plans and outcomes logged to MEMORY.md
  • Tests: Always verify test coverage before and after. Use cargo test -- --test-threads=1, bun test, or uv run pytest
  • Tech debt: If a refactoring is deferred, add it to the tech debt registry in MEMORY.md

Arc skill — Refactoring strategies and code smell detection

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي Refactoring Advisor؟

Agents should invoke this skill for refactors, code smells, migrations, duplication removal, module splitting, API cleanup, or restructuring plans. Emphasizes small safe steps, behavior preservation, and verification after each change.

لماذا تستخدم Refactoring Advisor على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Refactoring Advisor عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Refactoring Advisor في TypingMind؟

افتح الإضافات → المهارات → التثبيت من GitHub في TypingMind والصق https://github.com/Firstp1ck/pi-coding-agent-forge/tree/main/pi-skill-refactoring-advisor/skills/refactoring-advisor. يقرأ TypingMind ملف SKILL.md الخاص بها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Refactoring Advisor؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Refactoring Advisor؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Refactoring Advisor معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Refactoring Advisor مجانية؟

نعم. نشرها Firstp1ck على GitHub بموجب ترخيص MIT. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا البريدية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇