How to delete an Apex Class from Production using VS Code?

Which method to choose?
There are various methods, including the Force.com IDE, Workbench, and Ant Migration Tool, to remove Apex classes from Production.
This guide will demonstrate how to use the Visual Studio Code IDE to remove a class or trigger from the production.
1. Create a project with manifest
First, create a project on Visual Studio Code, that is connected to your production environment. After authorizing successfully, retrieve the manifest.xml file from the source. Make sure that manifest.xml contains ApexClass as a member. After retrieving, you will see all the classes under the folder /force-app/classes.
Now, go to the specific class you want to delete.
2. Edit className.cls-meta.xml File
Let's say you want to get rid of the class badApexClass.

Go to your .cls-meta.xml file and change the status from Active to Deleted
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>55.0</apiVersion>
<status>Active</status>
</ApexClass>
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>55.0</apiVersion>
<status>Deleted</status>
</ApexClass>
3. Run the following command using the terminal
sfdx force:source:deploy -m ApexClass:badApexClass -l RunLocalTests -u ProjectAliasName
4. Check the Output
You should see something similar to this on your terminal:
=== Deployed Source
FULL NAME TYPE PROJECT PATH
─────────────────────────── ───────── ───────────────────────────────────────────────────────────────────────
badApexClass ApexClass force-app/main/default/classes/badApexClass.cls
badApexClass ApexClass force-app/main/default/classes/badApexClass.cls-meta.xml
=== Test Results Summary
Passing: 10
Failing: 0
Total: 10
Time: 12789
Deploy Succeeded.
Congratulations! You've successfully deleted that Apex class with minimal effort.


![[TIL] Javascrip Dev 1 - Summer '23 Review Notes](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fstock%2Funsplash%2Fg5jpH62pwes%2Fupload%2Ff6e5ea3bf48125018578ac2d51a1852f.jpeg&w=3840&q=75)
