|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Repository Overview |
| 6 | + |
| 7 | +This is the **ServiceNow Developer Program's Code Snippets Repository** - a community-driven collection of ServiceNow development code examples and utilities. The repository contains 900+ code snippets organized into 50+ categories covering all aspects of ServiceNow platform development. |
| 8 | + |
| 9 | +## Repository Structure and Organization |
| 10 | + |
| 11 | +### Directory Structure |
| 12 | +All code snippets follow a standardized four-level structure: |
| 13 | +``` |
| 14 | +Top-Level Category/ |
| 15 | +├── Sub-Category/ |
| 16 | +│ ├── Specific-Use-Case/ |
| 17 | +│ │ ├── README.md # Description and usage instructions |
| 18 | +│ │ ├── script.js # Main code implementation |
| 19 | +│ │ └── variant.js # Optional code variations |
| 20 | +``` |
| 21 | + |
| 22 | +### Top-Level Categories (REQUIRED Structure) |
| 23 | +The repository is organized into **6 major categories**. All contributions MUST use these categories: |
| 24 | + |
| 25 | +- **Core ServiceNow APIs/**: Essential ServiceNow JavaScript APIs |
| 26 | + - `GlideRecord/`, `GlideAjax/`, `GlideSystem/`, `GlideDate/`, `GlideDateTime/`, `GlideElement/`, `GlideFilter/`, `GlideAggregate/`, `GlideHTTPRequest/`, `GlideModal/`, `GlideQuery/`, `GlideTableDescriptor/` |
| 27 | + |
| 28 | +- **Server-Side Components/**: Server-executed code |
| 29 | + - `Background Scripts/`, `Business Rules/`, `Script Includes/`, `Script Actions/`, `Scheduled Jobs/`, `Transform Map Scripts/`, `Server Side/`, `Inbound Actions/`, `Processors/` |
| 30 | + |
| 31 | +- **Client-Side Components/**: Browser-executed code |
| 32 | + - `Client Scripts/`, `Catalog Client Script/`, `UI Actions/`, `UI Scripts/`, `UI Pages/`, `UI Macros/`, `UX Client Scripts/`, `UX Client Script Include/`, `UX Data Broker Transform/` |
| 33 | + |
| 34 | +- **Modern Development/**: Modern ServiceNow frameworks |
| 35 | + - `Service Portal/`, `Service Portal Widgets/`, `NOW Experience/`, `GraphQL/`, `ECMASCript 2021/` |
| 36 | + |
| 37 | +- **Integration/**: External systems and data exchange |
| 38 | + - `Integration/` (original), `RESTMessageV2/`, `Import Set API/`, `Scripted REST Api/`, `Mail Scripts/`, `MIDServer/`, `Attachments/` |
| 39 | + |
| 40 | +- **Specialized Areas/**: Domain-specific functionality |
| 41 | + - `CMDB/`, `ITOM/`, `Performance Analytics/`, `ATF Steps/`, `Agile Development/`, `Advanced Conditions/`, `Browser Bookmarklets/`, `Browser Utilities/`, `Dynamic Filters/`, `Fix scripts/`, `Flow Actions/`, `Formula Builder/`, `Notifications/`, `On-Call Calendar/`, `Record Producer/`, `Regular Expressions/`, `Styles/` |
| 42 | + |
| 43 | +## Development Guidelines |
| 44 | + |
| 45 | +### Code Quality Standards |
| 46 | +- Each snippet must include comprehensive README.md documentation |
| 47 | +- Code should be relevant to ServiceNow developers |
| 48 | +- ES2021 features are allowed but should be clearly documented |
| 49 | +- Examples should expand meaningfully on official ServiceNow documentation |
| 50 | +- Quality over quantity - low-effort submissions are rejected |
| 51 | + |
| 52 | +### Contribution Requirements |
| 53 | +- **Mandatory Category Structure**: All contributions MUST use the 6 top-level categories. PRs with incorrect structure will be rejected. |
| 54 | +- **Descriptive Structure**: Changes must match pull request scope exactly |
| 55 | +- **No XML Exports**: Avoid ServiceNow record exports in favor of JavaScript code |
| 56 | +- **Documentation**: Every code snippet requires accompanying README.md |
| 57 | +- **Proper Categorization**: Place snippets in appropriate existing sub-categories within the required top-level structure |
| 58 | + |
| 59 | +### File Organization |
| 60 | +- Use descriptive folder names that clearly indicate functionality |
| 61 | +- Group related code variations in the same folder |
| 62 | +- Include screenshots or examples when helpful for understanding |
| 63 | +- Maintain consistent naming conventions across similar snippets |
| 64 | + |
| 65 | +## Common ServiceNow Development Patterns |
| 66 | + |
| 67 | +### GlideRecord Usage |
| 68 | +- Most snippets demonstrate proper GlideRecord query patterns |
| 69 | +- Security considerations with ACL enforcement examples |
| 70 | +- Performance optimization through proper query construction |
| 71 | +- Reference field handling and relationship traversal |
| 72 | + |
| 73 | +### Integration Patterns |
| 74 | +- REST API consumption and production examples |
| 75 | +- Authentication handling for external systems |
| 76 | +- Data transformation and mapping utilities |
| 77 | +- Error handling and logging best practices |
| 78 | + |
| 79 | +### Business Logic Implementation |
| 80 | +- Business Rules for event-driven processing |
| 81 | +- Background Scripts for administrative tasks |
| 82 | +- Client Scripts for form behavior and validation |
| 83 | +- UI Actions for custom user interactions |
| 84 | + |
| 85 | +## Testing and Validation |
| 86 | + |
| 87 | +### Code Verification |
| 88 | +- Test all code snippets in development environments before submission |
| 89 | +- Validate against multiple ServiceNow versions when possible |
| 90 | +- Consider security implications and access controls |
| 91 | +- Document any prerequisites or dependencies |
| 92 | + |
| 93 | +### Community Review Process |
| 94 | +- All contributions undergo peer review by Developer Advocates |
| 95 | +- Changes outside described scope result in rejection |
| 96 | +- Multiple submissions require separate branches in forked repositories |
| 97 | + |
| 98 | +## Security Considerations |
| 99 | + |
| 100 | +- Never include sensitive information (passwords, API keys, tokens) |
| 101 | +- Consider security implications of all code examples |
| 102 | +- Demonstrate proper access control patterns where applicable |
| 103 | +- Include warnings for potentially dangerous operations |
| 104 | + |
| 105 | +## Repository Maintenance |
| 106 | + |
| 107 | +### Branch Management |
| 108 | +- Main branch contains all approved code snippets |
| 109 | +- Use descriptive branch names for contributions |
| 110 | +- Create separate branches for different feature additions |
| 111 | + |
| 112 | +### File Management |
| 113 | +- No build processes or compilation required |
| 114 | +- Direct GitHub editing supported |
| 115 | +- Git-enabled IDEs like VS Code recommended for larger contributions |
| 116 | +- Standard .gitignore excludes only .DS_Store files |
| 117 | + |
| 118 | +This repository serves as a comprehensive reference for ServiceNow developers at all skill levels, emphasizing practical, tested solutions for real-world development scenarios. |
0 commit comments