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

# Cut a Feature Prompt from 42 to 12 ACUs

export const UseCaseHero = ({title, description, prompt, category, features, devinUrl, agent, intent, playbookId, type}) => {
  const encodedPrompt = encodeURIComponent(prompt || '');
  const tag = 'docs-use-case-gallery';
  const utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=hero-cta';
  const agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  const devinHref = type === 'schedule' ? 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + (prompt ? '&prompt=' + encodedPrompt : '') : type === 'review' ? 'https://app.devin.ai/review?' + utm : agent === 'ada' ? 'https://app.devin.ai/search?' + utm + '&noSubmit=true' + (prompt ? '&prompt=' + encodedPrompt : '') : devinUrl ? devinUrl.includes('?') ? devinUrl + '&' + utm + agentParams : devinUrl + '?' + utm + agentParams : prompt ? 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encodedPrompt : 'https://app.devin.ai/?' + utm + agentParams;
  const buttonLabel = type === 'schedule' ? 'Schedule in Devin ↗' : type === 'review' ? 'Set Up Devin Review ↗' : agent === 'advanced' ? 'Try in Devin ↗' : agent === 'dana' ? 'Try in Dana ↗' : agent === 'ada' ? 'Try in Ask Devin ↗' : 'Try in Devin ↗';
  const featureList = features ? features.split(',').map(f => f.trim()) : [];
  return <div className="uc-hero">
      <div className="uc-hero-inner">
        <div className="uc-hero-left">
          <h1 className="uc-hero-title">{title}</h1>
          <p className="uc-hero-desc">{description}</p>
          <div>
            <a href={devinHref} target="_blank" rel="noopener noreferrer" className="try-in-devin-btn">
              {buttonLabel}
            </a>
          </div>
        </div>
        <div className="uc-hero-meta">
          <div className="uc-meta-item">
            <span className="uc-meta-label">Author</span>
            <span className="uc-meta-value">Cognition</span>
          </div>
          <div className="uc-meta-item">
            <span className="uc-meta-label">Category</span>
            <span className="uc-meta-value">{category}</span>
          </div>
          {featureList.length > 0 && <div className="uc-meta-item">
              <span className="uc-meta-label">Features</span>
              <span className="uc-meta-value">{featureList.join(', ')}</span>
            </div>}
        </div>
      </div>
    </div>;
};

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>;
};

<UseCaseHero title="Cut a Feature Prompt from 42 to 12 ACUs" description="Walk through a real session that burned 3x the expected ACUs on a pagination task, pinpoint three root causes, and rewrite the prompt to save 70%." prompt="This session used 42 ACUs to add pagination to GET /api/users but I expected ~12. Break down where Devin spent the most time, what dead ends or wrong approaches it tried, and what context was missing from my prompt. Give me a revised, structured prompt that would avoid these issues." category="Devin Optimization" features="Advanced" agent="advanced" intent="analyze" />

