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

# Deploy to Org

> Deploy Apex and LWC files directly from VS Code with one click.

<iframe width="100%" height="400" src="https://www.youtube.com/embed/YOUR_VIDEO_ID" title="Deploy to Org with MoxyCode" frameBorder="0" allowFullScreen />

MoxyCode deploys your Apex and LWC files directly to your Salesforce org from VS Code. When a deploy fails, MoxyCode opens the Deploy Errors panel automatically — ready to explain and fix every error without leaving your editor.

## How to deploy

### Right-click in the editor

Open any supported file in VS Code, right-click anywhere in the editor, and select **MoxyCode: Deploy to Org**.

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/moxycode/images/deploy-right-click-editor.png" alt="MoxyCode: Deploy to Org in the editor right-click menu" />
</Frame>

### Right-click in the Explorer panel

Right-click any supported file in the VS Code Explorer panel and select **MoxyCode: Deploy to Org**.

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/moxycode/images/deploy-right-click-explorer.png" alt="MoxyCode: Deploy to Org in the Explorer right-click menu" />
</Frame>

### Command Palette

Open the Command Palette (`Cmd+Shift+P` / `Ctrl+Shift+P`) and run:

MoxyCode: Deploy to Org

## On success

When the deploy succeeds, MoxyCode shows a notification at the bottom of VS Code:

**"MoxyCode: Deployment successful!"**

No action needed — your code is live in the org.

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/moxycode/images/deploy-success.png" alt="MoxyCode deployment successful notification" />
</Frame>

## On failure

When the deploy fails, MoxyCode shows a notification:

**"MoxyCode: n deployment error(s) found."**

The **MoxyCode — Deploy Errors** panel opens automatically in a new tab with every error listed and ready to fix.

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/moxycode/images/deploy-failure.png" alt="MoxyCode deployment error notification and Deploy Errors panel" />
</Frame>

<Note>
  Each new failed deploy resets the Deploy Errors panel with the latest errors. If the panel is already open from a previous deploy, it updates in place. If it was closed, it opens as a new tab.
</Note>

## Applying fixes

After generating fixes in the Deploy Errors panel, click **Apply Fix**. The button changes to **Fix Applied** and a notification appears:

**"MoxyCode: Fix applied — changed lines highlighted in green. Save to confirm."**

Changed lines are highlighted in green in your editor. From the notification you can:

* Click **Save File** to accept the changes
* Click **Undo Fix** to revert immediately

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/moxycode/images/deploy-fix-applied.png" alt="MoxyCode fix applied notification with Save File and Undo Fix options" />
</Frame>

<Note>
  You can also use `Cmd+Z` / `Ctrl+Z` at any time to undo an applied fix.
</Note>

## How MoxyCode understands your code

MoxyCode doesn't just read the file you deploy — it builds context from your wider codebase to give more accurate fixes.

### LWC bundles

When you deploy any file in an LWC component folder, MoxyCode deploys the entire bundle and reads all files in that folder — the `.js` controller, `.html` template, `.css` styles, and `.js-meta.xml`. This means when fixing a JavaScript error, MoxyCode knows what the HTML template expects, and vice versa.

<Tip>
  You can right-click any file in the LWC component folder to deploy the whole bundle — you don't need to select a specific file.
</Tip>

### Apex dependencies

When you deploy an Apex class, MoxyCode reads the classes it depends on. If your class calls another class, MoxyCode has context of that dependency when generating fixes — so suggestions are based on your actual codebase, not just the file being deployed.

## Supported file types

MoxyCode supports deploying the following file types:

| Extension  | Type                                    |
| ---------- | --------------------------------------- |
| `.cls`     | Apex class (including batch classes)    |
| `.trigger` | Apex trigger                            |
| `.js`      | LWC JavaScript (deploys full bundle)    |
| `.html`    | LWC HTML template (deploys full bundle) |

<Note>
  XML metadata files (`.xml`) are not supported in this release. Only code files listed above can be deployed with MoxyCode.
</Note>

## Common issues

<AccordionGroup>
  <Accordion title="MoxyCode: Deploy to Org not showing in the right-click menu">
    Make sure the active file is a supported type — `.cls`, `.trigger`, `.js`, or `.html`. MoxyCode only shows the deploy option for supported file types. If the option still doesn't appear, run **Developer: Reload Window** from the Command Palette.
  </Accordion>

  <Accordion title="Deploy succeeds but changes aren't reflected in the org">
    Make sure you are deploying to the correct org. Check your active Salesforce CLI default org by clicking the org name in the VS Code status bar. MoxyCode always deploys to whichever org is set as your CLI default.
  </Accordion>

  <Accordion title="Deploy Errors panel not opening after a failed deploy">
    MoxyCode only monitors deploys triggered via **MoxyCode: Deploy to Org**. If you used the Salesforce CLI directly or the SFDX commands, MoxyCode will not detect the errors. Use MoxyCode: Deploy to Org to get the automatic error panel.
  </Accordion>

  <Accordion title="Fix applied but I want to undo it">
    Click **Undo Fix** in the notification that appears after applying a fix, or use `Cmd+Z` / `Ctrl+Z` in the editor at any time to revert the change.
  </Accordion>

  <Accordion title="LWC deploy failing on a file I didn't change">
    LWC components deploy as a full bundle — all files in the component folder are deployed together. If another file in the bundle has an error, the deploy will fail even if you only changed one file. Check the Deploy Errors panel for the specific file and line causing the failure.
  </Accordion>
</AccordionGroup>

<CardGroup cols={2}>
  <Card title="Fix Deployment Errors" icon="wrench" href="/workflows/fix-deployment-errors">
    Learn how to analyse and fix errors after a failed deploy
  </Card>

  <Card title="Safe Mode" icon="shield" href="/configuration/safe-mode">
    Control when fixes are applied to your code
  </Card>
</CardGroup>
