npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

sf-utils-cli

v1.0.6

Published

A modern, web-based interface for executing SOQL queries, Anonymous Apex, and DML operations against Salesforce orgs with Monaco Editor

Readme

⚡ Salesforce Utils CLI

A modern, web-based interface for executing SOQL queries, Anonymous Apex, and DML operations against Salesforce orgs.

Salesforce Utils CLI Node.js Monaco Editor Version License

✨ Features

🔍 SOQL Query Execution

  • Execute SOQL queries with syntax highlighting
  • Support for Tooling API queries
  • Smart autocomplete for SObjects and fields
  • Real-time field suggestions based on your org's metadata
  • Relationship field navigation (e.g., Account.Owner.Name)
  • Query history with timestamps and record counts

⚡ Anonymous Apex Execution

  • Execute anonymous Apex code directly from the browser
  • View debug logs in real-time
  • See compilation and execution status
  • Detailed error messages with stack traces

📊 Data Management (DML Operations)

  • Insert - Create new records in bulk
  • Update - Modify existing records
  • Delete - Remove records with confirmation

🎨 Modern UI Features

  • Dark theme interface
  • Monaco Editor with IntelliSense
  • Sortable and filtable data tables
  • Pagination for large result sets
  • CSV export functionality
  • Keyboard shortcuts (Ctrl/Cmd + Enter to execute)

💾 Query History

  • Automatically saves successful queries
  • Stores up to 50 recent queries
  • View timestamp, record count, and org username
  • One-click to reload previous queries
  • Persistent storage using localStorage

Screenshots

query

Options

Results

Apex

Insert

🚀 Installation

Prerequisites

  • Node.js (v14 or higher)
  • Salesforce CLI (sf) installed and authenticated
  • mohanc sf plugin. Install it with:
    • sf plugins install sfdx-mohanc-plugins
  • At least one Salesforce org authenticated with the CLI

Install

 npm install -g sf-utils-cli

🎯 Usage

Starting the Server

Production mode:

sf-utils

The server will start on http://localhost:3456

Error: Port alredy in use

❌ Error: Port 3456 is already in use!

   Find and kill the process using port 3456:
     lsof -ti:3456 | xargs kill -9
     # or on Windows:
     netstat -ano | findstr :3456

Connecting to a Salesforce Org

  1. Enter your Salesforce org username or alias in the connection field
  2. Click Connect
  3. Wait for the green checkmark confirming connection

Tip: Use Salesforce CLI aliases for easier connection:

sf org login web --alias production
sf org login web --alias sandbox

Then simply use production or sandbox in the connection field.

📚 Examples

1. SOQL Queries

Basic Query

SELECT Id, Name, Industry, AnnualRevenue 
FROM Account 
WHERE Industry = 'Technology' 
LIMIT 10

Query with Relationships

SELECT Id, Name, Owner.Name, Owner.Email, 
       (SELECT Id, Subject, Status FROM Tasks)
FROM Account 
WHERE CreatedDate = THIS_MONTH

LIKE Query

SELECT Name, Code, DeveloperName
FROM AttributeDefinition
WHERE  DeveloperName  LIKE 'ATT_%'

NOT LIKE Query

SELECT Name, Code, DeveloperName
FROM AttributeDefinition
WHERE NOT DeveloperName  LIKE 'ATT_%'

Aggregate Query

SELECT Industry, COUNT(Id) AccountCount, AVG(AnnualRevenue) AvgRevenue
FROM Account
WHERE Industry != null
GROUP BY Industry
ORDER BY COUNT(Id) DESC

Tooling API Query

Enable "Use Tooling API" checkbox

SELECT Id, Name, Body, ApiVersion
FROM ApexClass
WHERE Name LIKE 'Test%'
ORDER BY Name

2. Anonymous Apex Code

Update Records Based on Query

List<Account> accts = [
    SELECT Id, Name
    FROM Account
    WHERE Name != null
];
for (Account a : accts) {
    a.Name2__c = a.Name;
}
update accts;
System.debug('Updated ' + accts.size() + ' accounts.');

Bulk Update with Custom Objects

