
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
3 weeks ago
Introduction:
NOW Assist for creator OOB has great skills to to generate servicenow development objects ( e.g client scripts, flows, Playbook generation). These plugins should be recommended and implemented for servicenow customers as a first preference.
Also, There are so many LLM models ( e.g Chatgpt, Claude) already which can generate servicenow code with effective prompt engineering.
I have explored and integrated cursor IDE with Claude LLM and servicenow instance for a bidirectional sync so that objects created, updated in cursor IDE can be synched to servicenow instances and also same object can be synched back to cursor.
Purpose:
This article is created to document steps to integrate servicenow instance and cursor for a bidirectional sync.
Solution:
π Bi-Directional Sync Setup (Cursor β ServiceNow)
1. Link ServiceNow App to GitHub Repo
-
Login to servicenow instance with admin role and navigate to Studio β Source Control > Link to Source Control
-
Connect to your GitHub (or GitLab, Azure Repos) repository.
-
With a successful connection, all artifacts (e.g Script Includes, Business Rules, Client Scripts) are stored as XML/JSON in Git.
- This is pretty standard config step which most of servicenow developers used to link source control for their custom apps.
β This is the "single source of truth" that both ServiceNow and Cursor will talk to.
2. Clone Repo in Cursor
git clone https://github.com/org/servicenow-app.git
cd servicenow-app
-
Open this repo in Cursor IDE.
-
Cursor now has full access to all ServiceNow files (like
sys_script_include_xxxx.xml
).
3. From Cursor β ServiceNow
-
In Cursor, ask AI chat with your required prompt like below :
"Create a new Script Include
UserUtils
with a methodgetManager(userId).
This method should return user's manager and userid will be passed as function param" -
Cursor will generate an XML file like:
<record_update table="sys_script_include" sys_id="auto_sys_id_here"> <sys_script_include action="INSERT_OR_UPDATE"> <name>UserUtils</name> <access>public</access> <client_callable>false</client_callable> <script><![CDATA[ var UserUtils = Class.create(); UserUtils.prototype = { initialize: function() {}, getManager: function(userId) { var user = new GlideRecord('sys_user'); if (user.get(userId)) { return user.manager; } return null; }, type: 'UserUtils' }; ]]></script> </sys_script_include> </record_update>
-
Cursor saves β commits β pushes to Git:
git add . git commit -m "Add UserUtils script include" git push origin main
-
In ServiceNow Studio β Source Control > Pull
-
The new Script Include now exists inside ServiceNow. π
-
4. Workflow: From ServiceNow β Cursor
-
Suppose a developer edits
UserUtils
Script Include directly in ServiceNow. -
In Studio β Source Control > Commit Changes
-
This pushes the new XML to GitHub.
-
-
In Cursor, run:
git pull origin main
-
Cursor now sees the updated script.
-
5. Automating Sync
Prerequisites
-
ServiceNow app already linked to Source Control (GitHub repo).
-
Personal Access Token for GitHub.
-
ServiceNow DevOps integration (or REST API credentials with
admin
+source_control
roles).
Add GitHub Action Workflow
Create a file in your repo:
.github/workflows/snc-sync.yml
name: ServiceNow Sync
on:
push:
branches:
- main
schedule:
- cron: "*/15 * * * *" # every 15 mins check SN β Git sync
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
# Step 1: Push changes from GitHub β ServiceNow
- name: Push GitHub changes to ServiceNow
run: |
curl -X POST \
"https://<your-instance>.service-now.com/api/sn_source_control/push" \
-u ${{ secrets.SNC_USER }}:${{ secrets.SNC_PASS }} \
-H "Content-Type: application/json" \
-d '{"applicationName": "<your-app-scope>"}'
# Step 2: Pull latest from ServiceNow β GitHub
- name: Pull ServiceNow changes into GitHub
run: |
curl -X POST \
"https://<your-instance>.service-now.com/api/sn_source_control/pull" \
-u ${{ secrets.SNC_USER }}:${{ secrets.SNC_PASS }} \
-H "Content-Type: application/json" \
-d '{"applicationName": "<your-app-scope>"}'
Store Secrets
In your GitHub repo β Settings > Secrets and Variables > Actions
Add:
-
SNC_USER
β ServiceNow admin user -
SNC_PASS
β password (or OAuth token if using DevOps app)
Workflow Behavior
-
Every push to
main
β auto-pushes into ServiceNow. -
Every 15 minutes β auto-pulls ServiceNow β commits back into GitHub.
-
Cursor just needs to pull latest GitHub changes (
git pull
), and itβs synced.
Cursor Setup
In Cursor, you can also add a post-save hook:
git add .
git commit -m "Cursor update"
git push origin main
So whenever you accept AI changes β they go straight to GitHub β GitHub Action syncs them into SN.
This way, both Cursor and ServiceNow are always in sync with GitHub in the middle.
End Result
-
Edit in Cursor β auto β GitHub β ServiceNow.
-
Edit in ServiceNow β auto β GitHub β Cursor (on next pull).
-
No manual clicking needed in Studio.
6. Limitations / Gotchas
-
My experience was better with client script,script includes and business rules for a scoped app development.
-
Flows (Flow Designer JSON) are harder to hand-edit β best edited in ServiceNow, but still sync via Git.You can still create a them using prompts in Cursor IDE.
-
You must always pull latest before editing in Cursor to avoid merge conflicts.
Conclusion:
You will be able to follow same solution for most of your preferred LLM models. Happy Exploring!.
β Recommended Setup
-
GitHub repo = single source of truth.
-
Cursor = your local editing + AI generation environment.
-
ServiceNow Studio = your in-instance editing environment.
-
Both sides push/pull to GitHub β automatic sync.
- 478 Views