Best Practices

Best Practices

Opinionated guidance for getting the most out of LogicStamp Context with AI coding assistants.

Use the Right Context Files in Prompts

AI assistants do their best work when you give them a single, structured view of your project instead of raw source files.

đź’ˇ Best Practice: When prompting an AI assistant, explicitly tell it to use the per-folder context.json files and the root context_main.json to understand your project structure. This produces the most consistent and grounded results across all assistants.

Using src/app/docs/getting-started/context.json, explain how the Installation & Quick Start page is structured.

Keep Context Fresh After Refactors

Stale context is worse than no context. Regenerate bundles when you make structural changes so assistants don't reason about an outdated graph.

After big refactors

  • • Moving components between folders
  • • Renaming shared utilities or hooks
  • • Changing public props or exported APIs

Recommended workflow

stamp context compare

Choose the Right Code Inclusion Mode

Most teams never need full source code in every bundle. Start with headers, then selectively turn on full code for deep investigations. Use --compare-modes to see exact token costs before committing to a mode.

ModeWhat it includesBest forToken cost
noneContracts onlyAPI docs, CI checks10-20% of raw
header defaultJSDoc, signatures, and contractsEveryday AI chat and code review20-30% of raw
header+styleHeader + style metadata (Tailwind, SCSS, animations)UI/UX discussions, design system work40-60% of raw
fullComplete sourceTargeted deep dives on tricky areas80-100% of raw

đź’ˇ Best Practice: Before generating context for a large project, run stamp context --compare-modes to see exact token costs across all modes. This helps you choose the most cost-effective mode for your use case and budget.

# See token costs for all modes before generating stamp context --compare-modes

Use Compare Modes Before Generating Context

The --compare-modes flag shows you token costs across all modes without writing any files. This helps you make informed decisions about which mode fits your budget and use case.

When to use compare modes

  • • Before generating context for large projects
  • • When optimizing token budgets
  • • Evaluating style metadata overhead
  • • Planning AI workflow costs
  • • Comparing against raw source dumps

What you get

📊 Mode Comparison Comparison: Mode | Tokens GPT-4o | Tokens Claude | Savings vs Raw Source -------------|---------------|---------------|------------------------ Raw source | 22,000 | 19,556 | 0% Header | 12,228 | 10,867 | 44% Header+style | 13,895 | 12,351 | 37% Mode breakdown: Mode | Tokens GPT-4o | Tokens Claude | Savings vs Full Context -------------|---------------|---------------|-------------------------- none | 8,337 | 7,411 | 79% header | 12,228 | 10,867 | 69% header+style | 13,895 | 12,351 | 65% full | 39,141 | 34,792 | 0%

💡 Pro Tip: Compare modes is analysis-only—it doesn't write any files. Use it liberally to experiment with different configurations before committing to a mode. The analysis takes 2-3x longer than normal generation but provides invaluable cost insights.

Security Best Practices

Prevent secrets from being included in your context files. LogicStamp includes built-in security scanning to detect API keys, passwords, tokens, and other sensitive data in your JS/TS/JSON files before they reach context generation.

đź”’ Security Scan Runs by Default

By default, stamp init automatically runs a security scan to detect secrets in your JS/TS/JSON files. Review the security report and use stamp ignore <file> to exclude files with detected secrets from context generation.

cd your-react-project stamp init

⚠️ Important: If secrets are detected, they are automatically sanitized in generated context files (replaced with "PRIVATE_DATA"). Your source code files are never modified.

Best practice: Remove secrets from your codebase and use environment variables or a secrets manager (e.g., Vault, Doppler, AWS Secrets Manager) instead.

Regular security scans

Run security scans regularly, especially before generating context or committing code:

# Scan current directory stamp security scan # Review report and exclude files stamp ignore src/secrets.ts

CI/CD integration

Add security scanning to your CI pipeline to catch secrets before they're committed:

# Fail build if secrets detected stamp security scan --quiet # Exit code: 0 (no secrets) or 1 (secrets found)

💡 Best Practice: Security scanning runs 100% locally—nothing is uploaded or sent anywhere. The scanner detects API keys, passwords, tokens, AWS keys, GitHub tokens, private keys, database URLs, JWT secrets, and more in your TypeScript, JavaScript, and JSON files.

Integrate LogicStamp Into Your Workflow

Treat context generation like tests or type-checking: something that runs regularly so your AI tools always see the latest structure.

Local development

  • • Run on demand before complex AI-assisted work
  • • Keep bundles in sync with your feature branches

CI / CD pipelines

# Scan for secrets first stamp security scan --quiet # Generate fresh context stamp context # Validate before using or publishing stamp context validate