<div className="uc-detail-wrapper">
  <Tip>Don't want to set this up manually? Paste a link to this page into a Devin session and ask it to set everything up for you.</Tip>

  <Steps>
    <Step title="The session that triggered the investigation">
      A developer asked Devin to add pagination to an API endpoint. The prompt was short and reasonable-sounding:

      <PromptBlock>
        ```txt Original prompt (vague) theme={null}
        Add pagination to GET /api/users. Run the tests when done.
        ```
      </PromptBlock>

      The session finished successfully — tests passed, the PR looked good. But it consumed **42 ACUs** for what should have been a **\~12 ACU** task. Three-and-a-half times the expected cost, on a feature that already had a working pattern elsewhere in the codebase.

      Here's how to find out what went wrong and make sure it doesn't happen again.
    </Step>

    <Step title="Start with Session Insights">
      Every completed session can have a free [Session Insights](/product-guides/session-insights) analysis. Click the **lightbulb icon** in the top bar of any finished session and then click **Generate Analysis** to trigger it — no Advanced session required.

      For this pagination session, Session Insights flagged:

      * **Issue Timeline** — Red marks at the 14-minute and 28-minute marks where Devin changed approaches entirely.
      * **Issues Detected** — "Incorrect codebase assumption: built pagination from scratch when `src/utils/paginate.ts` already existed" and "Wrong implementation type: used cursor-based pagination, but tests expect offset-based."
      * **Improved Prompt** — A rewritten version with the missing context filled in, ready to copy.
      * **ACU Usage** — 42 ACUs, flagged as disproportionate for the task scope.

      For many sessions, this is enough. Copy the improved prompt, start a new session, and compare. But if you want the full phase-by-phase cost breakdown, go deeper.
    </Step>

    <Step title="Get a phase-by-phase breakdown">
      Click **Investigate with Devin** in the Session Insights panel to launch a Devin session pre-loaded with the original session's full history. Or start a new session manually and describe what you want analyzed:

      <PromptBlock agent="advanced" intent="analyze">
        ```txt Analyze the pagination session theme={null}
        This session used 42 ACUs to add pagination to GET /api/users.
        I expected ~12. Break down:
        1. Where did Devin spend an abnormally long time?
        2. What dead ends or wrong approaches did it try?
        3. What could it have done more efficiently?
        4. What context was missing from my prompt?
        5. Give me a revised, structured prompt that would avoid these issues.
        ```
      </PromptBlock>

      Devin reviews every action from the original session and identifies where time was spent inefficiently:

      ```
      Session analysis | Task: Add pagination to GET /api/users
      Actual: 42 ACUs | Expected: ~12 ACUs

      Inefficiencies identified:

      1. Unnecessary exploration — investigation phase took abnormally long
         Devin explored 23 files looking for a pagination helper.
         It built pagination from scratch, then discovered
         src/utils/paginate.ts and had to refactor everything.
         Fix: Mention existing utilities in the prompt.

      2. Wrong approach — entire implementation had to be rewritten
         Devin implemented cursor-based pagination. Tests failed
         because the API uses offset-based. It rewrote the entire
         implementation from scratch.
         Fix: Specify "offset-based" in the prompt.

      3. Environment issue — repeated failed installs
         npm install failed twice due to a missing .npmrc config
         for the private registry. Devin retried with workarounds.
         Fix: Add registry config to repo setup.
      ```

      Three root causes, all preventable with a better prompt or repo configuration.
    </Step>

    <Step title="Rewrite the prompt and compare">
      You can ask Devin to start a new session with the improved prompt directly — no need to copy-paste. The analysis produces a structured prompt that includes exactly the context that was missing:

      <PromptBlock>
        ```txt Optimized prompt (structured) theme={null}
        Add offset-based pagination to GET /api/users.

        ## Context
        - Use our existing pagination utility at src/utils/paginate.ts
        - Follow the same pattern as GET /api/projects (already paginated)
        - Query params: page (default 1), limit (default 20, max 100)
        - Response shape: { data: User[], meta: { page, limit, total, totalPages } }

        ## Implementation
        1. Add page and limit query params with Zod validation
        2. Use paginate() from src/utils/paginate.ts to wrap the Prisma query
        3. Return the paginated response matching the shape above

        ## Testing
        - Run existing tests with npm test
        - Verify pagination works with 0 results, 1 page, and multiple pages
        - Verify invalid page/limit params return 400

        Do not open a PR until all tests pass.
        ```
      </PromptBlock>

      Compare the two prompts side by side:

      |                       | Original        | Optimized                   |
      | --------------------- | --------------- | --------------------------- |
      | **Pagination type**   | Not specified   | "offset-based"              |
      | **Existing utility**  | Not mentioned   | `src/utils/paginate.ts`     |
      | **Reference pattern** | None            | "same as GET /api/projects" |
      | **Response shape**    | Not specified   | Explicit schema             |
      | **Testing criteria**  | "Run the tests" | Specific edge cases         |
      | **ACU result**        | 42 ACUs         | \~12 ACUs                   |

      The optimized prompt eliminates all three root causes. Devin skips the 23-file exploration, picks the right pagination type on the first try, and follows a proven pattern.
    </Step>

    <Step title="Turn the findings into permanent fixes">
      A single prompt rewrite saves ACUs on one session. Turning the findings into permanent configuration saves ACUs on every future session.

      **Add recurring context to [Knowledge](/product-guides/knowledge).** The pagination analysis revealed two facts Devin needs repeatedly — the pagination type and the utility location. Add them as Knowledge entries so every session starts with that context automatically:

      * *"All API endpoints use offset-based pagination. The shared utility is at `src/utils/paginate.ts`. See GET /api/projects for the reference implementation."*
      * *"Run tests with `npm test`. Run type checks with `npm run typecheck`."*

      **Fix workspace issues in [environment configuration](/onboard-devin/environment).** The 3 ACUs wasted on `npm install` failures were caused by a missing `.npmrc` config for the private registry. Adding registry configuration to your environment prevents every future session from hitting that error.

      **Batch-analyze to find team-wide patterns.** If multiple developers are seeing high-ACU sessions, analyze several at once to find shared root causes:

      <PromptBlock agent="advanced" intent="analyze">
        ```txt Batch-analyze recent sessions theme={null}
        Here are 5 sessions from this week: [paste session links]

        Find common patterns of ACU waste across all of them. What
        knowledge entries should I add to prevent these issues in
        every future session?
        ```
      </PromptBlock>
    </Step>
  </Steps>
</div>
