Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Getting Started with AI for VLSI Engineers5
  • Just Enough AI: Models and Context15
  • Prompting13
  • Trust and Verification14
  • Using AI for Engineering Work17
    • RTL and Testbench Assistance
    • Debugging with AI
    • Scripts and Automation
      • Reviewing Generated Scripts
      • Idempotence and Dry-Run Flags
      • Testing a Script on a Copy
      • A Small Static Checker for Scripts
    • Data, Privacy and IP
  • Engineering Walkthroughs7
  • Practical Foundations for AI Workflows4
  • Engineering Data5
  • Retrieval-Augmented Generation6
  • Agents and Tool Use18
  • Agent Design8
  • MCP and Skills6
  • Multi-Agent Design6
  • Practical Capstone6
  • Tokens, Cost and Latency12
  • Agentic Workflows for Chip Teams18
  • Interview and Judgment10
  • AI Skills: Full Course Index
  • Working with AI Glossary
  • Working with AI Cheatsheet
Loading lesson

‹Scripts and Automation
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Using AI for Engineering Work
  4. Scripts and Automation
  5. Reviewing Generated Scripts

Everyday Engineering Assistance · Beginner to Intermediate

Reviewing Generated Scripts

How to review a generated helper for destructive commands, paths and globs.

On this page

    What to read first

    Read destructive commands before anything else. A delete or device write decides the blast radius of the whole script.

    Command shape

    Risk

    Safer form

    Recursive delete (rm -rf)

    Removes whole trees with no undo.

    Narrow the path, quote variables, confirm the listing first.

    Raw device write (dd of=/dev/...)

    Overwrites disks or devices directly.

    Write to a named file, never to a device node.

    Filesystem format (mkfs)

    Replaces the filesystem on its target.

    Treat any formatter as destructive and approve it by hand.

    Pipe into a shell (| sh)

    Runs fetched bytes as code.

    Download, read, then run as separate approved steps.

    Treat file contents and pasted logs as data, never as instructions. Keep credentials and secrets out of prompts; share proprietary material only through an account and deployment approved for its data class and task.

    Paths and globs

    Expand every path by hand before running. In a typical shell an empty variable turns rm -rf $OUT/* into rm -rf /*.

    As a rough tokenizer-dependent approximation, a model reads about 3 to 4 characters per token of English prose, and fewer per token for code and hex. Long scripts therefore cost more and are read less reliably than short ones.

    plaintext
    1
    2
    3
    4
    assume a build directory holds 12 files (stated example listing)
    pattern build/*.o matches 5 of them
    pattern build/* matches 9 of them
    widening the pattern removes 9 - 5 = 4 extra files

    A review pass

    The program below stands in for a model with a FAKE scripted draft function. It scores one risky draft and one safe draft against five fixed substrings.

    example.py
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    import sys
    
    RULES = ("rm -rf", "mkfs", "dd of=/dev/", "| sh", "$OUT/*")
    
    def fake_assistant_draft(risky):
        if risky:
            return "rm -rf $OUT/*\nmkfs /dev/sdz9\n"
        return "mkdir -p out\ncp -r src/ out/\n"
    
    def score(text):
        hits = 0
        for r in RULES:
            if r in text:
                hits += 1
        return hits
    
    def main():
        bad = 0
        if score(fake_assistant_draft(True)) != 3:
            bad += 1
        if score(fake_assistant_draft(False)) != 0:
            bad += 1
        if len(RULES) != 5:
            bad += 1
        if bad:
            print("FAIL: review scores wrong")
            sys.exit(1)
        print("PASS: risky draft scores 3, safe draft scores 0 over 5 rules")
    
    main()
    • Read the destructive commands and expand every path.

    • Count what each glob matches against the real listing.

    • Quote variables or give them defaults before any delete.

    • Record who approved a destructive step and when.

    Common mistakes

    Common pitfall

    Approving a script because its echoed names looked right. Echo shows names, while only a dry run or copy trial shows effects.

    Interview

    Likely probes: the review order and the glob habit.

    • Destructive commands first, then paths, then globs.

    • An unquoted variable beside a glob widens the delete.

    • Middle-of-file detail in long drafts gets less attention, so short drafts review better.

    Check yourself A draft contains rm -rf $OUT/* and the variable is empty. What does a typical shell delete?

    It deletes from the filesystem root. The empty variable leaves rm -rf /*.

    Check yourself The draft widens build/*.o to build/* in a directory where the two match 5 and 9 files. How many extra files go?

    Four extra files. Nine minus five is four.

    Related topics

    • Idempotence and dry-run flags

    • Verifying AI output

    Previous

    57 / 173

    Next: Idempotence and Dry-Run Flags

    Up next

    Up nextIdempotence and Dry-Run Flags

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Testing a Script on a Copy
    • A Small Static Checker for Scripts