snow-flow 3.6.1 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1398 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLAUDE_MD_TEMPLATE_VERSION = exports.CLAUDE_MD_TEMPLATE = void 0;
4
+ exports.CLAUDE_MD_TEMPLATE = `# Snow-Flow Configuration & Best Practices
5
+
6
+ This document provides comprehensive instructions for Snow-Flow, an advanced ServiceNow development and orchestration framework powered by Claude AI.
7
+
8
+ ## 🚨 ABSOLUTE RULE #1: NO MOCK DATA, NO PLACEHOLDERS, NO SHORTCUTS! 🚨
9
+
10
+ ### **EVERYTHING MUST BE REAL, COMPLETE, AND PRODUCTION-READY**
11
+
12
+ **⛔ ABSOLUTELY FORBIDDEN:**
13
+ - ❌ NO mock data, test data, or demo data
14
+ - ❌ NO placeholder code or stub implementations
15
+ - ❌ NO "TODO" comments or incomplete sections
16
+ - ❌ NO simulated responses or fake results
17
+ - ❌ NO shortcuts, quick fixes, or temporary solutions
18
+ - ❌ NO "this would normally..." explanations
19
+ - ❌ NO partial implementations or "proof of concepts"
20
+ - ❌ NO hardcoded test values or example data
21
+
22
+ **✅ MANDATORY REQUIREMENTS:**
23
+ - ✅ EVERY implementation must be COMPLETE and FUNCTIONAL
24
+ - ✅ ALL code must be PRODUCTION-READY
25
+ - ✅ TAKE THE TIME to write EVERYTHING properly
26
+ - ✅ IMPLEMENT all error handling, validation, and edge cases
27
+ - ✅ CREATE actual working solutions, not demonstrations
28
+ - ✅ BUILD real integrations, not simulations
29
+ - ✅ DEVELOP complete features, not prototypes
30
+ - ✅ DELIVER finished products, not drafts
31
+
32
+ **📝 Quality Standards:**
33
+ 1. **Complete Implementation** - Every feature fully implemented with all functionality
34
+ 2. **Real Data Operations** - Actual ServiceNow API calls with real responses
35
+ 3. **Comprehensive Error Handling** - All edge cases covered, all errors handled
36
+ 4. **Production-Grade Code** - Clean, maintainable, documented, tested
37
+ 5. **Full Validation** - Input validation, data verification, coherence checking
38
+ 6. **Actual Integration** - Real connections to ServiceNow, no mocked services
39
+ 7. **Thorough Testing** - Complete test coverage, not just happy path
40
+ 8. **Professional Documentation** - Detailed, accurate, complete documentation
41
+
42
+ **🎯 The Snow-Flow Commitment:**
43
+ When implementing ANY feature, no matter how complex or time-consuming:
44
+ - INVEST the time to do it RIGHT
45
+ - WRITE every line of code needed
46
+ - IMPLEMENT every validation required
47
+ - HANDLE every possible error
48
+ - CREATE comprehensive solutions
49
+ - BUILD production-ready systems
50
+ - DELIVER professional results
51
+
52
+ **Remember:** Users depend on Snow-Flow for REAL production ServiceNow environments.
53
+ There is NO room for shortcuts, placeholders, or incomplete implementations.
54
+ Every line of code matters. Every feature must work. Every implementation must be complete.
55
+
56
+ **TAKE THE TIME. DO IT RIGHT. NO EXCEPTIONS.**
57
+
58
+ ---
59
+
60
+ ## Table of Contents
61
+ 1. [Core Philosophy](#core-philosophy)
62
+ 2. [Fundamental Rules](#fundamental-rules)
63
+ 3. [ServiceNow Development Standards](#servicenow-development-standards)
64
+ 4. [MCP Server Capabilities](#mcp-server-capabilities)
65
+ 5. [Debugging Best Practices](#debugging-best-practices)
66
+ 6. [Command Reference](#command-reference)
67
+ 7. [Workflow Guidelines](#workflow-guidelines)
68
+
69
+ ## CRITICAL: Widget Debugging Must Use Local Sync
70
+
71
+ ### 🔴 When User Reports Widget Issues, ALWAYS Use \`snow_pull_artifact\` FIRST!
72
+
73
+ **Common scenarios that REQUIRE Local Sync:**
74
+ - "Widget skips questions" → \`snow_pull_artifact\`
75
+ - "Form doesn't submit properly" → \`snow_pull_artifact\`
76
+ - "Data not displaying" → \`snow_pull_artifact\`
77
+ - "Button doesn't work" → \`snow_pull_artifact\`
78
+ - "Debug this widget" → \`snow_pull_artifact\`
79
+ - "Fix widget issue" → \`snow_pull_artifact\`
80
+
81
+ **DO NOT use \`snow_query_table\` for widget debugging!** It will hit token limits and you can't use native search/edit tools.
82
+
83
+ ## Core Philosophy
84
+
85
+ ### The Prime Directive: Verify, Don't Assume
86
+
87
+ Snow-Flow operates on evidence-based development. Never make assumptions about what exists or doesn't exist in a ServiceNow environment. Every environment is unique with custom tables, fields, integrations, and configurations that you cannot predict.
88
+
89
+ **Cardinal Rules:**
90
+ 1. If code references something, it probably exists
91
+ 2. Test before declaring something broken
92
+ 3. Verify before modifying
93
+ 4. Fix only what's confirmed broken
94
+ 5. Respect existing configurations
95
+
96
+ ### The Verification-First Approach
97
+
98
+ \`\`\`javascript
99
+ // Before claiming anything doesn't work or exist:
100
+ // Step 1: Test the actual implementation - COMPLETE TEST, NO MOCK
101
+ const verify = await snow_execute_script_with_output({
102
+ script: \`
103
+ // REAL verification code - NO placeholders
104
+ var gr = new GlideRecord('actual_table_name');
105
+ gr.addQuery('active', true);
106
+ gr.query();
107
+ var count = 0;
108
+ while (gr.next()) {
109
+ count++;
110
+ gs.info('Record found: ' + gr.getDisplayValue());
111
+ }
112
+ gs.info('Total records: ' + count);
113
+ \`
114
+ });
115
+
116
+ // Step 2: Check if resources exist - ACTUAL CHECK, NO ASSUMPTIONS
117
+ const tableCheck = await snow_discover_table_fields({
118
+ table_name: 'potentially_custom_table'
119
+ });
120
+
121
+ // Step 3: Validate configurations - REAL VALIDATION
122
+ const propertyCheck = await snow_property_manager({
123
+ action: 'get',
124
+ name: 'system.property'
125
+ });
126
+
127
+ // Step 4: Only then make informed decisions based on REAL DATA
128
+ \`\`\`
129
+
130
+ ### 🔄 CRITICAL: Sync User Modifications Before Working
131
+
132
+ **When a user mentions they've modified an artifact directly in ServiceNow, ALWAYS fetch the latest version first!**
133
+
134
+ If a user says any of these:
135
+ - "I've updated the widget in ServiceNow"
136
+ - "I made some changes to the flow"
137
+ - "I modified the script"
138
+ - "I adjusted the configuration"
139
+ - "Ik heb het zelf aangepast" (Dutch: I adjusted it myself)
140
+
141
+ **YOU MUST:**
142
+
143
+ 1. **Immediately fetch the current version from ServiceNow:**
144
+ \`\`\`javascript
145
+ // For any artifact the user has modified
146
+ const currentVersion = await snow_query_table({
147
+ table: 'artifact_table_name',
148
+ query: \`sys_id=\${artifact_sys_id}\`,
149
+ fields: ['*'], // Get all fields
150
+ limit: 1
151
+ });
152
+
153
+ // Or for widgets specifically
154
+ const widgetData = await snow_query_table({
155
+ table: 'sp_widget',
156
+ query: \`sys_id=\${widget_sys_id}\`,
157
+ fields: ['name', 'template', 'client_script', 'script', 'css', 'option_schema'],
158
+ limit: 1
159
+ });
160
+
161
+ // Or use snow_get_by_sysid for comprehensive retrieval
162
+ const artifact = await snow_get_by_sysid({
163
+ table: 'table_name',
164
+ sys_id: 'the_sys_id'
165
+ });
166
+ \`\`\`
167
+
168
+ 2. **Analyze the user's modifications:**
169
+ - Review what they changed
170
+ - Understand their intent
171
+ - Preserve their modifications
172
+
173
+ 3. **Build upon their changes:**
174
+ - Don't overwrite their work
175
+ - Integrate new features with their modifications
176
+ - Maintain their code style and patterns
177
+
178
+ 4. **Inform the user:**
179
+ - Acknowledge that you've fetched their latest changes
180
+ - Summarize what modifications you found
181
+ - Explain how you'll build upon their work
182
+
183
+ **Example Workflow:**
184
+ \`\`\`javascript
185
+ // User: "I've updated the widget to add a loading spinner"
186
+ // Snow-Flow response:
187
+
188
+ // 1. Fetch current version
189
+ const widget = await snow_query_table({
190
+ table: 'sp_widget',
191
+ query: \`sys_id=\${widgetSysId}\`,
192
+ fields: ['*'],
193
+ limit: 1
194
+ });
195
+
196
+ // 2. Analyze changes
197
+ console.log("✅ Fetched your latest widget version from ServiceNow");
198
+ console.log("📝 I see you've added a loading spinner in the template");
199
+
200
+ // 3. Work with the updated version
201
+ // ... make additional changes based on user's modifications ...
202
+ \`\`\`
203
+
204
+ **Why This Matters:**
205
+ - User modifications are not tracked locally
206
+ - Working with outdated versions causes conflicts
207
+ - User's work could be lost if not synced
208
+ - Builds trust by respecting user's contributions
209
+ - Ensures coherent development flow
210
+
211
+ ## Fundamental Rules
212
+
213
+ ### Rule 1: 🚨 ES5 JavaScript ONLY in ServiceNow - NO EXCEPTIONS!
214
+
215
+ **⚠️ CRITICAL WARNING: ServiceNow uses Rhino engine - ES6/ES7/ES8+ WILL FAIL!**
216
+
217
+ ServiceNow's server-side JavaScript runs on Mozilla Rhino which **ONLY supports ES5 (2009)**. Any modern JavaScript syntax will cause **RUNTIME ERRORS**.
218
+
219
+ **❌ THESE WILL CRASH SERVICENOW (DO NOT USE):**
220
+ \`\`\`javascript
221
+ // ❌ ES6+ features that BREAK ServiceNow:
222
+ const data = []; // SyntaxError: missing ; after for-loop initializer
223
+ let items = []; // SyntaxError: missing ; after for-loop initializer
224
+ const fn = () => {}; // SyntaxError: syntax error
225
+ var msg = \`Hello \${name}\`; // SyntaxError: syntax error
226
+ for (let item of items){} // SyntaxError: missing ; after for-loop initializer
227
+ var {name, id} = user; // SyntaxError: destructuring declaration not supported
228
+ array.forEach(x => {}); // SyntaxError: syntax error
229
+ array.map(x => x.id); // SyntaxError: syntax error
230
+ function test(param = 'default') {} // SyntaxError: syntax error
231
+ class MyClass {} // SyntaxError: missing ; after for-loop initializer
232
+ \`\`\`
233
+
234
+ **✅ ONLY USE ES5 SYNTAX (THIS WORKS):**
235
+ \`\`\`javascript
236
+ // ✅ ES5 compatible code that WORKS in ServiceNow:
237
+ var data = [];
238
+ var items = [];
239
+ function fn() { return 'result'; }
240
+ var msg = 'Hello ' + name;
241
+ for (var i = 0; i < items.length; i++) {
242
+ var item = items[i];
243
+ }
244
+ var name = user.name;
245
+ var id = user.id;
246
+ for (var j = 0; j < array.length; j++) {
247
+ // Process array[j]
248
+ }
249
+ function test(param) {
250
+ if (typeof param === 'undefined') param = 'default';
251
+ }
252
+ \`\`\`
253
+
254
+ **🔥 COMMON MISTAKES THAT BREAK SERVICENOW:**
255
+ 1. **Arrow Functions**: \`() => {}\` → Use \`function() {}\`
256
+ 2. **Template Literals**: \`\` \`\${var}\` \`\` → Use \`'text ' + var\`
257
+ 3. **Let/Const**: \`let x\` → Use \`var x\`
258
+ 4. **Destructuring**: \`{a, b} = obj\` → Use \`obj.a\`, \`obj.b\`
259
+ 5. **For...of**: \`for (x of arr)\` → Use \`for (var i=0; i<arr.length; i++)\`
260
+ 6. **Default Parameters**: \`fn(x='default')\` → Use \`typeof x === 'undefined'\`
261
+ 7. **Array Methods with Arrows**: \`.map(x => x)\` → Use \`.map(function(x) { return x; })\`
262
+
263
+ ### Rule 2: Background Scripts for Verification Only (Not Widget Updates!)
264
+
265
+ **CRITICAL DISTINCTION:**
266
+ - ✅ Use background scripts for TESTING and VERIFICATION
267
+ - ❌ Do NOT use background scripts to UPDATE widget fields
268
+ - ✅ Use \`snow_update\` to directly modify widget records
269
+ - ❌ Do NOT try to import server scripts into client scripts via background scripts
270
+
271
+ **🚨 ES5 ENFORCEMENT FOR BACKGROUND SCRIPTS:**
272
+ Background scripts run on ServiceNow's server-side Rhino engine. **EVERY background script MUST be ES5-only or it will fail.**
273
+
274
+ **Quick ES5 Validation Checklist:**
275
+ - [ ] No \`const\` or \`let\` (only \`var\`)
276
+ - [ ] No arrow functions \`() => {}\` (only \`function() {}\`)
277
+ - [ ] No template literals \`\` \`\${var}\` \`\` (only string concatenation)
278
+ - [ ] No destructuring \`{a, b} = obj\` (only explicit \`obj.a\`)
279
+ - [ ] No \`for...of\` loops (only traditional \`for\` loops)
280
+ - [ ] No default parameters (use \`typeof\` checks)
281
+ - [ ] No modern array methods with arrows (use traditional functions)
282
+
283
+ Background scripts are excellent for verification and debugging, but widget updates must go through proper MCP tools.
284
+
285
+ **NEW: Auto-Confirm Mode for Background Scripts (v3.4.10+)**
286
+ You can now skip the human-in-the-loop confirmation for trusted scripts:
287
+
288
+ \`\`\`javascript
289
+ // Standard mode - requires user confirmation (ES5 ONLY!)
290
+ snow_execute_background_script({
291
+ script: "var gr = new GlideRecord('incident'); gr.query();", // ✅ ES5 syntax
292
+ description: "Query incidents",
293
+ allowDataModification: false
294
+ });
295
+
296
+ // Auto-confirm mode - executes immediately ⚠️ USE WITH CAUTION!
297
+ snow_execute_background_script({
298
+ script: "var gr = new GlideRecord('incident'); gr.query();", // ✅ ES5 syntax
299
+ description: "Query incidents",
300
+ allowDataModification: false,
301
+ autoConfirm: true // ⚠️ Bypasses user confirmation!
302
+ });
303
+
304
+ // ❌ WRONG - This will FAIL in ServiceNow:
305
+ // script: "const gr = new GlideRecord('incident'); gr.query();", // SyntaxError!
306
+ // script: "incidents.forEach(i => console.log(i.number));", // SyntaxError!
307
+ \`\`\`
308
+
309
+ **🚨 ES5 Validation Required:**
310
+ Before using any background script tool, validate your script is ES5-only:
311
+ - No \`const\`/\`let\` (use \`var\`)
312
+ - No arrow functions (use \`function()\`)
313
+ - No template literals (use string concatenation)
314
+ - No destructuring (use explicit property access)
315
+
316
+ **⚠️ Security Warning:**
317
+ - Only use \`autoConfirm: true\` for verified, safe scripts
318
+ - High-risk operations will still be logged
319
+ - All auto-executions are tracked with audit IDs
320
+ - Default behavior (without autoConfirm) remains unchanged
321
+
322
+ ## 🚨 CRITICAL: Common ES5 Mistakes That Break ServiceNow
323
+
324
+ ServiceNow developers frequently use modern JavaScript that fails on the Rhino engine. Here are the most common mistakes:
325
+
326
+ ### 🔥 Top ES5 Violations (Fix These Immediately!)
327
+
328
+ **1. Arrow Functions with Array Methods**
329
+ \`\`\`javascript
330
+ // ❌ BREAKS ServiceNow:
331
+ var activeIncidents = incidents.filter(inc => inc.active);
332
+ var numbers = activeIncidents.map(inc => inc.number);
333
+
334
+ // ✅ WORKS in ServiceNow:
335
+ var activeIncidents = [];
336
+ for (var i = 0; i < incidents.length; i++) {
337
+ if (incidents[i].active) {
338
+ activeIncidents.push(incidents[i]);
339
+ }
340
+ }
341
+ var numbers = [];
342
+ for (var j = 0; j < activeIncidents.length; j++) {
343
+ numbers.push(activeIncidents[j].number);
344
+ }
345
+ \`\`\`
346
+
347
+ **2. Template Literals for String Building**
348
+ \`\`\`javascript
349
+ // ❌ BREAKS ServiceNow:
350
+ var message = \`Incident \${incident.number} assigned to \${user.name}\`;
351
+
352
+ // ✅ WORKS in ServiceNow:
353
+ var message = 'Incident ' + incident.number + ' assigned to ' + user.name;
354
+ \`\`\`
355
+
356
+ **3. Const/Let Variable Declarations**
357
+ \`\`\`javascript
358
+ // ❌ BREAKS ServiceNow:
359
+ const MAX_RETRIES = 3;
360
+ let currentUser = gs.getUser();
361
+
362
+ // ✅ WORKS in ServiceNow:
363
+ var MAX_RETRIES = 3;
364
+ var currentUser = gs.getUser();
365
+ \`\`\`
366
+
367
+ **4. Object Destructuring**
368
+ \`\`\`javascript
369
+ // ❌ BREAKS ServiceNow:
370
+ var {name, email, department} = user;
371
+ var {sys_id: id, short_description: desc} = incident;
372
+
373
+ // ✅ WORKS in ServiceNow:
374
+ var name = user.name;
375
+ var email = user.email;
376
+ var department = user.department;
377
+ var id = incident.sys_id;
378
+ var desc = incident.short_description;
379
+ \`\`\`
380
+
381
+ **5. For...of Loops**
382
+ \`\`\`javascript
383
+ // ❌ BREAKS ServiceNow:
384
+ for (let incident of incidents) {
385
+ gs.info('Processing: ' + incident.number);
386
+ }
387
+
388
+ // ✅ WORKS in ServiceNow:
389
+ for (var i = 0; i < incidents.length; i++) {
390
+ gs.info('Processing: ' + incidents[i].number);
391
+ }
392
+ \`\`\`
393
+
394
+ **6. Default Function Parameters**
395
+ \`\`\`javascript
396
+ // ❌ BREAKS ServiceNow:
397
+ function processIncident(incident, priority = 3, assignee = 'unassigned') {
398
+ // Process incident
399
+ }
400
+
401
+ // ✅ WORKS in ServiceNow:
402
+ function processIncident(incident, priority, assignee) {
403
+ if (typeof priority === 'undefined') priority = 3;
404
+ if (typeof assignee === 'undefined') assignee = 'unassigned';
405
+ // Process incident
406
+ }
407
+ \`\`\`
408
+
409
+ ### 🎯 Quick ES5 Conversion Guide
410
+ | Modern (ES6+) | ES5 Equivalent |
411
+ |---------------|----------------|
412
+ | \`const x = 5;\` | \`var x = 5;\` |
413
+ | \`let items = [];\` | \`var items = [];\` |
414
+ | \`() => {}\` | \`function() {}\` |
415
+ | \`\` \`Hello \${name}\` \`\` | \`'Hello ' + name\` |
416
+ | \`{a, b} = obj\` | \`var a = obj.a; var b = obj.b;\` |
417
+ | \`for (item of items)\` | \`for (var i = 0; i < items.length; i++)\` |
418
+ | \`func(x = 'default')\` | \`if (typeof x === 'undefined') x = 'default';\` |
419
+ | \`arr.map(x => x.id)\` | \`arr.map(function(x) { return x.id; })\` |
420
+
421
+ \`\`\`javascript
422
+ // Universal verification pattern - COMPLETE IMPLEMENTATION REQUIRED
423
+ const verify = await snow_execute_script_with_output({
424
+ script: \`
425
+ gs.info('=== VERIFICATION TEST ===');
426
+
427
+ // Test ACTUAL table existence - NO PLACEHOLDERS
428
+ var incidentTable = new GlideRecord('incident');
429
+ gs.info('Incident table valid: ' + incidentTable.isValid());
430
+
431
+ // Count REAL records
432
+ incidentTable.addQuery('active', true);
433
+ incidentTable.query();
434
+ var count = 0;
435
+ while (incidentTable.next() && count < 10) {
436
+ count++;
437
+ gs.info('Found: ' + incidentTable.number + ' - ' + incidentTable.short_description);
438
+ }
439
+ gs.info('Total active incidents: ' + incidentTable.getRowCount());
440
+
441
+ // Test ACTUAL property - use real property names
442
+ var instanceName = gs.getProperty('instance_name');
443
+ var glideVersion = gs.getProperty('glide.version');
444
+ gs.info('Instance: ' + instanceName);
445
+ gs.info('Version: ' + glideVersion);
446
+
447
+ // Test COMPLETE user code - NO STUBS
448
+ try {
449
+ // REAL implementation - not placeholder
450
+ var userGr = new GlideRecord('sys_user');
451
+ userGr.addQuery('active', true);
452
+ userGr.addQuery('user_name', gs.getUserName());
453
+ userGr.query();
454
+ if (userGr.next()) {
455
+ gs.info('Current user: ' + userGr.name + ' (' + userGr.email + ')');
456
+ gs.info('Roles: ' + userGr.roles.toString());
457
+ }
458
+
459
+ // Test ACTUAL business logic
460
+ var taskGr = new GlideRecord('task');
461
+ taskGr.addQuery('assigned_to', gs.getUserID());
462
+ taskGr.addQuery('active', true);
463
+ taskGr.query();
464
+ gs.info('Active tasks assigned to me: ' + taskGr.getRowCount());
465
+
466
+ gs.info('=== VERIFICATION COMPLETE ===');
467
+ } catch(e) {
468
+ gs.error('ERROR: ' + e.message);
469
+ gs.error('Stack: ' + e.stack);
470
+ }
471
+ \`
472
+ });
473
+ \`\`\`
474
+
475
+ ### Rule 3: Widget Coherence - Critical Client-Server Communication
476
+
477
+ ServiceNow widgets MUST have perfect communication between client and server scripts. This is not optional - widgets fail when these components don't talk to each other correctly.
478
+
479
+ **The Three-Way Contract:**
480
+
481
+ **Server Script Must:**
482
+ - Initialize all \`data\` properties that HTML will reference
483
+ - Handle every \`input.action\` that client sends
484
+ - Return data in the format client expects
485
+
486
+ **Client Script Must:**
487
+ - Implement every method that HTML calls via \`ng-click\`
488
+ - Use \`c.server.get({action: 'name'})\` for server communication
489
+ - Update \`c.data\` when server responds
490
+
491
+ **HTML Template Must:**
492
+ - Only reference \`data\` properties that server provides
493
+ - Only call methods that client implements
494
+ - Use correct Angular directives and bindings
495
+
496
+ **Critical Communication Points:**
497
+
498
+ 1. **Server → Client Data Flow**
499
+ - Server sets \`data.property\`
500
+ - Client receives via \`c.data.property\`
501
+ - HTML displays with \`{{data.property}}\`
502
+
503
+ 2. **Client → Server Requests**
504
+ - Client sends \`c.server.get({action: 'name'})\`
505
+ - Server receives via \`input.action\`
506
+ - Server processes and returns updated \`data\`
507
+
508
+ 3. **HTML → Client Method Calls**
509
+ - HTML has \`ng-click="methodName()"\`
510
+ - Client must have \`$scope.methodName = function()\`
511
+ - Method typically calls server with \`c.server.get()\`
512
+
513
+ **Common Failures to Avoid:**
514
+ - Action name mismatches between client and server
515
+ - Method name mismatches between HTML and client
516
+ - Property name mismatches between server and HTML
517
+ - Missing handlers for client requests
518
+ - Orphaned data properties or methods
519
+
520
+ **Coherence Validation Checklist:**
521
+ - [ ] Every \`data.property\` in server is used in HTML/client
522
+ - [ ] Every \`ng-click\` in HTML has matching \`$scope.method\` in client
523
+ - [ ] Every \`c.server.get({action})\` in client has matching \`if(input.action)\` in server
524
+ - [ ] Data flows correctly: Server → HTML → Client → Server
525
+ - [ ] No orphaned methods or unused data properties
526
+
527
+ ### Rule 4: Use Local Sync for Widget Debugging - NOT snow_query_table!
528
+
529
+ **CRITICAL: When debugging widgets, ALWAYS use \`snow_pull_artifact\` first!**
530
+
531
+ \`\`\`javascript
532
+ // ✅ CORRECT - Use Local Sync for widget debugging
533
+ snow_pull_artifact({
534
+ sys_id: 'widget_sys_id',
535
+ table: 'sp_widget'
536
+ });
537
+ // Now use Claude Code native search, multi-file edit, etc.
538
+
539
+ // ❌ WRONG - Don't use snow_query_table for debugging widgets
540
+ snow_query_table({
541
+ table: 'sp_widget',
542
+ query: 'sys_id=...',
543
+ fields: ['template', 'script', 'client_script']
544
+ });
545
+ // This hits token limits and can't use native tools!
546
+ \`\`\`
547
+
548
+ **Why Local Sync for Widget Debugging:**
549
+ - **No token limits** - Handle widgets of ANY size
550
+ - **Native search** - Find issues across all files instantly
551
+ - **Multi-file view** - See relationships between components
552
+ - **Better debugging** - Trace data flow, find missing methods
553
+ - **Coherence checking** - Validate all parts work together
554
+
555
+ **Widget Debugging Workflow:**
556
+ 1. User reports issue → \`snow_pull_artifact\`
557
+ 2. Search for error patterns across files
558
+ 3. Fix using multi-file edit
559
+ 4. Validate coherence → \`snow_validate_artifact_coherence\`
560
+ 5. Push fixes back → \`snow_push_artifact\`
561
+
562
+ **IMPORTANT: Use Local Sync Instead of Query for Large Widgets**
563
+
564
+ When you see "exceeds maximum allowed tokens" errors, don't try to fetch fields separately with \`snow_query_table\`. Use Local Sync instead:
565
+
566
+ \`\`\`javascript
567
+ // ❌ WRONG - Don't do this when debugging:
568
+ snow_query_table({ table: 'sp_widget', fields: ['name'] });
569
+ snow_query_table({ table: 'sp_widget', fields: ['script'] });
570
+ snow_query_table({ table: 'sp_widget', fields: ['client_script'] });
571
+ // This is inefficient and can't use native tools!
572
+
573
+ // ✅ CORRECT - Use Local Sync:
574
+ snow_pull_artifact({
575
+ sys_id: '01d01d6983176a502a7ea130ceaad376'
576
+ });
577
+ // All files available locally with NO token limits!
578
+ \`\`\`
579
+
580
+ **Local Sync Benefits:**
581
+ - Handles widgets of ANY size automatically
582
+ - All files available for native tool usage
583
+ - Maintains relationships between components
584
+ - Enables powerful search and refactoring
585
+
586
+ ### Rule 5: Evidence-Based Debugging
587
+
588
+ Follow this systematic approach for all debugging:
589
+
590
+ 1. **Reproduce** - Run the exact failing code
591
+ 2. **Inventory** - List all dependencies
592
+ 3. **Verify** - Test each dependency exists
593
+ 4. **Fix** - Correct only confirmed issues
594
+
595
+ **Fix only:**
596
+ - ✅ Confirmed syntax errors
597
+ - ✅ Verified null references
598
+ - ✅ Missing dependencies (after verification)
599
+ - ✅ Real type mismatches
600
+
601
+ **Never change:**
602
+ - ❌ Unverified resources
603
+ - ❌ Configurations that "seem wrong"
604
+ - ❌ APIs you haven't tested
605
+ - ❌ Working code that could be "better"
606
+
607
+ ## ServiceNow Development Standards
608
+
609
+ ### Table Operations
610
+ - Always verify table existence before operations
611
+ - Use proper field types and references
612
+ - Check for ACLs and permissions
613
+ - Handle large datasets with pagination
614
+
615
+ ### Script Development
616
+ - Use Script Includes for reusable code
617
+ - Implement proper error handling
618
+ - Add meaningful logging with gs.info/warn/error
619
+ - Test in scoped applications when applicable
620
+ - **NEVER use background scripts to update widget fields - use \`snow_update\` instead**
621
+
622
+ ### Widget Development
623
+
624
+ **🚨 NO MOCK WIDGETS - EVERY WIDGET MUST BE COMPLETE AND FUNCTIONAL**
625
+
626
+ **CRITICAL: Direct Widget Updates (Not Background Scripts!)**
627
+ - Use \`snow_update({ type: 'widget', identifier: 'widget_name', config: { /* COMPLETE fields */ }})\`
628
+ - Updates widget fields DIRECTLY on the widget record
629
+ - Do NOT use background scripts to update widget fields
630
+ - Do NOT try to import server scripts into client scripts
631
+
632
+ **Widget Coherence Requirements:**
633
+ - Ensure HTML/Client/Server scripts communicate properly
634
+ - Use Angular providers correctly
635
+ - Implement proper data binding
636
+ - Test across different themes and portals
637
+ - **NO PLACEHOLDER CONTENT - Every widget must be production-ready**
638
+
639
+ **Creating New Widgets - COMPLETE IMPLEMENTATION REQUIRED:**
640
+ \`\`\`javascript
641
+ // ❌ WRONG - Mock/placeholder widget
642
+ snow_deploy({
643
+ type: 'widget',
644
+ config: {
645
+ name: 'test_widget',
646
+ template: '<div>TODO: Add content</div>', // NO!
647
+ script: '// TODO: Add logic', // NO!
648
+ client_script: '// Placeholder' // NO!
649
+ }
650
+ })
651
+
652
+ // ✅ CORRECT - Complete, functional widget
653
+ snow_deploy({
654
+ type: 'widget',
655
+ config: {
656
+ name: 'incident_dashboard_widget',
657
+ title: 'Incident Dashboard',
658
+ template: \`
659
+ <div class="incident-dashboard">
660
+ <div class="dashboard-header">
661
+ <h2>{{data.title}}</h2>
662
+ <span class="refresh-time">{{data.lastRefresh}}</span>
663
+ </div>
664
+ <div class="stats-container">
665
+ <div class="stat-card" ng-repeat="stat in data.stats">
666
+ <div class="stat-value">{{stat.value}}</div>
667
+ <div class="stat-label">{{stat.label}}</div>
668
+ </div>
669
+ </div>
670
+ <div class="incident-list">
671
+ <table class="table">
672
+ <thead>
673
+ <tr>
674
+ <th>Number</th>
675
+ <th>Short Description</th>
676
+ <th>Priority</th>
677
+ <th>Assigned To</th>
678
+ </tr>
679
+ </thead>
680
+ <tbody>
681
+ <tr ng-repeat="incident in data.incidents" ng-click="c.openIncident(incident.sys_id)">
682
+ <td>{{incident.number}}</td>
683
+ <td>{{incident.short_description}}</td>
684
+ <td><span class="priority-{{incident.priority}}">{{incident.priority}}</span></td>
685
+ <td>{{incident.assigned_to}}</td>
686
+ </tr>
687
+ </tbody>
688
+ </table>
689
+ </div>
690
+ </div>
691
+ \`,
692
+ script: \`
693
+ // COMPLETE server-side implementation
694
+ (function() {
695
+ data.title = 'Incident Dashboard';
696
+ data.lastRefresh = new GlideDateTime().getDisplayValue();
697
+
698
+ // Get incident statistics
699
+ data.stats = [];
700
+
701
+ var totalGr = new GlideAggregate('incident');
702
+ totalGr.addQuery('active', true);
703
+ totalGr.addAggregate('COUNT');
704
+ totalGr.query();
705
+ if (totalGr.next()) {
706
+ data.stats.push({
707
+ value: totalGr.getAggregate('COUNT'),
708
+ label: 'Total Active'
709
+ });
710
+ }
711
+
712
+ var criticalGr = new GlideAggregate('incident');
713
+ criticalGr.addQuery('active', true);
714
+ criticalGr.addQuery('priority', '1');
715
+ criticalGr.addAggregate('COUNT');
716
+ criticalGr.query();
717
+ if (criticalGr.next()) {
718
+ data.stats.push({
719
+ value: criticalGr.getAggregate('COUNT'),
720
+ label: 'Critical'
721
+ });
722
+ }
723
+
724
+ // Get recent incidents
725
+ data.incidents = [];
726
+ var incGr = new GlideRecord('incident');
727
+ incGr.addQuery('active', true);
728
+ incGr.orderByDesc('sys_created_on');
729
+ incGr.setLimit(10);
730
+ incGr.query();
731
+
732
+ while (incGr.next()) {
733
+ data.incidents.push({
734
+ sys_id: incGr.getUniqueValue(),
735
+ number: incGr.getValue('number'),
736
+ short_description: incGr.getValue('short_description'),
737
+ priority: incGr.getValue('priority'),
738
+ assigned_to: incGr.assigned_to.getDisplayValue()
739
+ });
740
+ }
741
+
742
+ // Handle server actions
743
+ if (input && input.action === 'refresh') {
744
+ // Refresh logic
745
+ data.lastRefresh = new GlideDateTime().getDisplayValue();
746
+ }
747
+ })();
748
+ \`,
749
+ client_script: \`
750
+ function($scope, $window, spModal) {
751
+ var c = this;
752
+
753
+ // Initialize client controller
754
+ c.refreshInterval = null;
755
+
756
+ // Open incident in new window
757
+ c.openIncident = function(sysId) {
758
+ var url = '/nav_to.do?uri=incident.do?sys_id=' + sysId;
759
+ $window.open(url, '_blank');
760
+ };
761
+
762
+ // Refresh data
763
+ c.refresh = function() {
764
+ c.server.get({
765
+ action: 'refresh'
766
+ }).then(function(response) {
767
+ console.log('Dashboard refreshed');
768
+ });
769
+ };
770
+
771
+ // Auto-refresh every 30 seconds
772
+ c.startAutoRefresh = function() {
773
+ c.refreshInterval = setInterval(function() {
774
+ $scope.$apply(function() {
775
+ c.refresh();
776
+ });
777
+ }, 30000);
778
+ };
779
+
780
+ // Clean up on destroy
781
+ $scope.$on('$destroy', function() {
782
+ if (c.refreshInterval) {
783
+ clearInterval(c.refreshInterval);
784
+ }
785
+ });
786
+
787
+ // Start auto-refresh
788
+ c.startAutoRefresh();
789
+ }
790
+ \`,
791
+ css: \`
792
+ .incident-dashboard {
793
+ padding: 20px;
794
+ background: #f5f5f5;
795
+ }
796
+
797
+ .dashboard-header {
798
+ display: flex;
799
+ justify-content: space-between;
800
+ margin-bottom: 20px;
801
+ }
802
+
803
+ .stats-container {
804
+ display: flex;
805
+ gap: 15px;
806
+ margin-bottom: 20px;
807
+ }
808
+
809
+ .stat-card {
810
+ flex: 1;
811
+ background: white;
812
+ padding: 15px;
813
+ border-radius: 8px;
814
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
815
+ text-align: center;
816
+ }
817
+
818
+ .stat-value {
819
+ font-size: 32px;
820
+ font-weight: bold;
821
+ color: #333;
822
+ }
823
+
824
+ .stat-label {
825
+ font-size: 14px;
826
+ color: #666;
827
+ margin-top: 5px;
828
+ }
829
+
830
+ .incident-list {
831
+ background: white;
832
+ border-radius: 8px;
833
+ padding: 15px;
834
+ }
835
+
836
+ .incident-list tr {
837
+ cursor: pointer;
838
+ }
839
+
840
+ .incident-list tr:hover {
841
+ background: #f0f0f0;
842
+ }
843
+
844
+ .priority-1 { color: #d9534f; font-weight: bold; }
845
+ .priority-2 { color: #f0ad4e; }
846
+ .priority-3 { color: #5bc0de; }
847
+ .priority-4 { color: #5cb85c; }
848
+ .priority-5 { color: #777; }
849
+ \`,
850
+ option_schema: [
851
+ {
852
+ name: 'refresh_interval',
853
+ label: 'Refresh Interval (seconds)',
854
+ type: 'integer',
855
+ default: 30
856
+ },
857
+ {
858
+ name: 'max_incidents',
859
+ label: 'Maximum Incidents to Display',
860
+ type: 'integer',
861
+ default: 10
862
+ }
863
+ ]
864
+ }
865
+ })
866
+ \`\`\`
867
+
868
+ **Updating Existing Widgets:**
869
+ \`\`\`javascript
870
+ snow_update({
871
+ type: 'widget',
872
+ identifier: 'my_widget', // Name or sys_id
873
+ config: {
874
+ template: '<div>Updated HTML</div>', // Only update what changes
875
+ script: 'data.updated = true;' // ServiceNow uses 'script' field
876
+ }
877
+ })
878
+ \`\`\`
879
+
880
+ ### Flow Development
881
+ - Use proper trigger conditions
882
+ - Implement error handling paths
883
+ - Add appropriate logging actions
884
+ - Test with various data scenarios
885
+
886
+ ## MCP Server Capabilities
887
+
888
+ Snow-Flow includes 16+ specialized MCP servers with over 200 tools for comprehensive ServiceNow integration:
889
+
890
+ ### 1. ServiceNow Deployment Server
891
+ **Purpose:** Widget and artifact deployment with coherence validation
892
+
893
+ **Key Tools:**
894
+ - \`snow_deploy\` - Create NEW artifacts (widgets, pages, etc.) - use with \`type: 'widget'\`
895
+ - \`snow_update\` - UPDATE existing artifacts - use for widget field updates
896
+ - \`snow_validate_deployment\` - Validate deployed artifacts
897
+ - \`snow_rollback_deployment\` - Rollback failed deployments
898
+ - \`snow_preview_widget\` - Preview widget before deployment
899
+ - \`snow_widget_test\` - Test widget functionality
900
+
901
+ **Special Features:**
902
+ - Automatic widget coherence validation
903
+ - Data flow contract verification
904
+ - Method implementation checking
905
+ - CSS class validation
906
+
907
+ ### 2. ServiceNow Operations Server
908
+ **Purpose:** Core ServiceNow operations and queries
909
+
910
+ **Key Tools:**
911
+ - \`snow_query_table\` - Universal table querying with pagination
912
+ - \`snow_query_incidents\` - Query and analyze incidents
913
+ - \`snow_cmdb_search\` - Search Configuration Management Database
914
+ - \`snow_user_lookup\` - Find and manage users
915
+ - \`snow_operational_metrics\` - Get operational metrics
916
+ - \`snow_knowledge_search\` - Search knowledge base
917
+
918
+ **Features:**
919
+ - Full CRUD operations on any table
920
+ - Advanced query capabilities
921
+ - Field discovery and validation
922
+ - Relationship navigation
923
+
924
+ ### 3. ServiceNow Automation Server
925
+ **Purpose:** Script execution and automation
926
+
927
+ **🚨 CRITICAL: ALL SCRIPTS MUST BE ES5 ONLY!**
928
+ ServiceNow runs on Rhino engine - ES6+ syntax will cause SyntaxError and script failure.
929
+
930
+ **Key Tools:**
931
+ - \`snow_execute_background_script\` - Execute background scripts (**ES5 ONLY!** with optional autoConfirm)
932
+ - \`snow_confirm_script_execution\` - Confirm script execution after user approval
933
+ - \`snow_execute_script_with_output\` - Execute scripts with output capture (**ES5 ONLY!**)
934
+ - \`snow_get_script_output\` - Retrieve script execution history
935
+ - \`snow_execute_script_sync\` - Synchronous script execution (**ES5 ONLY!**)
936
+ - \`snow_get_logs\` - Access system logs
937
+ - \`snow_test_rest_connection\` - Test REST integrations
938
+ - \`snow_trace_execution\` - Trace script execution (**ES5 ONLY!**)
939
+ - \`snow_schedule_job\` - Create scheduled jobs
940
+ - \`snow_create_event\` - Trigger system events
941
+
942
+ **Remember:** Use \`var\`, \`function(){}\`, string concatenation, traditional for loops only!
943
+
944
+ **Features:**
945
+ - Full output capture (gs.print/info/warn/error)
946
+ - Execution history tracking
947
+ - System log access
948
+ - REST message testing
949
+ - Performance tracing
950
+
951
+ ### 4. ServiceNow Platform Development Server
952
+ **Purpose:** Platform development artifacts
953
+
954
+ **Key Tools:**
955
+ - \`snow_create_ui_page\` - Create UI pages
956
+ - \`snow_create_script_include\` - Create reusable scripts
957
+ - \`snow_create_business_rule\` - Create business rules
958
+ - \`snow_create_client_script\` - Create client-side scripts
959
+ - \`snow_create_ui_policy\` - Create UI policies
960
+ - \`snow_create_ui_action\` - Create UI actions
961
+
962
+ **Features:**
963
+ - Full artifact creation
964
+ - Proper scoping support
965
+ - Condition builder integration
966
+ - Script validation
967
+
968
+ ### 5. ServiceNow Integration Server
969
+ **Purpose:** Integration and data management
970
+
971
+ **Key Tools:**
972
+ - \`snow_create_rest_message\` - Create REST integrations
973
+ - \`snow_create_transform_map\` - Create data transformation maps
974
+ - \`snow_create_import_set\` - Manage import sets
975
+ - \`snow_test_web_service\` - Test web services
976
+ - \`snow_configure_email\` - Configure email settings
977
+
978
+ **Features:**
979
+ - REST/SOAP integration
980
+ - Data transformation
981
+ - Import/Export capabilities
982
+ - Email configuration
983
+
984
+ ### 6. ServiceNow System Properties Server
985
+ **Purpose:** System property management
986
+
987
+ **Key Tools:**
988
+ - \`snow_property_get\` - Retrieve property values
989
+ - \`snow_property_set\` - Set property values
990
+ - \`snow_property_list\` - List properties by pattern
991
+ - \`snow_property_delete\` - Remove properties
992
+ - \`snow_property_bulk_update\` - Bulk operations
993
+ - \`snow_property_export\` - Export to JSON
994
+ - \`snow_property_import\` - Import from JSON
995
+
996
+ **Features:**
997
+ - Full CRUD on sys_properties
998
+ - Bulk operations
999
+ - Import/Export capabilities
1000
+ - Property validation
1001
+
1002
+ ### 7. ServiceNow Update Set Server
1003
+ **Purpose:** Change management and deployment
1004
+
1005
+ **Key Tools:**
1006
+ - \`snow_update_set_create\` - Create new update sets
1007
+ - \`snow_update_set_switch\` - Switch active update set
1008
+ - \`snow_update_set_current\` - Get current update set
1009
+ - \`snow_update_set_complete\` - Mark as complete
1010
+ - \`snow_update_set_export\` - Export as XML
1011
+ - \`snow_ensure_active_update_set\` - Ensure update set is active
1012
+
1013
+ **Features:**
1014
+ - Full update set lifecycle
1015
+ - Change tracking
1016
+ - XML export/import
1017
+ - Conflict detection
1018
+
1019
+ ### 8. ServiceNow Development Assistant Server
1020
+ **Purpose:** Intelligent artifact search, editing and development assistance
1021
+
1022
+ **Key Tools:**
1023
+ - \`snow_find_artifact\` - Find any ServiceNow artifact by name/type
1024
+ - \`snow_edit_artifact\` - Edit existing artifacts intelligently
1025
+ - \`snow_get_by_sysid\` - Get artifact by sys_id
1026
+ - \`snow_analyze_artifact\` - Analyze artifact structure and dependencies
1027
+ - \`snow_comprehensive_search\` - Deep search across all tables
1028
+ - \`snow_analyze_requirements\` - Analyze development requirements
1029
+
1030
+ **Features:**
1031
+ - Pattern-based code generation
1032
+ - Best practice enforcement
1033
+ - Performance optimization
1034
+ - Security review
1035
+
1036
+ ### 9. ServiceNow Security & Compliance Server
1037
+ **Purpose:** Security and compliance management
1038
+
1039
+ **Key Tools:**
1040
+ - \`snow_create_security_policy\` - Create security policies
1041
+ - \`snow_audit_compliance\` - Compliance auditing
1042
+ - \`snow_scan_vulnerabilities\` - Vulnerability scanning
1043
+ - \`snow_assess_risk\` - Risk assessment
1044
+ - \`snow_review_access_control\` - ACL review
1045
+
1046
+ **Features:**
1047
+ - SOX/GDPR/HIPAA compliance
1048
+ - Security policy management
1049
+ - Vulnerability assessment
1050
+ - Access control validation
1051
+
1052
+ ### 10. ServiceNow Reporting & Analytics Server
1053
+ **Purpose:** Reporting and data visualization
1054
+
1055
+ **Key Tools:**
1056
+ - \`snow_create_report\` - Create reports
1057
+ - \`snow_create_dashboard\` - Create dashboards
1058
+ - \`snow_define_kpi\` - Define KPIs
1059
+ - \`snow_schedule_report\` - Schedule report delivery
1060
+ - \`snow_analyze_data_quality\` - Data quality analysis
1061
+
1062
+ **Features:**
1063
+ - Advanced reporting
1064
+ - Dashboard creation
1065
+ - KPI management
1066
+ - Scheduled delivery
1067
+
1068
+ ### 11. ServiceNow Machine Learning Server
1069
+ **Purpose:** AI/ML capabilities with TensorFlow.js and native ML integration
1070
+
1071
+ **Key Tools:**
1072
+ - \`ml_train_incident_classifier\` - Train incident classifier with LSTM neural networks
1073
+ - \`ml_predict_change_risk\` - Predict change risks
1074
+ - \`ml_detect_anomalies\` - Anomaly detection
1075
+ - \`ml_forecast_incidents\` - Incident forecasting with time series
1076
+ - \`ml_performance_analytics\` - Native Performance Analytics ML
1077
+ - \`ml_hybrid_recommendation\` - Hybrid ML recommendations
1078
+
1079
+ **Features:**
1080
+ - Predictive analytics
1081
+ - Pattern recognition
1082
+ - Anomaly detection
1083
+ - Process optimization
1084
+
1085
+ ### 12. ServiceNow Local Development Server
1086
+ **Purpose:** Bridge between ServiceNow artifacts and Claude Code's native development tools
1087
+
1088
+ **Key Tools:**
1089
+ - \`snow_pull_artifact\` - Pull any ServiceNow artifact to local files
1090
+ - \`snow_push_artifact\` - Push local changes back with validation
1091
+ - \`snow_validate_artifact_coherence\` - Validate artifact relationships
1092
+ - \`snow_list_supported_artifacts\` - List all supported artifact types
1093
+ - \`snow_sync_status\` - Check sync status of local artifacts
1094
+ - \`snow_sync_cleanup\` - Clean up local files after sync
1095
+ - \`snow_convert_to_es5\` - Convert modern JavaScript to ES5
1096
+
1097
+ **Features:**
1098
+ - Supports 12+ artifact types dynamically
1099
+ - Smart field chunking for large artifacts
1100
+ - ES5 validation for server-side scripts
1101
+ - Coherence validation for widgets
1102
+ - Full Claude Code native tool integration
1103
+
1104
+ **Supported Artifact Types:**
1105
+ - Service Portal Widgets (\`sp_widget\`)
1106
+ - Flow Designer Flows (\`sys_hub_flow\`)
1107
+ - Script Includes (\`sys_script_include\`)
1108
+ - Business Rules (\`sys_script\`)
1109
+ - UI Pages (\`sys_ui_page\`)
1110
+ - Client Scripts (\`sys_script_client\`)
1111
+ - UI Policies (\`sys_ui_policy\`)
1112
+ - REST Messages (\`sys_rest_message\`)
1113
+ - Transform Maps (\`sys_transform_map\`)
1114
+ - Scheduled Jobs (\`sysauto_script\`)
1115
+ - Fix Scripts (\`sys_script_fix\`)
1116
+
1117
+ ### 13. Snow-Flow Orchestration Server
1118
+ **Purpose:** Multi-agent coordination and task management
1119
+
1120
+ **Key Tools:**
1121
+ - \`swarm_init\` - Initialize agent swarms
1122
+ - \`agent_spawn\` - Create specialized agents
1123
+ - \`task_orchestrate\` - Orchestrate complex tasks
1124
+ - \`memory_search\` - Search persistent memory
1125
+ - \`neural_train\` - Train neural networks with TensorFlow.js
1126
+ - \`performance_report\` - Generate performance reports
1127
+
1128
+ **Features:**
1129
+ - Multi-agent coordination
1130
+ - Task orchestration
1131
+ - Neural network training (TensorFlow.js)
1132
+ - Memory management
1133
+ - Performance monitoring
1134
+
1135
+ ### Additional Servers:
1136
+
1137
+ **ServiceNow CMDB/Event/HR/CSM/DevOps Server** - CI management, event correlation, HR processes, customer service, DevOps pipelines
1138
+
1139
+ **ServiceNow Knowledge & Catalog Server** - Knowledge articles, service catalog items, catalog variables and policies
1140
+
1141
+ **ServiceNow Change/Virtual Agent/PA Server** - Change management, virtual agent NLU, predictive analytics
1142
+
1143
+ **ServiceNow Flow/Workspace/Mobile Server** - Flow Designer, workspace configuration, mobile app management
1144
+
1145
+ **Features:**
1146
+ - Multi-agent coordination
1147
+ - Task orchestration
1148
+ - Neural network training (TensorFlow.js)
1149
+ - Memory management
1150
+ - Performance monitoring
1151
+
1152
+ ## Local Development with Artifact Sync
1153
+
1154
+ ### Dynamic Artifact Synchronization
1155
+
1156
+ The Local Development Server enables editing ServiceNow artifacts using Claude Code's native file tools. This creates a powerful development bridge between ServiceNow and local development environments.
1157
+
1158
+ **Workflow:**
1159
+
1160
+ 1. **Pull Artifact to Local Files**
1161
+ \`\`\`javascript
1162
+ // Auto-detect artifact type
1163
+ snow_pull_artifact({ sys_id: 'any_sys_id' });
1164
+
1165
+ // Or specify table for faster pull
1166
+ snow_pull_artifact({
1167
+ sys_id: 'widget_sys_id',
1168
+ table: 'sp_widget'
1169
+ });
1170
+ \`\`\`
1171
+
1172
+ 2. **Edit with Claude Code Native Tools**
1173
+ - Full search capabilities across files
1174
+ - Multi-file editing and refactoring
1175
+ - Syntax highlighting and validation
1176
+ - Git-like diff viewing
1177
+ - Go-to-definition and references
1178
+
1179
+ 3. **Validate Coherence**
1180
+ \`\`\`javascript
1181
+ // Check artifact relationships
1182
+ snow_validate_artifact_coherence({
1183
+ sys_id: 'artifact_sys_id'
1184
+ });
1185
+ \`\`\`
1186
+
1187
+ 4. **Push Changes Back**
1188
+ \`\`\`javascript
1189
+ // Push with automatic validation
1190
+ snow_push_artifact({ sys_id: 'artifact_sys_id' });
1191
+
1192
+ // Force push despite warnings
1193
+ snow_push_artifact({
1194
+ sys_id: 'artifact_sys_id',
1195
+ force: true
1196
+ });
1197
+ \`\`\`
1198
+
1199
+ 5. **Clean Up**
1200
+ \`\`\`javascript
1201
+ // Remove local files after sync
1202
+ snow_sync_cleanup({ sys_id: 'artifact_sys_id' });
1203
+ \`\`\`
1204
+
1205
+ **Artifact Registry:**
1206
+
1207
+ Each artifact type is configured with:
1208
+ - Field mappings to local files
1209
+ - Context-aware wrappers for better editing
1210
+ - ES5 validation flags for server scripts
1211
+ - Coherence rules for interconnected fields
1212
+ - Preprocessors/postprocessors for data transformation
1213
+
1214
+ **File Structure Example:**
1215
+ \`\`\`
1216
+ /tmp/snow-flow-artifacts/
1217
+ ├── widgets/
1218
+ │ └── my_widget/
1219
+ │ ├── my_widget.html # Template
1220
+ │ ├── my_widget.server.js # Server script (ES5)
1221
+ │ ├── my_widget.client.js # Client script
1222
+ │ ├── my_widget.css # Styles
1223
+ │ ├── my_widget.config.json # Configuration
1224
+ │ └── README.md # Context & instructions
1225
+ ├── script_includes/
1226
+ │ └── MyScriptInclude/
1227
+ │ ├── MyScriptInclude.js # Script
1228
+ │ └── MyScriptInclude.docs.md # Documentation
1229
+ └── business_rules/
1230
+ └── my_rule/
1231
+ ├── my_rule.js # Rule script
1232
+ └── my_rule.condition.js # Condition
1233
+ \`\`\`
1234
+
1235
+ **Benefits:**
1236
+ - Use your favorite editor features
1237
+ - Full search and replace capabilities
1238
+ - Version control integration
1239
+ - Bulk operations across artifacts
1240
+ - Offline development capability
1241
+ - Advanced refactoring tools
1242
+
1243
+ ## Debugging Best Practices
1244
+
1245
+ ### Systematic Debugging Protocol
1246
+
1247
+ 1. **Reproduce the Issue**
1248
+ \`\`\`javascript
1249
+ // Always use ES5 and test exact code
1250
+ const result = await snow_execute_script_with_output({
1251
+ script: \`/* Exact failing code in ES5 */\`
1252
+ });
1253
+ \`\`\`
1254
+
1255
+ 2. **Verify Dependencies**
1256
+ - Check all referenced tables exist
1257
+ - Verify all properties are set
1258
+ - Confirm all fields are present
1259
+ - Test all integrations work
1260
+
1261
+ 3. **Test in Context**
1262
+ - Use same scope and variables
1263
+ - Include same imports
1264
+ - Test with same data
1265
+
1266
+ 4. **Apply Evidence-Based Fixes**
1267
+ - Fix only confirmed issues
1268
+ - Document why changes were made
1269
+ - Test fixes thoroughly
1270
+
1271
+ ### Common Verification Patterns
1272
+
1273
+ **Table Verification:**
1274
+ \`\`\`javascript
1275
+ var table = new GlideRecord('table_name');
1276
+ gs.info('Table exists: ' + table.isValid());
1277
+ \`\`\`
1278
+
1279
+ **Property Verification:**
1280
+ \`\`\`javascript
1281
+ var prop = gs.getProperty('property.name');
1282
+ gs.info('Property value: ' + (prop || 'NOT SET'));
1283
+ \`\`\`
1284
+
1285
+ **Field Verification:**
1286
+ \`\`\`javascript
1287
+ var gr = new GlideRecord('table');
1288
+ var element = gr.getElement('field_name');
1289
+ gs.info('Field exists: ' + (element ? 'Yes' : 'No'));
1290
+ \`\`\`
1291
+
1292
+ ## Command Reference
1293
+
1294
+ ### Core Commands
1295
+ - \`./snow-flow start\` - Start orchestration system
1296
+ - \`./snow-flow status\` - System status
1297
+ - \`./snow-flow monitor\` - Real-time monitoring
1298
+
1299
+ ### Agent Management
1300
+ - \`./snow-flow agent spawn <type>\` - Create agents
1301
+ - \`./snow-flow agent list\` - List active agents
1302
+
1303
+ ### Task Management
1304
+ - \`./snow-flow task create\` - Create tasks
1305
+ - \`./snow-flow task list\` - View task queue
1306
+
1307
+ ### Memory Operations
1308
+ - \`./snow-flow memory store <key> <data>\` - Store data
1309
+ - \`./snow-flow memory get <key>\` - Retrieve data
1310
+ - \`./snow-flow memory list\` - List all keys
1311
+
1312
+ ### SPARC Modes
1313
+ - \`./snow-flow sparc "<task>"\` - Orchestrator mode
1314
+ - \`./snow-flow sparc run <mode> "<task>"\` - Specific mode
1315
+ - \`./snow-flow sparc tdd "<feature>"\` - Test-driven development
1316
+
1317
+ ### Swarm Coordination
1318
+ - \`./snow-flow swarm "<objective>"\` - Multi-agent coordination
1319
+ - Options: \`--strategy\`, \`--mode\`, \`--parallel\`, \`--monitor\`
1320
+
1321
+ ## Workflow Guidelines
1322
+
1323
+ ### Development Workflow
1324
+ 1. **Plan** - Use TodoWrite for task management
1325
+ 2. **Verify** - Check existing resources
1326
+ 3. **Develop** - Follow ES5 standards
1327
+ 4. **Test** - Use background scripts
1328
+ 5. **Deploy** - Use update sets
1329
+ 6. **Validate** - Verify deployment
1330
+
1331
+ ### Testing Workflow
1332
+ 1. Run unit tests with background scripts
1333
+ 2. Test integrations with REST tools
1334
+ 3. Validate UI with widget coherence
1335
+ 4. Check performance with tracing
1336
+ 5. Review logs for errors
1337
+
1338
+ ### Debugging Workflow
1339
+ 1. Reproduce issue exactly
1340
+ 2. Gather evidence with scripts
1341
+ 3. Verify all assumptions
1342
+ 4. Apply minimal fixes
1343
+ 5. Test thoroughly
1344
+ 6. Document changes
1345
+
1346
+ ## Important Reminders
1347
+
1348
+ ### Always Remember
1349
+ - Every ServiceNow instance is unique
1350
+ - Custom implementations exist that you don't know about
1351
+ - Preview/beta features may be available
1352
+ - Organization-specific configurations are common
1353
+ - Test everything before making assumptions
1354
+
1355
+ ### Never Assume
1356
+ - That something doesn't exist without verification
1357
+ - That configurations are wrong without testing
1358
+ - That APIs aren't available without checking
1359
+ - That code won't work without running it
1360
+ - That you know better than existing implementations
1361
+
1362
+ ### Golden Rules
1363
+ 1. **Verify First** - Test before declaring broken
1364
+ 2. **ES5 Only** - No modern JavaScript in ServiceNow
1365
+ 3. **Evidence-Based** - Make decisions on facts, not assumptions
1366
+ 4. **Minimal Changes** - Fix only what's broken
1367
+ 5. **Respect Context** - Understand why things exist as they do
1368
+
1369
+ ## Conclusion
1370
+
1371
+ Snow-Flow is a powerful framework for ServiceNow development that demands **COMPLETE, PRODUCTION-READY IMPLEMENTATIONS** with absolutely **NO MOCK DATA, NO PLACEHOLDERS, and NO SHORTCUTS**.
1372
+
1373
+ **The Snow-Flow Standard:**
1374
+ - **EVERY** line of code must be complete and functional
1375
+ - **EVERY** feature must be fully implemented
1376
+ - **EVERY** integration must be real and working
1377
+ - **EVERY** solution must be production-ready
1378
+ - **NO EXCEPTIONS, NO EXCUSES**
1379
+
1380
+ By following these guidelines and the **NO MOCK DATA** principle, you ensure:
1381
+ - Reliable, maintainable ServiceNow solutions
1382
+ - Complete implementations that work in production
1383
+ - Professional-grade code that users can depend on
1384
+ - Real solutions to real problems
1385
+
1386
+ Remember:
1387
+ 1. **NO MOCK DATA** - Everything must be real
1388
+ 2. **TAKE THE TIME** - Do it right, no shortcuts
1389
+ 3. **COMPLETE IMPLEMENTATIONS** - Every feature, every time
1390
+ 4. **PRODUCTION READY** - Users depend on this being real
1391
+ 5. **VERIFY AND TEST** - With real data, real systems
1392
+
1393
+ Your job is to deliver **COMPLETE, WORKING SOLUTIONS**. Every implementation matters. Every line of code counts. Every feature must work.
1394
+
1395
+ **TAKE THE TIME. DO IT RIGHT. NO MOCK DATA. NO EXCEPTIONS.**`;
1396
+ // Add version constant to track template updates
1397
+ exports.CLAUDE_MD_TEMPLATE_VERSION = '3.6.1-NO-MOCK-DATA';
1398
+ //# sourceMappingURL=claude-md-template-old.js.map