> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devinenterprise.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Testen & Refactoring

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

<div id="overview">
  ## Übersicht
</div>

Devin kann bestehende Codebasen analysieren, Verbesserungsmöglichkeiten identifizieren oder von dir definierte Refactoring-Anforderungen umsetzen, ohne dabei die Funktionalität zu beeinträchtigen.

<div id="common-use-cases">
  ## Häufige Anwendungsfälle
</div>

1. Schreiben und Erweitern der Testabdeckung
2. Refactoring und Optimierung von Code
3. Entwicklung und Anpassung von API-Endpunkten
4. Performance-Optimierungen
5. Code Review und Qualitätssicherung
6. Automatisierte Test-Workflows über die [API-Referenz](/de/api-reference/overview)

<div id="example-prompts">
  ## Beispiel-Prompts
</div>

<AccordionGroup>
  <Accordion title="Unit-Test schreiben" icon="magnifying-glass">
    <PromptBlock>
      ```txt Write unit test theme={null}
      Kannst du https://github.com/markedjs/marked einrichten, das Command-Line-Tool mit dem --output/-o-Flag verwenden und dann einen Unit-Test hinzufügen, der das --output-Flag testet?
      Es sollten bereits ähnliche Tests in bin.test.js vorhanden sein, an die du anknüpfen kannst.
      ```
    </PromptBlock>
  </Accordion>

  <Accordion title="Endpoint-Refactoring" icon="gear-code">
    <PromptBlock>
      ```txt Endpoint refactor theme={null}
      Derzeit gilt: Wenn Nutzer:innen einen POST an <endpoint> senden, <describe endpoint behavior>. Es wäre besser, diesen Endpoint in zwei separate Endpoints aufzuteilen, da <explain reasoning>.
      <Describe what the first endpoint should do>.
      <Describe what the second endpoint should do>.
      Teste dies, indem du <explain how Devin can test each endpoint to verify it's on the right track>.
      ```
    </PromptBlock>
  </Accordion>

  <Accordion title="Allgemeines Refactoring" icon="code">
    <PromptBlock>
      ```txt General refactor theme={null}
      Lagere im Slack-Server AppRegistry in eine eigene Datei aus.
      ```
    </PromptBlock>
  </Accordion>
</AccordionGroup>

<div id="example-sessions">
  ## Beispiel-Sessions
</div>

<div id="code-coverage-tutorial">
  ### Tutorial zur Testabdeckung
</div>

Erfahren Sie in unserem ausführlichen Tutorial, wie Sie die Testabdeckung systematisch verbessern:

* Schreiben umfassender Unit-Tests
* Erkennen von Lücken in der Testabdeckung
* Implementieren fehlender Testfälle

[Code-Coverage-Tutorial ansehen](/de/use-cases/tutorials/code-coverage)

<div id="connect4-code-refactor">
  ### Connect4-Code-Refactoring
</div>

Eine vollständige Refactoring-Session, die Folgendes zeigt:

* Verbesserung der Code-Struktur
* Trennung von Komponenten
* Performance-Optimierung
* Verbesserung der Testabdeckung

**Session ansehen:**
[https://app.devin.ai/sessions/8965de5e3ae0436985bf3dd2e1a5b4af](https://app.devin.ai/sessions/8965de5e3ae0436985bf3dd2e1a5b4af)
