---
name: nx-advanced-configuration-guide
description: Comprehensive documentation guide for advanced NX workspace configuration covering tagging, plugins, caching, generators, and best practices
status: open
priority: high
effort: S
estimated_hours: 1-2 weeks
dependencies: [nx-workspace-tagging-architectural-boundaries.md, nx-plugin-configuration-optimization.md, build-system-nx-remote-caching.md]
created: 2025-10-02
updated: 2025-10-02
source: P1.2 Audit Issue - NX Workspace Advanced Configuration
references: [nx-workspace-tagging-architectural-boundaries, nx-plugin-configuration-optimization, build-system-nx-remote-caching]
---

# PRD: NX Advanced Configuration Guide

## Overview

Create a comprehensive, user-facing documentation guide for advanced NX workspace configuration that consolidates implementation knowledge from existing PRDs and provides developers with a single authoritative reference for NX workspace management, optimization, and best practices.

**Key Objectives**:
1. **Consolidate NX knowledge** from 3 implementation PRDs into unified guide
2. **Provide step-by-step tutorials** for advanced configuration scenarios
3. **Document best practices** for workspace organization and optimization
4. **Enable self-service** for developers working with NX configuration
5. **Establish standards** for workspace-wide NX patterns

## Business Value

### Problem Statement

Developers currently face:
- **Fragmented Knowledge**: NX configuration guidance spread across 3 separate PRDs
- **Learning Curve**: No single guide for understanding advanced NX features
- **Configuration Uncertainty**: Unclear which NX features to use and when
- **Inconsistent Patterns**: No documented standards for workspace configuration
- **Repeated Questions**: Same NX questions asked multiple times

### Expected Outcomes

- **Single Source of Truth**: One comprehensive guide for all NX configuration topics
- **Faster Onboarding**: New developers can reference guide instead of reading 3 PRDs
- **Reduced Support Burden**: Self-service documentation reduces questions
- **Consistent Configuration**: Documented standards prevent configuration drift
- **Knowledge Retention**: Captures institutional knowledge in permanent documentation

## Scope

### In Scope

**Documentation Coverage**:
1. **NX.json Configuration Reference** (consolidated from 3 PRDs)
2. **Workspace Tagging Strategy** (from nx-workspace-tagging-architectural-boundaries.md)
3. **Plugin Management** (from nx-plugin-configuration-optimization.md)
4. **Remote Caching Setup** (from build-system-nx-remote-caching.md)
5. **Task Dependencies & Orchestration** (from build-system-nx-remote-caching.md)
6. **Architectural Boundaries** (from nx-workspace-tagging-architectural-boundaries.md)
7. **Generator Configuration** (new content)
8. **Executor Customization** (new content)
9. **Workspace Layout Best Practices** (new content)
10. **Migration Strategies** (new content)

**Target Audience**:
- Solo developer (primary)
- Future team members joining the project
- Contributors needing NX workspace understanding

### Out of Scope

- **Implementation Work**: PRDs already exist for implementation
- **Basic NX Concepts**: Assumes familiarity with NX fundamentals
- **Tool Installation**: Covered by dev-environment-setup-onboarding.md
- **Build Optimization**: Covered by existing build system PRDs

## Requirements

### Functional Requirements

#### FR1: NX.json Configuration Reference

**FR1.1**: Complete nx.json structure documentation
- Document all configured properties with examples
- Explain purpose and impact of each configuration
- Provide before/after examples showing optimization impact
- Include validation checklist for configuration correctness

**FR1.2**: namedInputs configuration guide
- Explain input patterns and file glob syntax
- Document best practices for cache invalidation
- Provide examples for different project types (apps, libs, e2e)
- Show how to debug cache misses

**FR1.3**: targetDefaults configuration guide
- Document all target types (build, test, lint, typecheck, format)
- Explain dependency chains (dependsOn: [^build])
- Show optimal parallel execution settings
- Provide troubleshooting guide for task failures

