50 | 6. Writes the files to your computer using the writefiles
prompt template
51 |
52 |
53 | From now on you can write to files using the following syntax:
54 |
55 | filename.ext
56 | ```language
57 | file content
58 | ```
59 |
60 | You must match this format EXACTLY. Example, to write to hello_world.txt:
61 |
62 | hello_world.txt
63 | ```
64 | This is the content of hello_world.txt
65 | ```
66 |
67 | {prompt}
68 |
69 | {#every}
70 | {#js}
71 | // Parse claude's response and write files if applicable
72 | const regex = /(?([\w_-]+\.)+\w+)\n?```(\w+\n)?\n?(?[\s\S]+?)\n?```/g
73 | let match;
74 | while (match = regex.exec(variables.claude_response.completion)) {
75 | writeFileSync(match.groups.file, match.groups.body);
76 | console.log(chalk.bold.green(`Wrote ${match.groups.body.split('\n').length} lines to ${chalk.bold.red(match.groups.file)}`))
77 | }
78 | {/js}
79 | {/every}
80 |
81 |
82 |
83 |
84 | # Output (code was _very_ lightly edited ~2 lines changed):
85 | Pause the recording to view total code
86 |
87 |