|
| 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 three-level structure: |
| 13 | +``` |
| 14 | +Category/ |
| 15 | +├── Specific-Use-Case/ |
| 16 | +│ ├── README.md # Description and usage instructions |
| 17 | +│ ├── script.js # Main code implementation |
| 18 | +│ └── variant.js # Optional code variations |
| 19 | +``` |
| 20 | + |
| 21 | +### Major Categories |
| 22 | +- **Core ServiceNow APIs**: `GlideRecord/`, `GlideAjax/`, `GlideSystem/`, `GlideDate/`, `GlideDateTime/` |
| 23 | +- **Server-Side Components**: `Background Scripts/` (100+ examples), `Business Rules/` (150+ examples), `Script Includes/` |
| 24 | +- **Client-Side Components**: `Client Scripts/`, `Catalog Client Script/`, `UI Actions/`, `UI Scripts/` |
| 25 | +- **Modern Development**: `Service Portal/`, `NOW Experience/`, `GraphQL/`, `ECMASScript 2021/` |
| 26 | +- **Integration**: `Integration/`, `RESTMessageV2/`, `GlideHTTPRequest/`, `Import Set API/` |
| 27 | +- **Specialized Areas**: `CMDB/`, `ITOM/`, `Performance Analytics/`, `ATF Steps/` |
| 28 | + |
| 29 | +## Development Guidelines |
| 30 | + |
| 31 | +### Code Quality Standards |
| 32 | +- Each snippet must include comprehensive README.md documentation |
| 33 | +- Code should be relevant to ServiceNow developers |
| 34 | +- ES2021 features are allowed but should be clearly documented |
| 35 | +- Examples should expand meaningfully on official ServiceNow documentation |
| 36 | +- Quality over quantity - low-effort submissions are rejected |
| 37 | + |
| 38 | +### Contribution Requirements |
| 39 | +- **Descriptive Structure**: Changes must match pull request scope exactly |
| 40 | +- **No XML Exports**: Avoid ServiceNow record exports in favor of JavaScript code |
| 41 | +- **Documentation**: Every code snippet requires accompanying README.md |
| 42 | +- **Categorization**: Place snippets in appropriate existing categories or propose new ones |
| 43 | + |
| 44 | +### File Organization |
| 45 | +- Use descriptive folder names that clearly indicate functionality |
| 46 | +- Group related code variations in the same folder |
| 47 | +- Include screenshots or examples when helpful for understanding |
| 48 | +- Maintain consistent naming conventions across similar snippets |
| 49 | + |
| 50 | +## Common ServiceNow Development Patterns |
| 51 | + |
| 52 | +### GlideRecord Usage |
| 53 | +- Most snippets demonstrate proper GlideRecord query patterns |
| 54 | +- Security considerations with ACL enforcement examples |
| 55 | +- Performance optimization through proper query construction |
| 56 | +- Reference field handling and relationship traversal |
| 57 | + |
| 58 | +### Integration Patterns |
| 59 | +- REST API consumption and production examples |
| 60 | +- Authentication handling for external systems |
| 61 | +- Data transformation and mapping utilities |
| 62 | +- Error handling and logging best practices |
| 63 | + |
| 64 | +### Business Logic Implementation |
| 65 | +- Business Rules for event-driven processing |
| 66 | +- Background Scripts for administrative tasks |
| 67 | +- Client Scripts for form behavior and validation |
| 68 | +- UI Actions for custom user interactions |
| 69 | + |
| 70 | +## Testing and Validation |
| 71 | + |
| 72 | +### Code Verification |
| 73 | +- Test all code snippets in development environments before submission |
| 74 | +- Validate against multiple ServiceNow versions when possible |
| 75 | +- Consider security implications and access controls |
| 76 | +- Document any prerequisites or dependencies |
| 77 | + |
| 78 | +### Community Review Process |
| 79 | +- All contributions undergo peer review by Developer Advocates |
| 80 | +- Changes outside described scope result in rejection |
| 81 | +- Multiple submissions require separate branches in forked repositories |
| 82 | + |
| 83 | +## Security Considerations |
| 84 | + |
| 85 | +- Never include sensitive information (passwords, API keys, tokens) |
| 86 | +- Consider security implications of all code examples |
| 87 | +- Demonstrate proper access control patterns where applicable |
| 88 | +- Include warnings for potentially dangerous operations |
| 89 | + |
| 90 | +## Repository Maintenance |
| 91 | + |
| 92 | +### Branch Management |
| 93 | +- Main branch contains all approved code snippets |
| 94 | +- Use descriptive branch names for contributions |
| 95 | +- Create separate branches for different feature additions |
| 96 | + |
| 97 | +### File Management |
| 98 | +- No build processes or compilation required |
| 99 | +- Direct GitHub editing supported |
| 100 | +- Git-enabled IDEs like VS Code recommended for larger contributions |
| 101 | +- Standard .gitignore excludes only .DS_Store files |
| 102 | + |
| 103 | +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