**FR1.4**: plugins configuration guide
- Document all installed @nx/* plugins
- Explain when to use each plugin
- Show plugin option customization
- Provide plugin migration guide

#### FR2: Workspace Tagging Strategy Guide

**FR2.1**: Tagging taxonomy documentation
- Document standardized tag structure: `scope:value`, `type:value`, `domain:value`, `platform:value`
- Provide tag reference table for all workspace projects
- Explain tag selection criteria for new projects
- Show tag usage in NX commands

**FR2.2**: Architectural boundaries documentation
- Document ESLint @nx/enforce-module-boundaries configuration
- Explain boundary rules for different project types
- Provide examples of allowed/disallowed imports
- Show how to add new boundary constraints

**FR2.3**: Tag-based workflows
- Document common tag-based NX commands
- Show how to run commands by tag filter
- Explain affected command with tags
- Provide CI/CD tag-based pipeline examples

#### FR3: Plugin Management Guide

**FR3.1**: Plugin audit process
- Document how to audit installed @nx/* packages
- Explain identifying unused plugins
- Show removal procedure for unused packages
- Provide validation steps after cleanup

**FR3.2**: Plugin installation guide
- Document when to add new @nx/* plugins
- Show installation and configuration steps
- Explain plugin option customization
- Provide testing checklist for new plugins

**FR3.3**: Plugin configuration optimization
- Document optimal plugin settings for each type
- Show performance impact of different configurations
- Explain compatibility considerations
- Provide migration guide for plugin updates

#### FR4: Remote Caching Configuration Guide

**FR4.1**: NX Cloud setup documentation
- Document NX Cloud account creation
- Show accessToken configuration
- Explain distributed task execution (DTE) setup
- Provide troubleshooting guide for connection issues

**FR4.2**: Cache optimization strategies
- Document cache input/output configuration
- Show how to optimize cache hit rates
- Explain cache debugging techniques
- Provide performance benchmarking guide

**FR4.3**: Local vs remote caching
- Document when to use local vs remote caching
- Show configuration for different environments
- Explain cache sharing strategies
- Provide CI/CD caching best practices

#### FR5: Task Dependencies & Orchestration Guide

**FR5.1**: Task dependency chain documentation
- Document optimal dependency patterns for all targets
- Show how to configure parallel vs sequential execution
- Explain implicit vs explicit dependencies
- Provide debugging guide for dependency issues

**FR5.2**: Custom target configuration
- Document how to add new custom targets
- Show executor configuration for custom tasks
- Explain input/output caching for custom targets
- Provide testing checklist for custom targets

**FR5.3**: Build orchestration patterns
- Document common build sequences
- Show how to optimize build order
- Explain resource allocation settings (parallel: N)
- Provide performance tuning guide

#### FR6: Generator Configuration Guide

**FR6.1**: Default generator configuration
- Document generators.json setup
- Show default options for common generators
- Explain how to customize generation templates
- Provide examples for different project types

**FR6.2**: Custom generator creation
- Document how to create workspace-specific generators
- Show generator schema definition
- Explain generator testing
- Provide migration guide for generator updates

**FR6.3**: Generator workflow automation
- Document how to chain generators
- Show automation scripts using generators
- Explain generator hooks and prompts
- Provide CI/CD generator integration examples

#### FR7: Executor Customization Guide

**FR7.1**: Custom executor configuration
- Document executor schema definition
- Show how to create custom executors
- Explain executor options and defaults
- Provide testing guide for custom executors

**FR7.2**: Executor composition patterns
- Document how to compose multiple executors
- Show executor dependency chains
- Explain executor caching configuration
- Provide performance optimization tips

#### FR8: Workspace Layout Best Practices

**FR8.1**: Project organization standards
- Document apps/ vs libs/ organization
- Explain domain-driven project structure
- Show naming conventions for projects
- Provide migration guide for reorganization

**FR8.2**: Library types and boundaries
- Document library type taxonomy (feature, ui, data-access, util)
- Explain architectural layer boundaries
- Show example project structures
- Provide refactoring guide for existing projects

**FR8.3**: Shared code patterns
- Document when to create shared libraries
- Show how to avoid circular dependencies
- Explain versioning strategies for libs
- Provide splitting guide for large libraries

#### FR9: Migration Strategies

**FR9.1**: NX version migration guide
- Document major version upgrade process
- Show breaking change handling
- Explain automated migration scripts
- Provide rollback procedures

**FR9.2**: Configuration migration patterns
- Document how to migrate old configurations
- Show deprecated feature replacements
- Explain validation after migration
- Provide testing checklist

**FR9.3**: Workspace restructuring guide
- Document safe restructuring procedures
- Show how to move projects between folders
- Explain import path updates
- Provide validation steps

#### FR10: Troubleshooting & Debugging

**FR10.1**: Common issues and solutions
- Document frequently encountered NX issues
- Show diagnostic commands for debugging
- Explain error message interpretation
- Provide step-by-step resolution guides

**FR10.2**: Performance debugging
- Document how to diagnose slow builds
- Show cache miss investigation
- Explain task dependency bottlenecks
- Provide profiling techniques

**FR10.3**: Cache debugging
- Document cache invalidation troubleshooting
- Show how to clear cache selectively
- Explain cache computation logs
- Provide cache hit rate analysis

### Non-Functional Requirements

#### NFR1: Documentation Quality
- Clear, concise writing accessible to developers
- Code examples for all configuration options
- Visual diagrams for complex concepts (tagging, boundaries)
- Consistent formatting and structure

#### NFR2: Maintainability
- Documentation lives in `/documentation/nx/` directory
- Version-controlled alongside code
- Easy to update as implementations evolve
- Links to implementation PRDs for detailed context

#### NFR3: Discoverability
- Listed in main documentation README
- Searchable by topic (tags, caching, plugins)
- Cross-referenced from implementation PRDs
- Linked from onboarding guide

#### NFR4: Completeness
- All NX.json properties documented
- All installed plugins explained
- All custom configurations captured
- Migration paths documented

## Implementation Plan

### Phase 1: Core Configuration Reference (Week 1)

**Day 1-2: NX.json Reference**
- Extract configuration from nx.json
- Document each property with examples
- Create validation checklist
- Add troubleshooting section

**Day 3-4: Tagging Strategy Guide**
- Consolidate from nx-workspace-tagging-architectural-boundaries.md
- Create tag reference table
- Document boundary rules with examples
- Add tag-based workflow examples

**Day 5: Plugin Management Guide**
- Consolidate from nx-plugin-configuration-optimization.md
- Document current plugin configuration
- Create plugin selection guide
- Add installation/removal procedures

### Phase 2: Advanced Configuration (Week 2)

**Day 6-7: Remote Caching Guide**
- Consolidate from build-system-nx-remote-caching.md
- Document NX Cloud setup steps
- Create cache optimization guide
- Add performance benchmarking section

**Day 8-9: Task Dependencies & Orchestration**
- Consolidate task dependency patterns
- Document optimal configurations
- Create troubleshooting guide
- Add performance tuning tips

**Day 10: Finalization**
- Create overview and navigation structure
- Add cross-references between sections
- Review for completeness and accuracy
- Publish to documentation directory

### Phase 3: Extended Topics (Optional - Week 3)

**Generator & Executor Guides** (if needed):
- Document generator configuration
- Create executor customization guide
- Add workflow automation examples

**Migration & Troubleshooting** (if needed):
- Create migration guides for major changes
- Expand troubleshooting section
- Add FAQ from team questions

## Documentation Structure

### Proposed File Organization

```
/documentation/nx/
├── README.md                          # Overview and navigation
├── nx-json-reference.md              # FR1: Complete nx.json reference
├── tagging-strategy.md               # FR2: Workspace tagging guide
├── plugin-management.md              # FR3: Plugin configuration
├── remote-caching.md                 # FR4: NX Cloud and caching
├── task-dependencies.md              # FR5: Task orchestration
├── generators.md                     # FR6: Generator configuration
├── executors.md                      # FR7: Custom executors
├── workspace-layout.md               # FR8: Project organization
├── migration-guide.md                # FR9: Version migrations
└── troubleshooting.md                # FR10: Common issues
```

### Document Template

Each guide follows this structure:
1. **Overview**: Purpose and audience
2. **Prerequisites**: What to know before reading
3. **Configuration Reference**: Detailed options with examples
4. **Best Practices**: Recommended patterns
5. **Examples**: Real-world use cases from workspace
6. **Troubleshooting**: Common issues and solutions
7. **References**: Links to implementation PRDs and NX docs

## Success Metrics

### Documentation Coverage
- [ ] 100% of nx.json properties documented
- [ ] All 3 implementation PRDs referenced
- [ ] All installed plugins explained
- [ ] All custom configurations captured

### Developer Adoption
- [ ] Added to onboarding checklist
- [ ] Referenced in at least 3 implementation PRDs
- [ ] Used during next NX configuration change
- [ ] Positive feedback from solo developer

### Quality Indicators
- [ ] No broken links or references
- [ ] All code examples tested and validated
- [ ] Consistent formatting throughout
- [ ] Comprehensive troubleshooting coverage

## Dependencies

### Implementation PRDs (Reference Only)
- **nx-workspace-tagging-architectural-boundaries.md**: Tagging strategy implementation
- **nx-plugin-configuration-optimization.md**: Plugin management implementation
- **build-system-nx-remote-caching.md**: Caching and task dependencies implementation

### Related Documentation
- **dev-environment-setup-onboarding.md**: Environment setup (links to NX guide)
- **build-system-wxt-documentation.md**: WXT build system (references NX)
- **package-script-naming-standardization.md**: Script naming (uses NX targets)

## Risks & Mitigation

### Risk 1: Documentation Becomes Outdated
**Mitigation**:
- Link to implementation PRDs for authoritative details
- Add "Last Updated" dates to each section
- Review during major NX version updates
- Keep examples minimal and focused

### Risk 2: Duplication with Implementation PRDs
**Mitigation**:
- Focus on user-facing "how to" content
- Reference PRDs for implementation details
- Avoid duplicating technical specifications
- Maintain clear separation of concerns

### Risk 3: Too Technical for Onboarding
**Mitigation**:
- Mark sections as "Basic" vs "Advanced"
- Provide progressive disclosure (overview → details)
- Include "When to Use" guidance for each feature
- Link to external NX docs for fundamentals

## Related PRDs

- **nx-workspace-tagging-architectural-boundaries.md**: Implementation of tagging strategy
- **nx-plugin-configuration-optimization.md**: Implementation of plugin management
- **build-system-nx-remote-caching.md**: Implementation of remote caching
- **dev-environment-setup-onboarding.md**: Environment setup references NX configuration
- **package-script-naming-standardization.md**: Script naming uses NX target conventions

## Appendix

### Example: NX.json Documentation Template

```markdown
## namedInputs Configuration

### Purpose
Define reusable input patterns for cache invalidation across multiple targets.

### Current Configuration
\`\`\`json
{
  "namedInputs": {
    "default": ["{projectRoot}/**/*", "sharedGlobals"],
    "production": ["default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?"],
    "sharedGlobals": ["{workspaceRoot}/nx.json"]
  }
}
\`\`\`

### Best Practices
1. **Use specific patterns**: Avoid overly broad patterns that invalidate cache unnecessarily
2. **Exclude test files**: Production builds shouldn't depend on test files
3. **Include shared configs**: Global configs should invalidate all caches

### Common Issues
- **Problem**: Cache never hits after any file change
- **Solution**: Check for overly broad patterns like `"**/*"`
```

### Example: Tagging Reference Table

| Project | Tags | Purpose |
|---------|------|---------|
| extension | `scope:frontend`, `type:app`, `platform:chrome` | Chrome extension application |
| chatbot | `scope:frontend`, `type:lib`, `domain:widget` | Chatbot widget library |
| backup-workflows | `scope:backend`, `type:app`, `domain:backup` | Backup service application |

### Example: Plugin Configuration Guide

```markdown
## @nx/vite Plugin

### When to Use
- Building frontend applications with Vite
- Need modern build performance (faster than Webpack)
- Working with React, Vue, or vanilla TypeScript

### Configuration
\`\`\`json
{
  "plugins": [
    {
      "plugin": "@nx/vite/plugin",
      "options": {
        "buildTargetName": "build",
        "serveTargetName": "serve",
        "previewTargetName": "preview"
      }
    }
  ]
}
\`\`\`

### See Also
- [build-system-vite-optimization.md](../prds/build-system-vite-optimization.md)
- [NX Vite Plugin Docs](https://nx.dev/nx-api/vite)
```
