diff --git a/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php b/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php
index 373a779..efee1b9 100644
--- a/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php
+++ b/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php
@@ -34,7 +34,7 @@ public static function buildProxyClassName($class_name) {
    * @return string
    *   The full string with namespace class and methods.
    */
-  public function build($class_name) {
+  public function build($class_name, $proxy_class_name = '') {
     $reflection = new \ReflectionClass($class_name);
 
     $output = '';
@@ -129,7 +129,7 @@ public function build($class_name) {
     $final_output = $class_documentation . $class_start . "\n{\n\n" . $output . "\n}\n";
 
     $final_output = str_replace('{{ class_name }}', $class_name, $final_output);
-    $final_output = str_replace('{{ proxy_class_name }}', $this->buildProxyClassName($class_name), $final_output);
+    $final_output = str_replace('{{ proxy_class_name }}', $proxy_class_name ?: $this->buildProxyClassName($class_name), $final_output);
 
     return $final_output;
   }
diff --git a/core/lib/Drupal/Core/Command/GenerateProxyClassApplication.php b/core/lib/Drupal/Core/Command/GenerateProxyClassApplication.php
new file mode 100644
index 0000000..52132a4
--- /dev/null
+++ b/core/lib/Drupal/Core/Command/GenerateProxyClassApplication.php
@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Command\GenerateProxyClassApplication.
+ */
+
+namespace Drupal\Core\Command;
+
+use Drupal\Component\ProxyBuilder\ProxyBuilder;
+use Symfony\Component\Console\Application;
+use Symfony\Component\Console\Input\InputInterface;
+
+class GenerateProxyClassApplication extends Application {
+
+  /**
+   * The proxy builder.
+   *
+   * @var \Drupal\Component\ProxyBuilder\ProxyBuilder
+   */
+  protected $proxyBuilder;
+
+  /**
+   * Constructs a new GenerateProxyClassApplication instance.
+   *
+   * @param \Drupal\Component\ProxyBuilder\ProxyBuilder $proxy_builder
+   *   The proxy builder.
+   */
+  public function __construct(ProxyBuilder $proxy_builder) {
+    $this->proxyBuilder = $proxy_builder;
+
+    parent::__construct();
+  }
+
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getCommandName(InputInterface $input) {
+    return 'generate-proxy-class';
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getDefaultCommands() {
+    // Even though this is a single command, keep the HelpCommand (--help).
+    $default_commands = parent::getDefaultCommands();
+    $default_commands[] = new GenerateProxyClassCommand($this->proxyBuilder);
+    return $default_commands;
+  }
+
+  /**
+   * {@inheritdoc}
+   *
+   * Overridden so the application doesn't expect the command name as the first
+   * argument.
+   */
+  public function getDefinition() {
+    $definition = parent::getDefinition();
+    // Clears the normal first argument (the command name).
+    $definition->setArguments();
+    return $definition;
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php b/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php
new file mode 100644
index 0000000..47da385
--- /dev/null
+++ b/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php
@@ -0,0 +1,75 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Command\GenerateProxyClassCommand.
+ */
+
+namespace Drupal\Core\Command;
+
+use Drupal\Component\ProxyBuilder\ProxyBuilder;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class GenerateProxyClassCommand extends Command {
+
+  /**
+   * The proxy builder.
+   *
+   * @var \Drupal\Component\ProxyBuilder\ProxyBuilder
+   */
+  protected $proxyBuilder;
+
+  /**
+   * Constructs a new GenerateProxyClassCommand instance.
+   *
+   * @param \Drupal\Component\ProxyBuilder\ProxyBuilder $proxy_builder
+   *   The proxy builder.
+   */
+  public function __construct(ProxyBuilder $proxy_builder) {
+    parent::__construct();
+
+    $this->proxyBuilder = $proxy_builder;
+  }
+
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function configure() {
+    $this->setName('generate-proxy-class')
+      ->setDefinition([
+        new InputArgument('class_name', InputArgument::REQUIRED, 'The class to be proxied'),
+        new InputArgument('namespace_root', InputArgument::REQUIRED, 'The filepath to the root of the namespace.'),
+      ])
+      ->setDescription('Dumps a generated proxy class into its appropriate namespace.');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function execute(InputInterface $input, OutputInterface $output) {
+    $class_name = $input->getArgument('class_name');
+    $namespace_root = $input->getArgument('namespace_root');
+
+    $match = [];
+    preg_match('/([a-zA-Z0-9]+\\\\[a-zA-Z0-9]+)\\\\(.+)/', $class_name, $match);
+
+    if ($match) {
+      $root_namespace = $match[1];
+      $rest_fqcn = $match[2];
+
+      $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php';
+      $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn;
+      $proxy_class_string = $this->proxyBuilder->build($class_name, $proxy_class_name);
+
+      file_put_contents($proxy_filename, $proxy_class_string);
+
+      $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename));
+    }
+
+  }
+
+}
diff --git a/core/scripts/generate-proxy-class.php b/core/scripts/generate-proxy-class.php
new file mode 100644
index 0000000..974c41c
--- /dev/null
+++ b/core/scripts/generate-proxy-class.php
@@ -0,0 +1,25 @@
+#!/usr/bin/env php
+<?php
+
+use Drupal\Core\Command\DbDumpApplication;
+use Drupal\Core\Command\GenerateProxyClassApplication;
+use Drupal\Core\Database\Database;
+use Drupal\Core\DrupalKernel;
+use Drupal\Core\ProxyBuilder\ProxyBuilder;
+use Drupal\Core\Site\Settings;
+use Symfony\Component\HttpFoundation\Request;
+
+if (PHP_SAPI !== 'cli') {
+  return;
+}
+
+// Bootstrap.
+$autoloader = require __DIR__ . '/../../autoload.php';
+require_once __DIR__ . '/../includes/bootstrap.inc';
+$request = Request::createFromGlobals();
+Settings::initialize(dirname(dirname(__DIR__)), DrupalKernel::findSitePath($request), $autoloader);
+$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
+
+// Run the database dump command.
+$application = new GenerateProxyClassApplication(new ProxyBuilder());
+$application->run();
