云南网站开发,那种直播软件从哪里下载,联想企业网盘,怎么用云校建设学校网站概述Steering规则是指导Claude行为和输出风格的核心配置系统#xff0c;允许用户定制AI助手的响应方式#xff0c;确保输出符合特定项目要求、编码标准或团队偏好。一、Steering规则语法基本结构规则名称: 条件部分:- 触发条件1- 触发条件2行为约束:- 约束要求1- 约束要求2例…概述Steering规则是指导Claude行为和输出风格的核心配置系统允许用户定制AI助手的响应方式确保输出符合特定项目要求、编码标准或团队偏好。一、Steering规则语法基本结构规则名称: 条件部分: - 触发条件1 - 触发条件2 行为约束: - 约束要求1 - 约束要求2 例外情况: - 特殊情况处理语法元素条件语句when: - context_contains: 代码审查 - task_type: 编程2. 约束语句enforce: - max_line_length: 80 - require_comments: true3. 优先级标记priority: high # high, medium, low4. 作用域定义scope: - file_types: [.js, .ts] - project_phase: production二、代码风格约束缩进与格式code_style: indentation: type: spaces size: 2 tabs_for: [] # 语言列表 formatting: max_line_length: 100 wrap_lines: true spaces_around_operators: true括号与换行bracket_style: functions: same_line # same_line, next_line conditionals: same_line objects: same_line blank_lines: after_imports: 2 between_functions: 1 before_return: 1注释规范commenting: function_comments: required: true style: jsdoc # jsdoc, javadoc, custom include: - description - params - returns - throws inline_comments: threshold: 15 # 代码复杂度阈值 require_for: [complex_logic, workarounds]三、命名约定规则通用命名模式naming_conventions: case_types: camelCase: [variables, functions, methods] PascalCase: [classes, interfaces, types] UPPER_SNAKE: [constants, env_vars] kebab-case: [file_names, css_classes] prefixes: private: _ protected: __ test: test_ suffixes: event_handlers: Handler async_functions: Async boolean_vars: [is, has, can]语言特定规则language_specific: python: private: __ protected: _ class_methods: cls java: interfaces: I PascalCase abstract_classes: Abstract PascalCase javascript: react_components: PascalCase hook_functions: use PascalCase四、错误处理偏好异常处理策略error_handling: strategy: defensive # defensive, optimistic, hybrid exception_types: use_custom_exceptions: true checked_exceptions: [IOException, SQLException] unchecked_exceptions: [RuntimeException] error_recovery: retry_attempts: 3 fallback_mechanisms: true graceful_degradation: true验证与防御validation_rules: input_validation: required: always # always, public_only, never sanitization: true bounds_checking: true null_safety: nullable_types: false optional_chaining: preferred null_coalescing: true assertions: preconditions: true postconditions: true invariants: true五、性能优化规则内存管理performance: memory: avoid_memory_leaks: true object_pooling_threshold: 10 cache_strategy: lru max_cache_size: 100MB algorithms: time_complexity_target: O(n log n) space_complexity_target: O(n) avoid_nested_loops: true prefer_builtin_functions: true资源优化resource_optimization: database: query_optimization: true connection_pooling: true batch_operations_threshold: 100 network: request_batching: true compression_threshold: 1KB caching_headers: true computation: lazy_evaluation: where_applicable memoization_threshold: 5 parallelism: auto_detect六、安全编码规则输入安全security: input_security: sanitize_all_inputs: true validation_layers: 2 sql_injection_prevention: true xss_protection: true authentication: password_hashing: bcrypt session_timeout: 30m token_refresh: true data_protection: encryption_at_rest: true pii_identification: true data_masking: [email, phone, ssn]依赖安全dependency_security: vulnerability_scanning: true version_pinning: true license_compliance: true transitive_deps_check: true api_security: rate_limiting: true api_versioning: true deprecation_warnings: true七、规则优先级管理优先级层次priority_system: levels: - critical: # 安全、核心功能 weight: 100 cannot_override: true - high: # 主要业务规则 weight: 75 override_with: explicit_approval - medium: # 代码质量 weight: 50 override_with: justification - low: # 风格偏好 weight: 25 override_with: team_consensus冲突解决conflict_resolution: detection: automatic resolution_strategies: - higher_priority_wins - more_specific_wins - explicit_override - ask_for_clarification logging: log_conflicts: true suggest_resolutions: true track_overrides: true规则继承inheritance: base_rules: company_standards project_overrides: true module_specific: true inheritance_order: - organization - project - team - individual八、团队协作规则配置团队规范team_collaboration: code_ownership: primary_owner: true code_review_required: true minimum_reviewers: 2 consistency: shared_config_files: true auto_format_on_commit: true linting_as_prerequisite: true knowledge_sharing: documentation_required: true change_logs: true architecture_decision_records: true版本控制集成version_control: branch_strategy: git_flow commit_conventions: type_prefix: true scope_optional: true breaking_change_indicator: ! pull_requests: template_required: true linked_issues: true size_limit: 400 lines auto_merge_rules: - all_checks_pass - approved_by: 2工具集成配置tool_integration: ide: config_files: [.editorconfig, .vscode/settings.json] live_linting: true auto_completion: true ci_cd: quality_gates: - test_coverage 80% - no_new_vulnerabilities - lint_score 9 automated_checks: - dependency_audit - license_check - performance_baseline最佳实践建议规则设计原则渐进式采用从核心规则开始逐步细化可维护性规则应该易于理解、修改和扩展明确性避免模糊或冲突的规则定义可测试性规则配置应该有相应的测试用例配置管理策略management: versioning: semantic_versioning change_management: review_required: true impact_assessment: true rollback_plan: true documentation: rule_catalog: true examples_gallery: true decision_log: true性能考虑规则数量保持在可管理范围建议200条核心规则定期审查和优化规则集监控规则执行性能影响通过这套Steering规则配置系统您可以精确控制Claude的行为确保生成的代码和内容完全符合您的团队标准和项目要求。建议根据实际需求选择性启用和调整规则并在团队中建立规则的评审和更新流程。