List<AttributeDefinition> ads = [
    SELECT Name, Code, DeveloperName
    FROM AttributeDefinition
    WHERE NOT DeveloperName LIKE 'ATT_%'
];
for (AttributeDefinition a : ads) {
    a.DeveloperName = a.Code;
}
update ads;
System.debug('Updated ' + ads.size() + ' AttributeDefinitions.');

Data Processing and Logging

// Calculate and log opportunity statistics
List<Opportunity> opps = [
    SELECT Id, Name, Amount, StageName, CloseDate
    FROM Opportunity
    WHERE CloseDate = THIS_YEAR
];

Decimal totalAmount = 0;
Integer closedWon = 0;

for (Opportunity opp : opps) {
    if (opp.Amount != null) {
        totalAmount += opp.Amount;
    }
    if (opp.StageName == 'Closed Won') {
        closedWon++;
    }
}

System.debug('Total Opportunities: ' + opps.size());
System.debug('Closed Won: ' + closedWon);
System.debug('Total Amount: $' + totalAmount.setScale(2));

3. DML Operations

Insert Records

Format: Object:Field1,Field2|value1,value2|value3,value4

Account:Name,Industry,AnnualRevenue|Acme Corp,Technology,1000000|Global Inc,Finance,5000000

Update Records

Format: Object:Id,Field1,Field2|recordId,value1,value2

Account:Id,Name,Industry|001XXXXXXXXXXXXXXX,Updated Acme Corp,Technology

Delete Records

Format: Object:Id1,Id2,Id3

Account:001XXXXXXXXXXXXXXX,001YYYYYYYYYYYYYYY

⚙️ Features in Detail

Autocomplete (IntelliSense)

The editor provides intelligent autocomplete:

  • SOQL Keywords: Type SEL → suggests SELECT, WHERE, ORDER BY, etc.
  • SObject Names: After FROM, get a list of all objects in your org
  • Field Names: After SELECT, see all fields for the queried object
  • Relationship Fields: Type Account. to see related fields
  • Functions: Aggregate functions like COUNT(), SUM(), AVG()

Query History

  • Automatically saves successful queries
  • Shows timestamp, record count, and org
  • Click any query to reload it
  • Delete individual queries or clear all
  • Persists across browser sessions

Data Table Features

  • Sorting: Click column headers to sort ascending/descending
  • Search: Filter results across all columns
  • Pagination: Navigate through large datasets (50 records per page)
  • Export: Download results as CSV
  • Nested Objects: Automatically flattens related records (e.g., Owner.Name)

Keyboard Shortcuts

  • Ctrl/Cmd + Enter - Execute query/code
  • Standard Monaco Editor shortcuts:
    • Ctrl/Cmd + / - Toggle comment
    • Ctrl/Cmd + D - Select next occurrence
    • Alt + Up/Down - Move line up/down

🔧 Configuration

🐛 Troubleshooting

Connection Issues

Problem: "Failed to get org details"

  • Verify Salesforce CLI is installed: sf --version
  • Check org authentication: sf org list
  • Ensure the username/alias is correct

Query Errors

Problem: "No such column 'FieldName'"

  • Verify field exists in the object
  • Check field API name (custom fields end with __c)
  • Ensure proper permissions on the field

Apex Execution Issues

Problem: Apex code compilation fails

  • Check syntax errors in your code
  • Verify all variables are declared
  • Ensure proper object/field API names

Performance Issues

Problem: Large query results are slow

  • Add LIMIT clause to queries
  • Use pagination effectively
  • Consider using Tooling API for metadata queries

🔒 Security Considerations

  • This tool runs locally and uses your authenticated Salesforce CLI session
  • No credentials are stored in the application
  • All API calls use your CLI's access tokens
  • Run only in trusted environments
  • Do not expose the server port to public networks

📝 Best Practices

  1. Always test DML operations in sandbox first
  2. Use LIMIT clauses to avoid large data transfers
  3. Review queries in history before re-executing
  4. Enable "Use Tooling API" only for metadata queries
  5. Export important query results as CSV backups
  6. Use meaningful variable names in Apex code
  7. Add System.debug() statements for troubleshooting

📄 License

MIT License (c) Mohan Chinnappan

🙏 Acknowledgments

📞 Support

For issues related to:


Made with ⚡ for the Salesforce Developer Community